3157 refactor scoped states to move to v3 (#3180)

* renaming

* renaming

* create getDropdownScopeInjectors

* update useDropdown

* create internal hooks folder

* update record-table states to be scoped states

* update record-table selectors to be scoped selectors

* create utils scope injector

* refactor record-table wip

* refactor record-table wip

* wip

* inject scopeId in selectors

* update intenal hooks

* update intenal hooks

* update intenal hooks

* update intenal hooks

* update intenal hooks

* update intenal hooks

* update internal hooks

* update internal hooks

* update internal hooks

* update internal hooks

* update useTableColumns

* update states and hooks

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* refactoring

* fix scopeId not in context

* fix lint errors

* fix error in story

* fix errors: wip

* fix errors

* fix error

* fix jest test

* fix scopeId not defined

* fix jest test

* Bug fixes

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
bosiraphael
2024-01-03 19:45:14 +01:00
committed by GitHub
parent 65250839fb
commit b0d3e6d8d3
112 changed files with 1447 additions and 716 deletions

View File

@ -20,7 +20,7 @@ export const AttachmentDropdown = ({
}: AttachmentDropdownProps) => {
const dropdownScopeId = `${scopeKey}-settings-field-active-action-dropdown`;
const { closeDropdown } = useDropdown({ dropdownScopeId });
const { closeDropdown } = useDropdown(dropdownScopeId);
const handleDownload = () => {
onDownload();

View File

@ -1,7 +1,8 @@
import { useRecoilCallback } from 'recoil';
import { ActivityType } from '@/activities/types/Activity';
import { selectedRowIdsSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsSelector';
import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';
import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';
import {
ActivityTargetableEntity,
@ -10,9 +11,16 @@ import {
import { useOpenCreateActivityDrawer } from './useOpenCreateActivityDrawer';
export const useOpenCreateActivityDrawerForSelectedRowIds = () => {
export const useOpenCreateActivityDrawerForSelectedRowIds = (
recordTableScopeId: string,
) => {
const openCreateActivityDrawer = useOpenCreateActivityDrawer();
const { selectedRowIdsScopeInjector } = getRecordTableScopeInjector();
const { injectSelectorSnapshotValueWithRecordTableScopeId } =
useRecordTableScopedStates(recordTableScopeId);
return useRecoilCallback(
({ snapshot }) =>
(
@ -20,9 +28,12 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = () => {
entityType: ActivityTargetableEntityType,
relatedEntities?: ActivityTargetableEntity[],
) => {
const selectedRowIds = snapshot
.getLoadable(selectedRowIdsSelector)
.getValue();
const selectedRowIds =
injectSelectorSnapshotValueWithRecordTableScopeId(
snapshot,
selectedRowIdsScopeInjector,
);
let activityTargetableEntityArray: ActivityTargetableEntity[] =
selectedRowIds.map((id: string) => ({
type: entityType,
@ -37,6 +48,10 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = () => {
targetableEntities: activityTargetableEntityArray,
});
},
[openCreateActivityDrawer],
[
injectSelectorSnapshotValueWithRecordTableScopeId,
openCreateActivityDrawer,
selectedRowIdsScopeInjector,
],
);
};

View File

@ -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());
expect(grouped[1].year).toBe(2023);
expect(grouped[0].month).toBe(11);
expect(grouped[0].month).toBe(new Date().getMonth());
expect(grouped[1].month).toBe(3);
});
});