-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
7336 create contextstore #7374
7336 create contextstore #7374
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR implements a new ContextStore feature, introducing three new states to manage object metadata, views, and targeted records across the application.
- Added
contextStoreCurrentObjectMetadataIdState
,contextStoreCurrentViewIdState
, andcontextStoreTargetedRecordIdsState
in separate files underpackages/twenty-front/src/modules/context-store/states/
- Updated
PageChangeEffect.tsx
to manage new context store states based on URL parameters - Modified
RecordIndexBoardDataLoaderEffect.tsx
andRecordIndexTableContainerEffect.tsx
to updatecontextStoreTargetedRecordIdsState
with selected record IDs - Introduced
useSetViewInUrl
hook inpackages/twenty-front/src/modules/views/hooks/useSetViewInUrl.ts
for managing view ID in URL - Added
RecordShowPageEffect.tsx
to updatecontextStoreTargetedRecordIdsState
when viewing a single record
11 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
@@ -49,6 +58,29 @@ export const PageChangeEffect = () => { | |||
activityObjectNameSingular: CoreObjectNameSingular.Task, | |||
}); | |||
|
|||
const [searchParams] = useSearchParams(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract this to another ComponentEffect: ContextStorePageChangeEffect.tsx
const [searchParams] = useSearchParams(); | ||
const { objectNameSingular, objectNamePlural } = useParams(); | ||
|
||
const objectMetadataItem = useRecoilValue( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
every page
const [searchParams] = useSearchParams(); | ||
const { objectNameSingular, objectNamePlural } = useParams(); | ||
|
||
const objectMetadataItem = useRecoilValue( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
introduce a hook for that useObjectMetadataItemFromPluralOrSingular
@@ -37,6 +38,7 @@ export const QueryParamsViewIdEffect = () => { | |||
objectMetadataItemId?.id, | |||
lastVisitedObjectMetadataItemId, | |||
); | |||
const { setViewInUrl } = useSetViewInUrl(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should push the viewId from there
packages/twenty-front/src/modules/app/effect-components/PageChangeEffect.tsx
Outdated
Show resolved
Hide resolved
import { useParams } from 'react-router-dom'; | ||
import { useSetRecoilState } from 'recoil'; | ||
|
||
export const RecordShowPageEffect = ({ recordId }: { recordId: string }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RecordShowPageContextStoreEffect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Closes twentyhq#7336 Create 3 states: - `contextStoreCurrentObjectMetadataIdState`: is set when we change object metadata - `contextStoreCurrentViewIdState`: is set when we change view - `contextStoreTargetedRecordIdsState`: is set when we select records inside a table or a board or when a show page is opened. Is reset when we change view.
Closes #7336
Create 3 states:
contextStoreCurrentObjectMetadataIdState
: is set when we change object metadatacontextStoreCurrentViewIdState
: is set when we change viewcontextStoreTargetedRecordIdsState
: is set when we select records inside a table or a board or when a show page is opened. Is reset when we change view.