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

3157 refactor scoped states to move to v3 #3180

Merged
merged 48 commits into from
Jan 3, 2024

Conversation

bosiraphael
Copy link
Contributor

For dropdown and record-table:

@bosiraphael bosiraphael linked an issue Dec 29, 2023 that may be closed by this pull request
Copy link

github-actions bot commented Dec 29, 2023

TODOs/FIXMEs:

  • // TODO: refactor with scoped state later: packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRecordTableData.ts
  • // TODO: refactor with scoped state later: packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useUpsertRecordTableItem.ts

Generated by 🚫 dangerJS against c7ffb6d

@bosiraphael bosiraphael marked this pull request as ready for review January 2, 2024 10:54
const { selectedRowIdsScopeInjector } = getRecordTableScopeInjector();

const { injectSelectorSnapshotValueWithRecordTableScopeId } =
useRecordTableScopedStates(recordTableScopeId);
Copy link
Member

Choose a reason for hiding this comment

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

this internal hook should not be called from the outside of recordTable
I think we should expose the pre-injected state out of useRecordTable: const { selectedRowIdsScopeInjector } = useRecordTable(recordTableScopeId) that would internally do what you are doing here

@@ -13,10 +13,10 @@ describe('groupActivitiesByMonth', () => {
expect(grouped[0].items).toHaveLength(1);
expect(grouped[1].items).toHaveLength(1);

expect(grouped[0].year).toBe(2023);
expect(grouped[0].year).toBe(new Date().getFullYear());
Copy link
Member

Choose a reason for hiding this comment

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

wow!

objectNamePlural,
createRecord,
}: {
recordTableId: string;
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 introduce RecordTableContainerProps

objectNamePlural={objectNamePlural}
createRecord={handleAddButtonClick}
/>
</StyledTableContainer>
<RecordTableActionBar />
<RecordTableContextMenu />
<RecordTableActionBar recordTableId={recordTableId} />
Copy link
Member

Choose a reason for hiding this comment

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

makes sense to pass recordTableId. I wonder if we should actually move RecordTableActionBar and ContextMenu within RecordTable itself (we can keep that for later refactoring)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was wondering the same thing

tableFiltersScopeInjector,
tableSortsScopeInjector,
tableLastRowVisibleScopeInjector,
} = getRecordTableScopeInjector();
Copy link
Member

Choose a reason for hiding this comment

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

getRecordTableScopeInjectors (I actually think that getRecordTableScopedStateGetter might be a better naming after all :p)

@charlesBochet
Copy link
Member

Looks good
Found a few bugs:

(Hover seems to be added to all cells)
image

(Create View button is broken)
image

@charlesBochet charlesBochet merged commit b0d3e6d into main Jan 3, 2024
13 checks passed
@charlesBochet charlesBochet deleted the 3157-refactor-scoped-states-to-move-to-v3 branch January 3, 2024 18:45
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.

Refactor scoped states to move to V3
2 participants