Migrate record table to scope map (#3363)

* Migrate record table to scope map

* Update record scope id to record id

* Remove todos and fix edit mode

* Fix perf

* Fix tests

* Fix tests

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Thomas Trompette
2024-01-11 17:44:40 +01:00
committed by GitHub
parent 5f0c9f67c9
commit 6bae6fcdce
84 changed files with 713 additions and 1121 deletions

View File

@ -1,22 +1,19 @@
import { useRecoilCallback } from 'recoil';
import { ActivityType } from '@/activities/types/Activity';
import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';
import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';
import { useRecordTableStates } from '@/object-record/record-table/hooks/internal/useRecordTableStates';
import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
import { ActivityTargetableObject } from '../types/ActivityTargetableEntity';
import { useOpenCreateActivityDrawer } from './useOpenCreateActivityDrawer';
export const useOpenCreateActivityDrawerForSelectedRowIds = (
recordTableScopeId: string,
recordTableId: string,
) => {
const openCreateActivityDrawer = useOpenCreateActivityDrawer();
const { selectedRowIdsScopeInjector } = getRecordTableScopeInjector();
const { injectSelectorSnapshotValueWithRecordTableScopeId } =
useRecordTableScopedStates(recordTableScopeId);
const { selectedRowIdsSelector } = useRecordTableStates(recordTableId);
return useRecoilCallback(
({ snapshot }) =>
@ -25,11 +22,10 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = (
objectNameSingular: string,
relatedEntities?: ActivityTargetableObject[],
) => {
const selectedRowIds =
injectSelectorSnapshotValueWithRecordTableScopeId(
snapshot,
selectedRowIdsScopeInjector,
);
const selectedRowIds = getSnapshotValue(
snapshot,
selectedRowIdsSelector,
);
let activityTargetableEntityArray: ActivityTargetableObject[] =
selectedRowIds.map((id: string) => ({
@ -48,10 +44,6 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = (
targetableObjects: activityTargetableEntityArray,
});
},
[
injectSelectorSnapshotValueWithRecordTableScopeId,
openCreateActivityDrawer,
selectedRowIdsScopeInjector,
],
[openCreateActivityDrawer, selectedRowIdsSelector],
);
};