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

View module refactor with atomic recoil component instance states #6810

Merged
merged 23 commits into from
Sep 20, 2024

Conversation

lucasbordeau
Copy link
Contributor

@lucasbordeau lucasbordeau commented Aug 30, 2024

This PR refactors the view module to implement utils that avoid having to create hooks to inject the scope id in the states, like useViewStates, each componentState will know its unique related InstanceContext (which holds the instanceId), and thus will be able to retrieve it itself.

We keep the naming componentState as it reflects the fact that those states are tied to instances of a component (or its children).

We introduce the instance word where it is needed, in place of scopeId for example, to precise the fact that we handle instances of component state, one for each instance of a component.

For example, the currentViewId is a state that is tied to an instance of the ViewBar, but as we can switch between views, we want currentViewId to be a componentState tied to an instance of the ViewBar component.

This PR also refactors view filter and sort states to fix this issue : #6837 and other problems involving resetting those states between page navigation.

Fixes #6837

Copy link

github-actions bot commented Sep 3, 2024

TODOs/FIXMEs:

  • // TODO: verify this instance id works: packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsx
  • // TODO: verify this instance id works: packages/twenty-front/src/modules/object-record/record-table/action-bar/components/RecordTableActionBar.tsx
  • // TODO: verify this instance id works: packages/twenty-front/src/modules/views/components/ViewBarFilterEffect.tsx
  • // TODO: fix this implicit hack: packages/twenty-front/src/modules/views/components/QueryParamsViewIdEffect.tsx
  • // TODO: scope view bar per view id if possible: packages/twenty-front/src/modules/views/components/QueryParamsViewIdEffect.tsx
  • // TODO: verify this instance id works: packages/twenty-front/src/modules/object-record/object-sort-dropdown/hooks/__tests__/useSortDropdown.test.tsx
  • // TODO: verify this instance id works: packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexTableContainerEffect.tsx

Generated by 🚫 dangerJS against 02ac82e

@lucasbordeau lucasbordeau changed the title Refactor/views recoil component states v2 View module refactor with atomic recoil component states Sep 9, 2024
@lucasbordeau lucasbordeau changed the title View module refactor with atomic recoil component states View module refactor with atomic recoil component instance states Sep 9, 2024
@lucasbordeau lucasbordeau marked this pull request as ready for review September 11, 2024 17:47
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request refactors the view module to implement atomic Recoil component instance states, focusing on improving state management and fixing issues with filter and sort persistence between page navigations.

  • Introduces useRecoilComponentValueV2 hook to replace various custom hooks for state management
  • Removes '-scope' suffix from component IDs for simplified and consistent state handling
  • Updates createComponentStateV2 to createComponentStateV2_alpha for better instance context support
  • Refactors filter and sort dropdown components to use new state management approach
  • Addresses issue Breadcrumbs Ignore Temporary Filters on Detail Page #6837 by improving temporary filter persistence during page navigation

30 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

Another masterpiece ;)

@lucasbordeau lucasbordeau merged commit 2552275 into main Sep 20, 2024
11 of 13 checks passed
@lucasbordeau lucasbordeau deleted the refactor/views-recoil-component-states-V2 branch September 20, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breadcrumbs Ignore Temporary Filters on Detail Page
2 participants