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

7336 create contextstore #7374

Merged
merged 15 commits into from
Oct 8, 2024
Merged

7336 create contextstore #7374

merged 15 commits into from
Oct 8, 2024

Conversation

bosiraphael
Copy link
Contributor

@bosiraphael bosiraphael commented Oct 1, 2024

Closes #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.

@bosiraphael bosiraphael linked an issue Oct 1, 2024 that may be closed by this pull request
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 PR implements a new ContextStore feature, introducing three new states to manage object metadata, views, and targeted records across the application.

  • Added contextStoreCurrentObjectMetadataIdState, contextStoreCurrentViewIdState, and contextStoreTargetedRecordIdsState in separate files under packages/twenty-front/src/modules/context-store/states/
  • Updated PageChangeEffect.tsx to manage new context store states based on URL parameters
  • Modified RecordIndexBoardDataLoaderEffect.tsx and RecordIndexTableContainerEffect.tsx to update contextStoreTargetedRecordIdsState with selected record IDs
  • Introduced useSetViewInUrl hook in packages/twenty-front/src/modules/views/hooks/useSetViewInUrl.ts for managing view ID in URL
  • Added RecordShowPageEffect.tsx to update contextStoreTargetedRecordIdsState 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();
Copy link
Member

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(
Copy link
Member

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(
Copy link
Member

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();
Copy link
Member

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

import { useParams } from 'react-router-dom';
import { useSetRecoilState } from 'recoil';

export const RecordShowPageEffect = ({ recordId }: { recordId: string }) => {
Copy link
Member

Choose a reason for hiding this comment

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

RecordShowPageContextStoreEffect

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.

LGTM!

@bosiraphael bosiraphael merged commit a8da0e2 into main Oct 8, 2024
13 checks passed
@bosiraphael bosiraphael deleted the 7336-create-contextstore branch October 8, 2024 16:40
harshit078 pushed a commit to harshit078/twenty that referenced this pull request Oct 14, 2024
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.
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.

Create ContextStore
2 participants