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

Refactor frontend stores for table-data #651

Closed
pavish opened this issue Sep 9, 2021 · 11 comments · Fixed by #654 or #816
Closed

Refactor frontend stores for table-data #651

pavish opened this issue Sep 9, 2021 · 11 comments · Fixed by #654 or #816
Assignees
Labels
affects: architecture Improvements or additions to architecture affects: technical debt Improves the state of the codebase restricted: maintainers Only maintainers can resolve this issue type: enhancement New feature or request work: frontend Related to frontend code in the mathesar_ui directory

Comments

@pavish
Copy link
Member

pavish commented Sep 9, 2021

Purpose of this refactor:

  1. Our tableData store handles colums, records and meta information needed for parameters and display purposes. It also includes the type definitions for all of them. This makes it cluttered, and there is an overlap of different concerns.
    A better approach would be to split it into separate stores, and have a parent store which maintains the rest.
  2. Currently, logic of certain requirements such passing parameters to table record request, refetching table data when params change etc., are done on the component. This can be side stepped and done entirely by observing store values. This gives a cleaner view/data model.
  3. We need to simplify certain display specific stores such as column position map, to improve readability.
  4. General improvements, separate out cells from header and row as different components.
  5. Update svelte, vite and related packages.
@pavish pavish added type: enhancement New feature or request affects: architecture Improvements or additions to architecture affects: technical debt Improves the state of the codebase work: frontend Related to frontend code in the mathesar_ui directory ready Ready for implementation restricted: maintainers Only maintainers can resolve this issue labels Sep 9, 2021
@pavish pavish added this to the 06. 2021-09 Stability milestone Sep 9, 2021
@pavish pavish self-assigned this Sep 9, 2021
@dmos62
Copy link
Contributor

dmos62 commented Sep 9, 2021

While working on some things that used the stores namespace I too found it cluttered. I'm happy to see that the refactor isn't being put off.

I'll share some ideas I had.

I think semantically and modularly it would be nice to make the stores namespace thin, holding declarations of Readables and Writables and not much more, referencing the logic for their declaration from other namespaces. That would imply one or more other parallel namespaces that would sit between the stores and the HTTP client. This would give a central place for holding state and declaring its flow graph, without the mixing of logic.

It's desirable that the structure of the stores and the modularity of logic follow the spirit of the API (which may require a refactor as well).

Hope these thoughts are useful.

@pavish
Copy link
Member Author

pavish commented Sep 9, 2021

@dmos62 Thanks. Your comments make a lot of sense.

That would imply one or more other parallel namespaces that would sit between the stores and the HTTP client. This would give a central place for holding state and declaring its flow graph, without the mixing of logic.

This is a cleaner structure, and I did consider it while starting on the stores. But that would have been premature optimization. These were my reasons:

The major issue with making modules thin on the frontend is that it eventually leads to a larger build size. The approach module bundlers use to bundle frontend code results in a set of boilerplate code for each file when it's built. The more the number of files, the higher the bundle size.

The tradeoff here is between good user experience (with lower load time) and good developer experience(with thinner modules). As a team, we prioritize the user.

It was a calculated decision to keep all the stores and their respective api calls in one place. We only refactor when it becomes essential, as in this case, where each of the stores are better managed separately. However, separating the api layer would still be premature at this juncture. We can get to it when we reach the point where it becomes essential.

@mr-gabe49 mr-gabe49 modified the milestones: 06. 2021-09 Stability, 22. Alpha Release Sep 12, 2021
@mr-gabe49
Copy link
Member

mr-gabe49 commented Sep 12, 2021

I'm so sorry, I don't know what I did. I was playing around. It says I modified the milestones: 06. 2021-09 Stability, 22. 22 Alpha Release. I fixed it :).

@mr-gabe49 mr-gabe49 modified the milestones: 22. Alpha Release, 06. 2021-09 Stability Sep 12, 2021
@kgodey
Copy link
Contributor

kgodey commented Sep 13, 2021

@mr-gabe49 No worries.

@pavish
Copy link
Member Author

pavish commented Sep 14, 2021

This issue has the following tasks:

  • Update svelte and vite to latest versions
  • Handle segregation needed for views
  • Create dedicated stores for columns, records, meta, display
  • Handle records re-request directly in store bypassing component layer
  • Handle column position recalc directly in store bypassing component layer
  • Handle record deletion directly from store
  • Use pagination instead of infinite scroll
  • Handle URL sync from store instead of component layer
  • Handle grouping on store response instead of component
  • Fix errors reported by svelte-typecheck
  • Separate cells from header and row

PRs that handle these:

Yet to handle:

  • Handle URL sync from store instead of component layer

@pavish pavish linked a pull request Sep 19, 2021 that will close this issue
7 tasks
@kgodey
Copy link
Contributor

kgodey commented Sep 27, 2021

@pavish It seems like there's one item left to do on your list, so I'm reopening this. Feel free to close if the URL sync is already done.

@kgodey kgodey reopened this Sep 27, 2021
@pavish
Copy link
Member Author

pavish commented Sep 27, 2021

@kgodey Thanks. I missed the fact that the issue got closed. It's not yet been handled, I will handle it in future PRs.

@pavish
Copy link
Member Author

pavish commented Sep 29, 2021

@kgodey We have a dedicated milestone for Sharing.

I think URL sync belongs in that milestone. Let me know your thoughts.

@kgodey
Copy link
Contributor

kgodey commented Sep 30, 2021

@pavish What is the current state of URL sync? If there's broken functionality, I think it would be better to fix it sooner.

@pavish
Copy link
Member Author

pavish commented Oct 7, 2021

@kgodey URL sync currently does not retain pagination, filters, groups and sort. Syncing for these parts need to be re-implemented based on the new stores. I was thinking it belongs more in the Sharing milestone, but now I agree that it's better to fix it sooner.

@kgodey
Copy link
Contributor

kgodey commented Oct 7, 2021

@pavish I'll leave it in here then.

@kgodey kgodey removed the ready Ready for implementation label Oct 12, 2021
@kgodey kgodey modified the milestones: [06] 2021-10 Stability, [06A] 2021-10 improvements Oct 14, 2021
Repository owner moved this from Started to Done in [NO LONGER USED] Mathesar work tracker Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: architecture Improvements or additions to architecture affects: technical debt Improves the state of the codebase restricted: maintainers Only maintainers can resolve this issue type: enhancement New feature or request work: frontend Related to frontend code in the mathesar_ui directory
Projects
No open projects
4 participants