Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabledata store reorganization #654

Merged
merged 30 commits into from
Sep 20, 2021
Merged

Tabledata store reorganization #654

merged 30 commits into from
Sep 20, 2021

Conversation

pavish
Copy link
Member

@pavish pavish commented Sep 13, 2021

Related to #651

Technical details

This PR:

  • Updates svelte and vite to latest versions
  • Handles segregation needed for views
  • Creates dedicated stores for columns, records, meta, display
  • Handles records re-request directly in store bypassing component layer
  • Handles column position recalc directly in store bypassing component layer
  • Handles record deletion directly from store
  • Uses pagination instead of infinite scroll
  • Handles grouping on store response instead of component
  • Fixes errors reported by svelte-typecheck
  • Separates cells from header and row

Breaking changes:

  • URL sync is broken for filtering, sorting and grouping. This will be handled incrementally, as it is not a blocker to other PRs.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the master branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@pavish pavish marked this pull request as ready for review September 14, 2021 17:19
@pavish pavish requested review from a team, kgodey and eito-fis September 14, 2021 17:19
@pavish pavish linked an issue Sep 19, 2021 that may be closed by this pull request
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things seem to work on my machine, and the tests are passing.

Optional suggestion:

While I think the new organization makes sense on a file level, I find it a little confusing at the directory level. The table-data directory contains files pertaining to not just the data for a table (i.e., the records), but also the metadata, and also some display concerns. I suggest either renaming that directory, or even further subdividing into three directories roughly along the lines:

  • actual data storage
  • metadata storage
  • display variables storage.

However, I defer to your experience here, @pavish , since I have little knowledge in the idiomatic use of the tools in question.

@pavish
Copy link
Member Author

pavish commented Sep 20, 2021

@mathemancer I agree that it would make more sense to come up with a better name for the directory. Splitting it up into smaller directories would not be ideal at this point, since there is only one file per type of data.

I will handle this in the upcoming PR: #671

@pavish
Copy link
Member Author

pavish commented Sep 20, 2021

@kgodey @zackkrida @dhruvkb @mr-gabe49 Please feel free to add review comments. I'll go ahead and merge this PR since it's blocking other PRs, and handle the comments in a separate PR.

@pavish pavish merged commit 2be0836 into master Sep 20, 2021
@pavish pavish deleted the editable_tables branch September 20, 2021 09:42

function recalculateColumnPositions(columnPositionMap: ColumnPositionMap, columns: TableColumn[]) {
let left = ROW_CONTROL_COLUMN_WIDTH;
const newColumnPositionMap: ColumnPositionMap = new Map(columnPositionMap);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pavish, fabulous work here! Quick question: What's the reasoning for passing columnPositionMap inside of new Map() ? It prevents columnPositionMap from updating correctly in line 76-78: this.columnPositionMap.update( (map) => recalculateColumnPositions(map, columnData.data), ); when calling columns.fetch() after a column is deleted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mr-gabe49 When a column has been previously resized, the columnPositionMap would contain a different value for width instead of the default column width. We create a new map using the existing map to retain it.

Good catch, I hadn't considered the effect of deletion.

In your PR for column deletion, we could update lines 30-32 to:

  const newColumnPositionMap: ColumnPositionMap = new Map();
  columns.forEach((column) => {
    const columnWidth = columnPositionMap.get(column.name)?.width;

Since we have access to the old map, we could use it to get the previous width. This would handle position recalc for both resize and delete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Refactor frontend stores for table-data
3 participants