From d61eb1a95166c214268a2eec52104a6de049161c Mon Sep 17 00:00:00 2001 From: Lucas Bordeau Date: Tue, 29 Jul 2025 11:52:24 +0200 Subject: [PATCH] Remove all legacy state management (#13476) This PR removes every legacy state management logic left in the code base, we only keep our last component state management logic. Removed : - Scoped states logic - Dropdown scope logic - Scope id naming - Component state v1 - Component state v2_alpha # QA | Component | Comments | | --- | --- | | AttachementDropdown | Ok | | ObjectTasks | Ok | | ActivityRichTextEditor | Ok | | App | Ok dialogs work | | AppRouterProviders | Ok dialogs work | | RecordBoardScrollToFocusedCardEffect | Ok | | RecordBoard | Ok | | RecordBoardCard | OK | | useSelectAllCards | Ok | | RecordInlineCell | Ok | | useInlineCell | Ok | | RecordDetailRelationRecordsListItem | Ok | | RecordDetailRelationSectionDropdownToMany | Ok | | RecordDetailRelationSectionDropdownToOne | Ok | | useHandleContainerMouseEnter | Ok | | useResetTableRowSelection | Ok | | useSelectAllRows | Ok | | useSetRecordTableData | Ok | | useRecordTable | Ok | | useRecordTableMoveFocusedCell | Ok | | useRecordTableMoveFocusedRow | Ok | | useMoveHoverToCurrentCell | OK | | useTriggerActionMenuDropdown | Ok | | RecordTableBodyDragDropContextProvider | Ok | | RecordTableHeaderCell | Ok | | useSetCurrentRowSelected | Ok | | useRecordTitleCell | Ok | | SettingsObjectFieldActiveActionDropdown | Ok | | SettingsObjectFieldInactiveActionDropdown | Ok | | SettingsObjectFieldItemTableRow | Ok | | SettingsObjectInactiveMenuDropDown | Ok | | SettingsRoleEditEffect | Ok | | SettingsRolesQueryEffect | Ok | | Dropdown | Ok | | useSelectableList | Ok | | useSelectableListHotKeys | Ok | | useSelectableListListenToEnterHotkeyOnItem | Ok | | useNavigationSection | Ok | | useCreateViewFromCurrentState | Ok | | useDeleteViewFromCurrentState | Ok | | useUpdateViewFromCurrentState | Ok | | ViewPickerFavoriteFoldersDropdown | Ok | | useCreateViewFromCurrentView | Ok | | ViewBarDetails | Ok | | WorkflowRunVisualizer | Ok | | useHandleWorkflowRunDiagramCanvasInit | Ok | | WorkflowDiagramCanvasBase | Ok | | WorkflowRunVisualizerEffect | Ok | | useRemoveStepFilter | Ok | | useRemoveStepFilterGroup | Ok | | useUpsertStepFilterSettings | Ok | | WorkflowFindRecordsFilters | Ok | | SettingsObjects | Ok | --- .../components/ActivityRichTextEditor.tsx | 6 +- .../files/components/AttachmentDropdown.tsx | 6 +- .../files/components/AttachmentRow.tsx | 2 +- .../useActivityTargetObjectRecords.test.tsx | 8 +- .../tasks/components/ObjectTasks.tsx | 2 +- .../__stories__/TaskGroups.stories.tsx | 6 +- .../tasks/hooks/__tests__/useTasks.test.tsx | 2 +- .../hooks/__tests__/useApolloFactory.test.tsx | 8 +- .../src/modules/app/components/App.tsx | 8 +- .../app/components/AppRouterProviders.tsx | 8 +- .../auth/hooks/__tests__/useAuth.test.tsx | 9 ++- .../hooks/useOpenRecordInCommandMenu.ts | 3 +- .../scopes/FavoriteFolderPickerScope.tsx | 20 ----- .../useFindManyObjectMetadataItems.test.tsx | 8 +- .../hooks/useUpsertRecordFromState.ts | 16 ---- .../ObjectOptionsDropdownContent.stories.tsx | 2 +- .../record-board/components/RecordBoard.tsx | 79 ++++++++----------- .../RecordBoardScrollToFocusedCardEffect.tsx | 8 -- .../record-board/hooks/useSelectAllCards.ts | 2 +- .../components/RecordBoardCard.tsx | 8 +- .../record-board/scopes/RecordBoardScope.tsx | 33 -------- .../RecordBoardScopeInternalContext.ts | 13 --- .../RelationFromManyFieldInput.stories.tsx | 5 +- .../RelationToOneFieldInput.stories.tsx | 7 +- .../components/RecordInlineCell.tsx | 4 +- .../record-inline-cell/hooks/useInlineCell.ts | 4 +- ...s => isInlineCellInEditModeFamilyState.ts} | 2 +- .../SingleRecordPicker.stories.tsx | 4 +- .../RecordDetailRelationRecordsListItem.tsx | 73 ++++++++--------- ...ordDetailRelationSectionDropdownToMany.tsx | 67 ++++++++-------- ...cordDetailRelationSectionDropdownToOne.tsx | 63 +++++++-------- .../internal/useHandleContainerMouseEnter.ts | 2 +- .../internal/useResetTableRowSelection.ts | 2 +- .../hooks/internal/useSelectAllRows.ts | 2 +- .../hooks/internal/useSetRecordTableData.ts | 2 +- .../record-table/hooks/useRecordTable.ts | 2 +- .../hooks/useRecordTableMoveFocusedCell.ts | 2 +- .../hooks/useRecordTableMoveFocusedRow.ts | 2 +- ...RecordTableBodyDragDropContextProvider.tsx | 2 +- .../useCloseRecordTableCellInGroup.test.tsx | 2 +- .../useCloseRecordTableCellNoGroup.test.tsx | 2 +- .../hooks/useMoveHoverToCurrentCell.ts | 2 +- .../hooks/useTriggerActionMenuDropdown.ts | 2 +- .../components/RecordTableHeaderCell.tsx | 2 +- .../hooks/useSetCurrentRowSelected.ts | 2 +- .../RecordTableComponentInstanceContext.ts | 1 - .../hooks/useRecordTitleCell.tsx | 6 +- .../useFilteredSearchRecordQuery.test.tsx | 8 +- ...ettingsObjectFieldActiveActionDropdown.tsx | 6 +- ...tingsObjectFieldDisabledActionDropdown.tsx | 6 +- .../SettingsObjectFieldItemTableRow.tsx | 4 +- .../SettingsObjectInactiveMenuDropDown.tsx | 6 +- ...ingsObjectInactiveMenuDropDown.stories.tsx | 4 +- .../useSettingsNavigationItems.test.tsx | 8 +- .../__stories__/GraphQLPlayground.stories.tsx | 6 +- .../PlaygroundSetupForm.stories.tsx | 10 +-- .../__stories__/RestPlayground.stories.tsx | 11 +-- .../components/SettingsRolesQueryEffect.tsx | 2 +- .../components/SettingsRoleEditEffect.tsx | 2 +- .../__stories__/MatchColumns.stories.tsx | 8 +- .../__stories__/SelectHeader.stories.tsx | 8 +- .../__stories__/SelectSheet.stories.tsx | 8 +- .../components/__stories__/Steps.stories.tsx | 2 - .../components/__stories__/Upload.stories.tsx | 8 +- .../__stories__/Validation.stories.tsx | 8 +- .../src/modules/types/RecoilScopeContext.ts | 3 - .../DialogManagerHotkeyScopeMemoizeKey.ts | 1 - .../hooks/__tests__/useDialogManager.test.tsx | 9 ++- .../scopes/DialogManagerScope.tsx | 21 ----- ...ackBarComponentInstanceContextProvider.tsx | 21 ----- .../layout/dropdown/components/Dropdown.tsx | 71 ++++++++--------- .../layout/dropdown/scopes/DropdownScope.tsx | 19 ----- .../DropdownScopeInternalContext.ts | 7 -- .../hooks/__tests__/useSelectableList.test.ts | 16 ++-- .../internal/useSelectableListHotKeys.ts | 2 +- .../hooks/useSelectableList.ts | 2 +- ...SelectableListListenToEnterHotkeyOnItem.ts | 2 +- .../layout/tab-list/scopes/TabListScope.tsx | 19 ----- .../TabListScopeInternalContext.ts | 7 -- .../hooks/useNavigationSection.ts | 16 ++-- .../recoil-scope/components/RecoilScope.tsx | 33 -------- .../__tests__/useContextScopeId.test.tsx | 43 ---------- .../hooks/__tests__/useRecoilScopeId.test.tsx | 43 ---------- .../recoil-scope/hooks/useContextScopeId.ts | 16 ---- .../recoil-scope/hooks/useRecoilScopeId.ts | 17 ---- .../hooks/useRecoilScopedStateV2.ts | 14 ---- .../__tests__/useAvailableScopeId.test.tsx | 64 --------------- .../useScopeInternalContext.test.tsx | 32 -------- .../hooks/useAvailableScopeId.ts | 26 ------ .../hooks/useScopeInternalContext.ts | 11 --- .../types/ScopeInternalContext.ts | 4 - .../utils/createScopeInternalContext.ts | 13 --- .../recoil-scope/states/RecoilScopeContext.ts | 3 - .../types/RecoilScopedSelector.ts | 7 -- .../recoil-scope/types/RecoilScopedState.ts | 7 -- .../utils/getScopedStateDeprecated.ts | 10 --- .../recoil-scope/utils/getSnapshotValue.ts | 8 -- .../utils/guardRecoilDefaultValue.ts | 8 -- .../useExtractedComponentFamilyStateV2.ts | 34 -------- .../hooks/useRecoilComponentFamilyValue.ts | 35 -------- .../hooks/useRecoilComponentState.ts | 27 ------- .../hooks/useRecoilComponentValue.ts | 28 ------- .../hooks/useScopeIdFromStateContext.ts | 23 ------ .../hooks/useSetRecoilComponentState.ts | 28 ------- .../types/ComponentFamilyState.ts | 13 --- .../types/ComponentFamilyStateKey.ts | 6 -- .../types/RecoilComponentState.ts | 9 --- .../types/RecoilComponentStateKey.ts | 3 - .../utils/createComponentFamilySelector.ts | 24 ------ .../utils/createComponentFamilyState.ts | 19 ----- .../utils/createComponentReadOnlySelector.ts | 17 ---- .../utils/createComponentSelector.ts | 21 ----- .../utils/createComponentState.ts | 21 ----- .../utils/createComponentStateV2Alpha.ts | 38 --------- .../utils/createEventContext.ts | 9 --- .../utils/extractComponentFamilyState.ts | 19 ----- .../utils/extractComponentReadOnlySelector.ts | 12 --- .../utils/extractComponentSelector.ts | 12 --- .../utils/extractComponentState.ts | 12 --- .../state/utils/guardRecoilDefaultValue.ts | 8 -- .../views/components/ViewBarDetails.tsx | 5 +- .../hooks/useCreateViewFromCurrentView.ts | 2 +- .../ViewPickerFavoriteFoldersDropdown.tsx | 25 +++--- .../hooks/useCreateViewFromCurrentState.ts | 2 +- .../hooks/useDeleteViewFromCurrentState.ts | 2 +- .../hooks/useUpdateViewFromCurrentState.ts | 2 +- .../components/WorkflowDiagramCanvasBase.tsx | 2 +- .../WorkflowRunVisualizerEffect.tsx | 2 +- .../useHandleWorkflowRunDiagramCanvasInit.ts | 2 +- .../hooks/useRemoveStepFilter.ts | 2 +- .../hooks/useRemoveStepFilterGroup.ts | 2 +- .../hooks/useUpsertStepFilterSettings.ts | 2 +- .../components/WorkflowFindRecordsFilters.tsx | 2 +- .../settings/data-model/SettingsObjects.tsx | 2 +- .../ComponentWithRecoilScopeDecorator.tsx | 14 ---- .../src/testing/decorators/PageDecorator.tsx | 9 ++- .../testing/decorators/SnackBarDecorator.tsx | 9 ++- .../getJestMetadataAndApolloMocksWrapper.tsx | 9 ++- .../src/types/ScopeContextProps.ts | 3 - .../src/content/twenty-ui/input/select.mdx | 2 - 140 files changed, 362 insertions(+), 1367 deletions(-) delete mode 100644 packages/twenty-front/src/modules/favorites/favorite-folder-picker/scopes/FavoriteFolderPickerScope.tsx delete mode 100644 packages/twenty-front/src/modules/object-record/hooks/useUpsertRecordFromState.ts delete mode 100644 packages/twenty-front/src/modules/object-record/record-board/scopes/RecordBoardScope.tsx delete mode 100644 packages/twenty-front/src/modules/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext.ts rename packages/twenty-front/src/modules/object-record/record-inline-cell/states/{isInlineCellInEditModeScopedState.ts => isInlineCellInEditModeFamilyState.ts} (73%) delete mode 100644 packages/twenty-front/src/modules/types/RecoilScopeContext.ts delete mode 100644 packages/twenty-front/src/modules/ui/feedback/dialog-manager/constants/DialogManagerHotkeyScopeMemoizeKey.ts delete mode 100644 packages/twenty-front/src/modules/ui/feedback/dialog-manager/scopes/DialogManagerScope.tsx delete mode 100644 packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider.tsx delete mode 100644 packages/twenty-front/src/modules/ui/layout/dropdown/scopes/DropdownScope.tsx delete mode 100644 packages/twenty-front/src/modules/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext.ts delete mode 100644 packages/twenty-front/src/modules/ui/layout/tab-list/scopes/TabListScope.tsx delete mode 100644 packages/twenty-front/src/modules/ui/layout/tab-list/scopes/scope-internal-context/TabListScopeInternalContext.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/components/RecoilScope.tsx delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useContextScopeId.test.tsx delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopeId.test.tsx delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useContextScopeId.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopeId.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedStateV2.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useAvailableScopeId.test.tsx delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopeInternalContext.test.tsx delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContext.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopeInternalContext.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/states/RecoilScopeContext.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedSelector.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedState.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopedStateDeprecated.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSnapshotValue.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/guardRecoilDefaultValue.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useExtractedComponentFamilyStateV2.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyValue.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentState.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentValue.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useScopeIdFromStateContext.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useSetRecoilComponentState.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyState.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyStateKey.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/types/RecoilComponentState.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/types/RecoilComponentStateKey.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilySelector.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilyState.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentReadOnlySelector.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentSelector.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentState.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentStateV2Alpha.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createEventContext.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentFamilyState.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentSelector.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentState.ts delete mode 100644 packages/twenty-front/src/modules/ui/utilities/state/utils/guardRecoilDefaultValue.ts delete mode 100644 packages/twenty-front/src/testing/decorators/ComponentWithRecoilScopeDecorator.tsx delete mode 100644 packages/twenty-front/src/types/ScopeContextProps.ts diff --git a/packages/twenty-front/src/modules/activities/components/ActivityRichTextEditor.tsx b/packages/twenty-front/src/modules/activities/components/ActivityRichTextEditor.tsx index 118f716164..14b83bb683 100644 --- a/packages/twenty-front/src/modules/activities/components/ActivityRichTextEditor.tsx +++ b/packages/twenty-front/src/modules/activities/components/ActivityRichTextEditor.tsx @@ -30,7 +30,7 @@ import { useLazyFetchAllRecords } from '@/object-record/hooks/useLazyFetchAllRec import { useRestoreManyRecords } from '@/object-record/hooks/useRestoreManyRecords'; import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord'; import { useIsRecordReadOnly } from '@/object-record/record-field/hooks/useIsRecordReadOnly'; -import { isInlineCellInEditModeScopedState } from '@/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState'; +import { isInlineCellInEditModeFamilyState } from '@/object-record/record-inline-cell/states/isInlineCellInEditModeFamilyState'; import { useRecordShowContainerData } from '@/object-record/record-show/hooks/useRecordShowContainerData'; import { getRecordFieldInputInstanceId } from '@/object-record/utils/getRecordFieldInputId'; import { BlockEditor } from '@/ui/input/editor/components/BlockEditor'; @@ -379,7 +379,7 @@ export const ActivityRichTextEditor = ({ ({ snapshot }) => () => { const isRecordTitleCellOpen = snapshot - .getLoadable(isInlineCellInEditModeScopedState(recordTitleCellId)) + .getLoadable(isInlineCellInEditModeFamilyState(recordTitleCellId)) .getValue(); if (isRecordTitleCellOpen) { @@ -405,7 +405,7 @@ export const ActivityRichTextEditor = ({ ({ snapshot }) => () => { const isRecordTitleCellOpen = snapshot - .getLoadable(isInlineCellInEditModeScopedState(recordTitleCellId)) + .getLoadable(isInlineCellInEditModeFamilyState(recordTitleCellId)) .getValue(); if (isRecordTitleCellOpen) { diff --git a/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx b/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx index ab03f51e41..bba8ad4fd6 100644 --- a/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx +++ b/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx @@ -16,16 +16,16 @@ type AttachmentDropdownProps = { onDownload: () => void; onDelete: () => void; onRename: () => void; - scopeKey: string; + attachmentId: string; }; export const AttachmentDropdown = ({ onDownload, onDelete, onRename, - scopeKey, + attachmentId, }: AttachmentDropdownProps) => { - const dropdownId = `${scopeKey}-settings-field-active-action-dropdown`; + const dropdownId = `${attachmentId}-attachment-dropdown`; const { closeDropdown } = useCloseDropdown(); diff --git a/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx b/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx index 88029e0226..2903b87e7c 100644 --- a/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx +++ b/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx @@ -199,7 +199,7 @@ export const AttachmentRow = ({ {formatToHumanReadableDate(attachment.createdAt)} ( - + {children} - + diff --git a/packages/twenty-front/src/modules/activities/tasks/components/ObjectTasks.tsx b/packages/twenty-front/src/modules/activities/tasks/components/ObjectTasks.tsx index 755ef059bf..b4d6285187 100644 --- a/packages/twenty-front/src/modules/activities/tasks/components/ObjectTasks.tsx +++ b/packages/twenty-front/src/modules/activities/tasks/components/ObjectTasks.tsx @@ -20,7 +20,7 @@ export const ObjectTasks = ({ targetableObject }: ObjectTasksProps) => { return ( diff --git a/packages/twenty-front/src/modules/activities/tasks/components/__stories__/TaskGroups.stories.tsx b/packages/twenty-front/src/modules/activities/tasks/components/__stories__/TaskGroups.stories.tsx index d3cbba718e..459e98e460 100644 --- a/packages/twenty-front/src/modules/activities/tasks/components/__stories__/TaskGroups.stories.tsx +++ b/packages/twenty-front/src/modules/activities/tasks/components/__stories__/TaskGroups.stories.tsx @@ -4,7 +4,6 @@ import { TaskGroups } from '@/activities/tasks/components/TaskGroups'; import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity'; import { ObjectFilterDropdownComponentInstanceContext } from '@/object-record/object-filter-dropdown/states/contexts/ObjectFilterDropdownComponentInstanceContext'; import { TabListComponentInstanceContext } from '@/ui/layout/tab-list/states/contexts/TabListComponentInstanceContext'; -import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator'; import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator'; import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator'; @@ -18,17 +17,16 @@ const meta: Meta = { decorators: [ (Story) => ( ), ComponentWithRouterDecorator, - ComponentWithRecoilScopeDecorator, ObjectMetadataItemsDecorator, SnackBarDecorator, I18nFrontDecorator, diff --git a/packages/twenty-front/src/modules/activities/tasks/hooks/__tests__/useTasks.test.tsx b/packages/twenty-front/src/modules/activities/tasks/hooks/__tests__/useTasks.test.tsx index a01f814cfc..1de8c792c1 100644 --- a/packages/twenty-front/src/modules/activities/tasks/hooks/__tests__/useTasks.test.tsx +++ b/packages/twenty-front/src/modules/activities/tasks/hooks/__tests__/useTasks.test.tsx @@ -47,7 +47,7 @@ jest.mock('@/activities/hooks/useActivities', () => ({ const Wrapper = ({ children }: { children: ReactNode }) => ( {children} diff --git a/packages/twenty-front/src/modules/apollo/hooks/__tests__/useApolloFactory.test.tsx b/packages/twenty-front/src/modules/apollo/hooks/__tests__/useApolloFactory.test.tsx index d5a4c2b20f..067c7cc401 100644 --- a/packages/twenty-front/src/modules/apollo/hooks/__tests__/useApolloFactory.test.tsx +++ b/packages/twenty-front/src/modules/apollo/hooks/__tests__/useApolloFactory.test.tsx @@ -4,7 +4,7 @@ import fetchMock, { enableFetchMocks } from 'jest-fetch-mock'; import { MemoryRouter, useLocation } from 'react-router-dom'; import { RecoilRoot } from 'recoil'; -import { SnackBarComponentInstanceContextProvider } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider'; +import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; import { useApolloFactory } from '../useApolloFactory'; enableFetchMocks(); @@ -26,9 +26,11 @@ const Wrapper = ({ children }: { children: React.ReactNode }) => ( initialEntries={['/welcome', '/verify', '/opportunities']} initialIndex={2} > - + {children} - + ); diff --git a/packages/twenty-front/src/modules/app/components/App.tsx b/packages/twenty-front/src/modules/app/components/App.tsx index cfccd1fa5a..2974724317 100644 --- a/packages/twenty-front/src/modules/app/components/App.tsx +++ b/packages/twenty-front/src/modules/app/components/App.tsx @@ -4,7 +4,7 @@ import { RecoilDebugObserverEffect } from '@/debug/components/RecoilDebugObserve import { AppErrorBoundary } from '@/error-handler/components/AppErrorBoundary'; import { AppRootErrorFallback } from '@/error-handler/components/AppRootErrorFallback'; import { ExceptionHandlerProvider } from '@/error-handler/components/ExceptionHandlerProvider'; -import { SnackBarComponentInstanceContextProvider } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider'; +import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; import { ClickOutsideListenerContext } from '@/ui/utilities/pointer-event/contexts/ClickOutsideListenerContext'; import { i18n } from '@lingui/core'; import { I18nProvider } from '@lingui/react'; @@ -25,7 +25,9 @@ export const App = () => { - + @@ -37,7 +39,7 @@ export const App = () => { - + diff --git a/packages/twenty-front/src/modules/app/components/AppRouterProviders.tsx b/packages/twenty-front/src/modules/app/components/AppRouterProviders.tsx index c7d7015b47..dd08e368af 100644 --- a/packages/twenty-front/src/modules/app/components/AppRouterProviders.tsx +++ b/packages/twenty-front/src/modules/app/components/AppRouterProviders.tsx @@ -15,7 +15,7 @@ import { ObjectMetadataItemsLoadEffect } from '@/object-metadata/components/Obje import { ObjectMetadataItemsProvider } from '@/object-metadata/components/ObjectMetadataItemsProvider'; import { PrefetchDataProvider } from '@/prefetch/components/PrefetchDataProvider'; import { DialogManager } from '@/ui/feedback/dialog-manager/components/DialogManager'; -import { DialogManagerScope } from '@/ui/feedback/dialog-manager/scopes/DialogManagerScope'; +import { DialogComponentInstanceContext } from '@/ui/feedback/dialog-manager/contexts/DialogComponentInstanceContext'; import { SnackBarProvider } from '@/ui/feedback/snack-bar-manager/components/SnackBarProvider'; import { BaseThemeProvider } from '@/ui/theme/components/BaseThemeProvider'; import { UserThemeProviderEffect } from '@/ui/theme/components/UserThemeProviderEffect'; @@ -51,7 +51,9 @@ export const AppRouterProviders = () => { - + @@ -61,7 +63,7 @@ export const AppRouterProviders = () => { - + diff --git a/packages/twenty-front/src/modules/auth/hooks/__tests__/useAuth.test.tsx b/packages/twenty-front/src/modules/auth/hooks/__tests__/useAuth.test.tsx index e50db75b1f..d37d1e0c5d 100644 --- a/packages/twenty-front/src/modules/auth/hooks/__tests__/useAuth.test.tsx +++ b/packages/twenty-front/src/modules/auth/hooks/__tests__/useAuth.test.tsx @@ -2,7 +2,7 @@ import { useAuth } from '@/auth/hooks/useAuth'; import { billingState } from '@/client-config/states/billingState'; import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState'; import { supportChatState } from '@/client-config/states/supportChatState'; -import { SnackBarComponentInstanceContextProvider } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider'; + import { workspaceAuthProvidersState } from '@/workspace/states/workspaceAuthProvidersState'; import { useApolloClient } from '@apollo/client'; import { MockedProvider } from '@apollo/client/testing'; @@ -12,6 +12,7 @@ import { MemoryRouter } from 'react-router-dom'; import { RecoilRoot, useRecoilValue } from 'recoil'; import { isMultiWorkspaceEnabledState } from '@/client-config/states/isMultiWorkspaceEnabledState'; +import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; import { renderHook } from '@testing-library/react'; import { iconsState } from 'twenty-ui/display'; import { SupportDriver } from '~/generated/graphql'; @@ -71,9 +72,11 @@ const Wrapper = ({ children }: { children: ReactNode }) => ( - + {children} - + diff --git a/packages/twenty-front/src/modules/command-menu/hooks/useOpenRecordInCommandMenu.ts b/packages/twenty-front/src/modules/command-menu/hooks/useOpenRecordInCommandMenu.ts index cf5829e36c..d81058d8d6 100644 --- a/packages/twenty-front/src/modules/command-menu/hooks/useOpenRecordInCommandMenu.ts +++ b/packages/twenty-front/src/modules/command-menu/hooks/useOpenRecordInCommandMenu.ts @@ -15,7 +15,8 @@ import { objectMetadataItemFamilySelector } from '@/object-metadata/states/objec import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; import { getIconColorForObjectType } from '@/object-metadata/utils/getIconColorForObjectType'; import { viewableRecordIdState } from '@/object-record/record-right-drawer/states/viewableRecordIdState'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; + import { useRunWorkflowRunOpeningInCommandMenuSideEffects } from '@/workflow/hooks/useRunWorkflowRunOpeningInCommandMenuSideEffects'; import { useTheme } from '@emotion/react'; import { t } from '@lingui/core/macro'; diff --git a/packages/twenty-front/src/modules/favorites/favorite-folder-picker/scopes/FavoriteFolderPickerScope.tsx b/packages/twenty-front/src/modules/favorites/favorite-folder-picker/scopes/FavoriteFolderPickerScope.tsx deleted file mode 100644 index 107c19beef..0000000000 --- a/packages/twenty-front/src/modules/favorites/favorite-folder-picker/scopes/FavoriteFolderPickerScope.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { FavoriteFolderPickerInstanceContext } from '@/favorites/favorite-folder-picker/states/context/FavoriteFolderPickerInstanceContext'; -import { ReactNode } from 'react'; - -type FavoriteFolderPickerComponentInstanceContextProps = { - children: ReactNode; - favoriteFoldersScopeId: string; -}; - -export const FavoriteFolderPickerComponentInstanceContext = ({ - children, - favoriteFoldersScopeId, -}: FavoriteFolderPickerComponentInstanceContextProps) => { - return ( - - {children} - - ); -}; diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFindManyObjectMetadataItems.test.tsx b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFindManyObjectMetadataItems.test.tsx index e9ece32074..68a08ade87 100644 --- a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFindManyObjectMetadataItems.test.tsx +++ b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFindManyObjectMetadataItems.test.tsx @@ -4,8 +4,8 @@ import { ReactNode } from 'react'; import { RecoilRoot } from 'recoil'; import { useFindManyObjectMetadataItems } from '@/object-metadata/hooks/useFindManyObjectMetadataItems'; -import { SnackBarComponentInstanceContextProvider } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider'; +import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; import { query, responseData, @@ -27,9 +27,11 @@ const mocks = [ const Wrapper = ({ children }: { children: ReactNode }) => ( - + {children} - + ); diff --git a/packages/twenty-front/src/modules/object-record/hooks/useUpsertRecordFromState.ts b/packages/twenty-front/src/modules/object-record/hooks/useUpsertRecordFromState.ts deleted file mode 100644 index 8251c8c780..0000000000 --- a/packages/twenty-front/src/modules/object-record/hooks/useUpsertRecordFromState.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { useRecoilCallback } from 'recoil'; - -import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; -import { ObjectRecord } from '@/object-record/types/ObjectRecord'; -import { isDeeplyEqual } from '~/utils/isDeeplyEqual'; - -// TODO: refactor with scoped state later -export const useUpsertRecordFromState = () => - useRecoilCallback( - ({ set }) => - (record: T) => - set(recordStoreFamilyState(record.id), (previousRecord) => - isDeeplyEqual(previousRecord, record) ? previousRecord : record, - ), - [], - ); diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/__stories__/ObjectOptionsDropdownContent.stories.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/__stories__/ObjectOptionsDropdownContent.stories.tsx index f7479c89e3..70877027a0 100644 --- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/__stories__/ObjectOptionsDropdownContent.stories.tsx +++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/__stories__/ObjectOptionsDropdownContent.stories.tsx @@ -24,7 +24,7 @@ import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadat import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems'; -const instanceId = 'entity-options-scope'; +const instanceId = 'entity-options-instance'; const meta: Meta = { title: diff --git a/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx b/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx index 4187c46e88..04231f96a8 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx @@ -16,7 +16,6 @@ import { useRecordBoardSelection } from '@/object-record/record-board/hooks/useR import { RecordBoardDeactivateBoardCardEffect } from '@/object-record/record-board/record-board-card/components/RecordBoardDeactivateBoardCardEffect'; import { RECORD_BOARD_CARD_CLICK_OUTSIDE_ID } from '@/object-record/record-board/record-board-card/constants/RecordBoardCardClickOutsideId'; import { RecordBoardColumn } from '@/object-record/record-board/record-board-column/components/RecordBoardColumn'; -import { RecordBoardScope } from '@/object-record/record-board/scopes/RecordBoardScope'; import { RecordBoardComponentInstanceContext } from '@/object-record/record-board/states/contexts/RecordBoardComponentInstanceContext'; import { getDraggedRecordPosition } from '@/object-record/record-board/utils/getDraggedRecordPosition'; import { recordGroupDefinitionFamilyState } from '@/object-record/record-group/states/recordGroupDefinitionFamilyState'; @@ -209,51 +208,43 @@ export const RecordBoard = () => { // } return ( - {}} - onFieldsChange={() => {}} + - - - - - - - - - - - - {visibleRecordGroupIds.map((recordGroupId, index) => ( - - ))} - - + + + + + + + + + + {visibleRecordGroupIds.map((recordGroupId, index) => ( + + ))} + + - - - - - - - + + + + + + ); }; diff --git a/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoardScrollToFocusedCardEffect.tsx b/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoardScrollToFocusedCardEffect.tsx index 1d6cdbf1dc..2eee76facc 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoardScrollToFocusedCardEffect.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoardScrollToFocusedCardEffect.tsx @@ -1,24 +1,16 @@ import { useEffect } from 'react'; -import { RecordBoardScopeInternalContext } from '@/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext'; import { focusedRecordBoardCardIndexesComponentState } from '@/object-record/record-board/states/focusedRecordBoardCardIndexesComponentState'; import { isRecordBoardCardFocusActiveComponentState } from '@/object-record/record-board/states/isRecordBoardCardFocusActiveComponentState'; -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; export const RecordBoardScrollToFocusedCardEffect = () => { - const recordBoardId = useAvailableScopeIdOrThrow( - RecordBoardScopeInternalContext, - ); - const focusedCardIndexes = useRecoilComponentValueV2( focusedRecordBoardCardIndexesComponentState, - recordBoardId, ); const isFocusActive = useRecoilComponentValueV2( isRecordBoardCardFocusActiveComponentState, - recordBoardId, ); useEffect(() => { diff --git a/packages/twenty-front/src/modules/object-record/record-board/hooks/useSelectAllCards.ts b/packages/twenty-front/src/modules/object-record/record-board/hooks/useSelectAllCards.ts index 7e7c380a22..03cebc8794 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/hooks/useSelectAllCards.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/hooks/useSelectAllCards.ts @@ -4,8 +4,8 @@ import { useRecordBoardSelection } from '@/object-record/record-board/hooks/useR import { isRecordBoardCardSelectedComponentFamilyState } from '@/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState'; import { allCardsSelectedStatusComponentSelector } from '@/object-record/record-board/states/selectors/allCardsSelectedStatusComponentSelector'; import { recordIndexAllRecordIdsComponentSelector } from '@/object-record/record-index/states/selectors/recordIndexAllRecordIdsComponentSelector'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; export const useSelectAllCards = (recordBoardId?: string) => { const allCardsSelectedStatusSelector = useRecoilComponentCallbackStateV2( diff --git a/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCard.tsx b/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCard.tsx index 28ca824fbc..922b167501 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCard.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCard.tsx @@ -2,7 +2,6 @@ import { recordIndexActionMenuDropdownPositionComponentState } from '@/action-me import { getActionMenuDropdownIdFromActionMenuId } from '@/action-menu/utils/getActionMenuDropdownIdFromActionMenuId'; import { getActionMenuIdFromRecordIndexId } from '@/action-menu/utils/getActionMenuIdFromRecordIndexId'; import { RecordBoardCardContext } from '@/object-record/record-board/record-board-card/contexts/RecordBoardCardContext'; -import { RecordBoardScopeInternalContext } from '@/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext'; import { isRecordBoardCardActiveComponentFamilyState } from '@/object-record/record-board/states/isRecordBoardCardActiveComponentFamilyState'; import { isRecordBoardCardFocusedComponentFamilyState } from '@/object-record/record-board/states/isRecordBoardCardFocusedComponentFamilyState'; import { isRecordBoardCardSelectedComponentFamilyState } from '@/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState'; @@ -14,10 +13,11 @@ import { useFocusedRecordBoardCard } from '@/object-record/record-board/hooks/us import { RecordBoardCardBody } from '@/object-record/record-board/record-board-card/components/RecordBoardCardBody'; import { RecordBoardCardHeader } from '@/object-record/record-board/record-board-card/components/RecordBoardCardHeader'; import { RECORD_BOARD_CARD_CLICK_OUTSIDE_ID } from '@/object-record/record-board/record-board-card/constants/RecordBoardCardClickOutsideId'; +import { RecordBoardComponentInstanceContext } from '@/object-record/record-board/states/contexts/RecordBoardComponentInstanceContext'; import { useOpenRecordFromIndexView } from '@/object-record/record-index/hooks/useOpenRecordFromIndexView'; import { useOpenDropdown } from '@/ui/layout/dropdown/hooks/useOpenDropdown'; -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; import { useScrollWrapperElement } from '@/ui/utilities/scroll/hooks/useScrollWrapperElement'; +import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow'; import { useRecoilComponentFamilyStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyStateV2'; import { useRecoilComponentFamilyValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyValueV2'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; @@ -122,8 +122,8 @@ export const RecordBoardCard = () => { }, ); - const recordBoardId = useAvailableScopeIdOrThrow( - RecordBoardScopeInternalContext, + const recordBoardId = useAvailableComponentInstanceIdOrThrow( + RecordBoardComponentInstanceContext, ); const actionMenuId = getActionMenuIdFromRecordIndexId(recordBoardId); diff --git a/packages/twenty-front/src/modules/object-record/record-board/scopes/RecordBoardScope.tsx b/packages/twenty-front/src/modules/object-record/record-board/scopes/RecordBoardScope.tsx deleted file mode 100644 index 2f61769ed1..0000000000 --- a/packages/twenty-front/src/modules/object-record/record-board/scopes/RecordBoardScope.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { ReactNode } from 'react'; - -import { RecordBoardScopeInternalContext } from '@/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext'; -import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition'; -import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata'; -import { RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition'; - -type RecordBoardScopeProps = { - children: ReactNode; - recordBoardScopeId: string; - onFieldsChange: (fields: FieldDefinition[]) => void; - onColumnsChange: (column: RecordGroupDefinition[]) => void; -}; - -/** @deprecated */ -export const RecordBoardScope = ({ - children, - recordBoardScopeId, - onColumnsChange, - onFieldsChange, -}: RecordBoardScopeProps) => { - return ( - - {children} - - ); -}; diff --git a/packages/twenty-front/src/modules/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext.ts b/packages/twenty-front/src/modules/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext.ts deleted file mode 100644 index 330ff18aba..0000000000 --- a/packages/twenty-front/src/modules/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition'; -import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata'; -import { RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition'; -import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -type RecordBoardScopeInternalContextProps = RecoilComponentStateKey & { - onFieldsChange: (fields: FieldDefinition[]) => void; - onColumnsChange: (column: RecordGroupDefinition[]) => void; -}; - -export const RecordBoardScopeInternalContext = - createScopeInternalContext(); diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationFromManyFieldInput.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationFromManyFieldInput.stories.tsx index 887ba57222..2276d0acb2 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationFromManyFieldInput.stories.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationFromManyFieldInput.stories.tsx @@ -6,7 +6,6 @@ import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMembe import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState'; import { RelationFromManyFieldInput } from '@/object-record/record-field/meta-types/input/components/RelationFromManyFieldInput'; import { usePushFocusItemToFocusStack } from '@/ui/utilities/focus/hooks/usePushFocusItemToFocusStack'; -import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator'; import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator'; import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; import { graphqlMocks } from '~/testing/graphqlMocks'; @@ -127,6 +126,4 @@ export default meta; type Story = StoryObj; -export const Default: Story = { - decorators: [ComponentWithRecoilScopeDecorator], -}; +export const Default: Story = {}; diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationToOneFieldInput.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationToOneFieldInput.stories.tsx index 65eac31320..f0a98f3855 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationToOneFieldInput.stories.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationToOneFieldInput.stories.tsx @@ -5,7 +5,6 @@ import { useSetRecoilState } from 'recoil'; import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState'; import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState'; -import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator'; import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator'; import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; import { graphqlMocks } from '~/testing/graphqlMocks'; @@ -150,12 +149,9 @@ export default meta; type Story = StoryObj; -export const Default: Story = { - decorators: [ComponentWithRecoilScopeDecorator], -}; +export const Default: Story = {}; export const Submit: Story = { - decorators: [ComponentWithRecoilScopeDecorator], play: async () => { const canvas = within(getCanvasElementForDropdownTesting()); @@ -174,7 +170,6 @@ export const Submit: Story = { }; export const Cancel: Story = { - decorators: [ComponentWithRecoilScopeDecorator], play: async () => { const canvas = within(getCanvasElementForDropdownTesting()); diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCell.tsx b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCell.tsx index d8ac5328aa..96210b576a 100644 --- a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCell.tsx +++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCell.tsx @@ -14,7 +14,7 @@ import { useIsFieldInputOnly } from '@/object-record/record-field/hooks/useIsFie import { useOpenFieldInputEditMode } from '@/object-record/record-field/hooks/useOpenFieldInputEditMode'; import { RecordFieldComponentInstanceContext } from '@/object-record/record-field/states/contexts/RecordFieldComponentInstanceContext'; -import { isInlineCellInEditModeScopedState } from '@/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState'; +import { isInlineCellInEditModeFamilyState } from '@/object-record/record-inline-cell/states/isInlineCellInEditModeFamilyState'; import { getDropdownFocusIdForRecordField } from '@/object-record/utils/getDropdownFocusIdForRecordField'; import { useGoBackToPreviousDropdownFocusId } from '@/ui/layout/dropdown/hooks/useGoBackToPreviousDropdownFocusId'; import { activeDropdownFocusIdState } from '@/ui/layout/dropdown/states/activeDropdownFocusIdState'; @@ -85,7 +85,7 @@ export const RecordInlineCell = ({ ); const setIsInlineCellInEditMode = useSetRecoilState( - isInlineCellInEditModeScopedState(recordFieldComponentInstanceId), + isInlineCellInEditModeFamilyState(recordFieldComponentInstanceId), ); const closeInlineCell = useCallback(() => { diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/hooks/useInlineCell.ts b/packages/twenty-front/src/modules/object-record/record-inline-cell/hooks/useInlineCell.ts index 6ced599386..ed9ce06039 100644 --- a/packages/twenty-front/src/modules/object-record/record-inline-cell/hooks/useInlineCell.ts +++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/hooks/useInlineCell.ts @@ -10,7 +10,7 @@ import { getDropdownFocusIdForRecordField } from '@/object-record/utils/getDropd import { useGoBackToPreviousDropdownFocusId } from '@/ui/layout/dropdown/hooks/useGoBackToPreviousDropdownFocusId'; import { useSetActiveDropdownFocusIdAndMemorizePrevious } from '@/ui/layout/dropdown/hooks/useSetFocusedDropdownIdAndMemorizePrevious'; import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow'; -import { isInlineCellInEditModeScopedState } from '../states/isInlineCellInEditModeScopedState'; +import { isInlineCellInEditModeFamilyState } from '../states/isInlineCellInEditModeFamilyState'; export const useInlineCell = ( recordFieldComponentInstanceIdFromProps?: string, @@ -23,7 +23,7 @@ export const useInlineCell = ( ); const [isInlineCellInEditMode, setIsInlineCellInEditMode] = useRecoilState( - isInlineCellInEditModeScopedState(recordFieldComponentInstanceId), + isInlineCellInEditModeFamilyState(recordFieldComponentInstanceId), ); const { onOpenEditMode, onCloseEditMode } = useRecordInlineCellContext(); diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState.ts b/packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeFamilyState.ts similarity index 73% rename from packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState.ts rename to packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeFamilyState.ts index 9142d9400e..d605eda213 100644 --- a/packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeFamilyState.ts @@ -1,6 +1,6 @@ import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState'; -export const isInlineCellInEditModeScopedState = createFamilyState< +export const isInlineCellInEditModeFamilyState = createFamilyState< boolean, string >({ diff --git a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/__stories__/SingleRecordPicker.stories.tsx b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/__stories__/SingleRecordPicker.stories.tsx index 99b843f1bd..37e3755852 100644 --- a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/__stories__/SingleRecordPicker.stories.tsx +++ b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/__stories__/SingleRecordPicker.stories.tsx @@ -2,7 +2,6 @@ import { Meta, StoryObj } from '@storybook/react'; import { expect, userEvent, within } from '@storybook/test'; import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; -import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator'; import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator'; import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; import { graphqlMocks } from '~/testing/graphqlMocks'; @@ -11,8 +10,8 @@ import { sleep } from '~/utils/sleep'; import { SingleRecordPicker } from '@/object-record/record-picker/single-record-picker/components/SingleRecordPicker'; import { SingleRecordPickerRecord } from '@/object-record/record-picker/single-record-picker/types/SingleRecordPickerRecord'; -import { ComponentDecorator } from 'twenty-ui/testing'; import { IconUserCircle } from 'twenty-ui/display'; +import { ComponentDecorator } from 'twenty-ui/testing'; const records = allMockPersonRecords.map( (person) => ({ @@ -29,7 +28,6 @@ const meta: Meta = { component: SingleRecordPicker, decorators: [ ComponentDecorator, - ComponentWithRecoilScopeDecorator, ObjectMetadataItemsDecorator, SnackBarDecorator, ], diff --git a/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationRecordsListItem.tsx b/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationRecordsListItem.tsx index 5a13bd5888..2381b2f381 100644 --- a/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationRecordsListItem.tsx +++ b/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationRecordsListItem.tsx @@ -35,7 +35,6 @@ import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent'; import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState'; import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal'; import { useModal } from '@/ui/layout/modal/hooks/useModal'; @@ -159,12 +158,12 @@ export const RecordDetailRelationRecordsListItem = ({ ) .sort(); - const dropdownScopeId = `record-field-card-menu-${relationFieldMetadataId}-${relationRecord.id}`; + const dropdownInstanceId = `record-field-card-menu-${relationFieldMetadataId}-${relationRecord.id}`; const { closeDropdown } = useCloseDropdown(); const isDropdownOpen = useRecoilComponentValueV2( isDropdownOpenComponentState, - dropdownScopeId, + dropdownInstanceId, ); const dropdownId = getRecordFieldCardRelationPickerDropdownId({ @@ -177,7 +176,7 @@ export const RecordDetailRelationRecordsListItem = ({ ); const handleDetach = () => { - closeDropdown(dropdownScopeId); + closeDropdown(dropdownInstanceId); const relationFieldMetadataItem = relationObjectMetadataItem.fields.find( ({ id }) => id === relationFieldMetadataId, @@ -202,7 +201,7 @@ export const RecordDetailRelationRecordsListItem = ({ }; const handleDelete = async () => { - closeDropdown(dropdownScopeId); + closeDropdown(dropdownInstanceId); openModal(getDeleteRelationModalId(relationRecord.id)); }; @@ -262,39 +261,37 @@ export const RecordDetailRelationRecordsListItem = ({ /> {!isFieldReadOnly && ( - - - } - dropdownComponents={ - - - - {!isAccountOwnerRelation && - relationObjectPermissions.canSoftDeleteObjectRecords && ( - - )} - - - } - /> - + + } + dropdownComponents={ + + + + {!isAccountOwnerRelation && + relationObjectPermissions.canSoftDeleteObjectRecords && ( + + )} + + + } + /> )} diff --git a/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSectionDropdownToMany.tsx b/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSectionDropdownToMany.tsx index a47d588179..f930f13c7a 100644 --- a/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSectionDropdownToMany.tsx +++ b/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSectionDropdownToMany.tsx @@ -17,7 +17,6 @@ import { recordStoreFamilySelector } from '@/object-record/record-store/states/s import { ObjectRecord } from '@/object-record/types/ObjectRecord'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { dropdownPlacementComponentState } from '@/ui/layout/dropdown/states/dropdownPlacementComponentState'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2'; @@ -131,39 +130,37 @@ export const RecordDetailRelationSectionDropdownToMany = () => { }; return ( - - - } - dropdownComponents={ - { - closeDropdown(dropdownId); - }} - onClickOutside={() => { - closeDropdown(dropdownId); - }} - layoutDirection={ - dropdownPlacement?.includes('end') - ? 'search-bar-on-bottom' - : 'search-bar-on-top' - } - /> - } - /> - + + } + dropdownComponents={ + { + closeDropdown(dropdownId); + }} + onClickOutside={() => { + closeDropdown(dropdownId); + }} + layoutDirection={ + dropdownPlacement?.includes('end') + ? 'search-bar-on-bottom' + : 'search-bar-on-top' + } + /> + } + /> ); }; diff --git a/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSectionDropdownToOne.tsx b/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSectionDropdownToOne.tsx index 0945e5f90b..b69df3a37a 100644 --- a/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSectionDropdownToOne.tsx +++ b/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSectionDropdownToOne.tsx @@ -17,7 +17,6 @@ import { recordStoreFamilySelector } from '@/object-record/record-store/states/s import { ObjectRecord } from '@/object-record/types/ObjectRecord'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { dropdownPlacementComponentState } from '@/ui/layout/dropdown/states/dropdownPlacementComponentState'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2'; @@ -117,37 +116,35 @@ export const RecordDetailRelationSectionDropdownToOne = () => { CoreObjectNameSingular.WorkspaceMember; return ( - - - } - dropdownComponents={ - closeDropdown(dropdownId)} - onCreate={shouldAllowCreateNew ? handleCreateNew : undefined} - layoutDirection={ - dropdownPlacement?.includes('end') - ? 'search-bar-on-bottom' - : 'search-bar-on-top' - } - /> - } - /> - + + } + dropdownComponents={ + closeDropdown(dropdownId)} + onCreate={shouldAllowCreateNew ? handleCreateNew : undefined} + layoutDirection={ + dropdownPlacement?.includes('end') + ? 'search-bar-on-bottom' + : 'search-bar-on-top' + } + /> + } + /> ); }; diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useHandleContainerMouseEnter.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useHandleContainerMouseEnter.ts index 7fb081552c..d508256061 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useHandleContainerMouseEnter.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useHandleContainerMouseEnter.ts @@ -3,8 +3,8 @@ import { useRecoilCallback } from 'recoil'; import { useMoveHoverToCurrentCell } from '@/object-record/record-table/record-table-cell/hooks/useMoveHoverToCurrentCell'; import { isSomeCellInEditModeComponentSelector } from '@/object-record/record-table/states/selectors/isSomeCellInEditModeComponentSelector'; import { TableCellPosition } from '@/object-record/record-table/types/TableCellPosition'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; export type HandleContainerMouseEnterArgs = { cellPosition: TableCellPosition; diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useResetTableRowSelection.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useResetTableRowSelection.ts index 02f6de326a..331b8d0ce0 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useResetTableRowSelection.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useResetTableRowSelection.ts @@ -7,9 +7,9 @@ import { hasUserSelectedAllRowsComponentState } from '@/object-record/record-tab import { isRowSelectedComponentFamilyState } from '@/object-record/record-table/record-table-row/states/isRowSelectedComponentFamilyState'; import { RecordTableComponentInstanceContext } from '@/object-record/record-table/states/context/RecordTableComponentInstanceContext'; import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { lastSelectedRowIndexComponentState } from '../../record-table-row/states/lastSelectedRowIndexComponentState'; export const useResetTableRowSelection = (recordTableId?: string) => { diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSelectAllRows.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSelectAllRows.ts index 67e842c0f5..ed9d7b8d50 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSelectAllRows.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSelectAllRows.ts @@ -4,8 +4,8 @@ import { recordIndexAllRecordIdsComponentSelector } from '@/object-record/record import { useResetTableRowSelection } from '@/object-record/record-table/hooks/internal/useResetTableRowSelection'; import { isRowSelectedComponentFamilyState } from '@/object-record/record-table/record-table-row/states/isRowSelectedComponentFamilyState'; import { allRowsSelectedStatusComponentSelector } from '@/object-record/record-table/states/selectors/allRowsSelectedStatusComponentSelector'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; export const useSelectAllRows = (recordTableId?: string) => { const allRowsSelectedStatusSelector = useRecoilComponentCallbackStateV2( diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRecordTableData.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRecordTableData.ts index 42cd1e1d48..8757fe4479 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRecordTableData.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRecordTableData.ts @@ -10,10 +10,10 @@ import { hasUserSelectedAllRowsComponentState } from '@/object-record/record-tab import { isRowSelectedComponentFamilyState } from '@/object-record/record-table/record-table-row/states/isRowSelectedComponentFamilyState'; import { recordTableHoverPositionComponentState } from '@/object-record/record-table/states/recordTableHoverPositionComponentState'; import { ObjectRecord } from '@/object-record/types/ObjectRecord'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; import { useRecoilComponentFamilyCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyCallbackStateV2'; import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { isDefined } from 'twenty-shared/utils'; import { isDeeplyEqual } from '~/utils/isDeeplyEqual'; diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts index 8b1875e86b..7852ba5225 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts @@ -2,7 +2,7 @@ import { useRecoilCallback } from 'recoil'; import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata'; import { useSetHasUserSelectedAllRows } from '@/object-record/record-table/hooks/internal/useSetAllRowSelectedState'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { isDeeplyEqual } from '~/utils/isDeeplyEqual'; import { ColumnDefinition } from '../types/ColumnDefinition'; diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTableMoveFocusedCell.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTableMoveFocusedCell.ts index 1db85a2467..b2d96e5894 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTableMoveFocusedCell.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTableMoveFocusedCell.ts @@ -1,7 +1,7 @@ import { useRecoilCallback } from 'recoil'; import { MoveFocusDirection } from '@/object-record/record-table/types/MoveFocusDirection'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { recordIndexAllRecordIdsComponentSelector } from '@/object-record/record-index/states/selectors/recordIndexAllRecordIdsComponentSelector'; import { useFocusRecordTableCell } from '@/object-record/record-table/record-table-cell/hooks/useFocusRecordTableCell'; diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTableMoveFocusedRow.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTableMoveFocusedRow.ts index cab82d7461..3a7bf93ced 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTableMoveFocusedRow.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTableMoveFocusedRow.ts @@ -4,8 +4,8 @@ import { recordIndexAllRecordIdsComponentSelector } from '@/object-record/record import { useFocusedRecordTableRow } from '@/object-record/record-table/hooks/useFocusedRecordTableRow'; import { focusedRecordTableRowIndexComponentState } from '@/object-record/record-table/states/focusedRecordTableRowIndexComponentState'; import { MoveFocusDirection } from '@/object-record/record-table/types/MoveFocusDirection'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { isDefined } from 'twenty-shared/utils'; export const useRecordTableMoveFocusedRow = (recordTableId?: string) => { diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyDragDropContextProvider.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyDragDropContextProvider.tsx index 8eb432828e..f1c1465152 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyDragDropContextProvider.tsx +++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyDragDropContextProvider.tsx @@ -10,9 +10,9 @@ import { currentRecordSortsComponentState } from '@/object-record/record-sort/st import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; import { useRecordTableContextOrThrow } from '@/object-record/record-table/contexts/RecordTableContext'; import { useModal } from '@/ui/layout/modal/hooks/useModal'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { isDefined } from 'twenty-shared/utils'; export const RecordTableBodyDragDropContextProvider = ({ diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellInGroup.test.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellInGroup.test.tsx index 00b1534be0..125b06762b 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellInGroup.test.tsx +++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellInGroup.test.tsx @@ -22,7 +22,7 @@ import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/ import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems'; const onColumnsChange = jest.fn(); -const recordTableId = 'scopeId'; +const recordTableId = 'record-table-id'; const Wrapper = ({ children }: { children: React.ReactNode }) => ( ( { diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/context/RecordTableComponentInstanceContext.ts b/packages/twenty-front/src/modules/object-record/record-table/states/context/RecordTableComponentInstanceContext.ts index 689e25fbc7..6d058637d3 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/context/RecordTableComponentInstanceContext.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/context/RecordTableComponentInstanceContext.ts @@ -4,7 +4,6 @@ import { ComponentStateKeyV2 } from '@/ui/utilities/state/component-state/types/ import { createComponentInstanceContext } from '@/ui/utilities/state/component-state/utils/createComponentInstanceContext'; import { ColumnDefinition } from '../../types/ColumnDefinition'; -// TODO: separate scope contexts from event contexts type RecordTableComponentInstanceContextProps = ComponentStateKeyV2 & { onColumnsChange: (columns: ColumnDefinition[]) => void; }; diff --git a/packages/twenty-front/src/modules/object-record/record-title-cell/hooks/useRecordTitleCell.tsx b/packages/twenty-front/src/modules/object-record/record-title-cell/hooks/useRecordTitleCell.tsx index 42c4c5c0cf..499f2edf79 100644 --- a/packages/twenty-front/src/modules/object-record/record-title-cell/hooks/useRecordTitleCell.tsx +++ b/packages/twenty-front/src/modules/object-record/record-title-cell/hooks/useRecordTitleCell.tsx @@ -1,7 +1,7 @@ import { useContextStoreObjectMetadataItemOrThrow } from '@/context-store/hooks/useContextStoreObjectMetadataItemOrThrow'; import { formatFieldMetadataItemAsColumnDefinition } from '@/object-metadata/utils/formatFieldMetadataItemAsColumnDefinition'; import { useInitDraftValueV2 } from '@/object-record/record-field/hooks/useInitDraftValueV2'; -import { isInlineCellInEditModeScopedState } from '@/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState'; +import { isInlineCellInEditModeFamilyState } from '@/object-record/record-inline-cell/states/isInlineCellInEditModeFamilyState'; import { RecordTitleCellContainerType } from '@/object-record/record-title-cell/types/RecordTitleCellContainerType'; import { getRecordFieldInputInstanceId } from '@/object-record/utils/getRecordFieldInputId'; import { useGoBackToPreviousDropdownFocusId } from '@/ui/layout/dropdown/hooks/useGoBackToPreviousDropdownFocusId'; @@ -32,7 +32,7 @@ export const useRecordTitleCell = () => { containerType: RecordTitleCellContainerType; }) => { set( - isInlineCellInEditModeScopedState( + isInlineCellInEditModeFamilyState( getRecordFieldInputInstanceId({ recordId, fieldName, @@ -93,7 +93,7 @@ export const useRecordTitleCell = () => { fieldName, prefix: containerType, }); - set(isInlineCellInEditModeScopedState(recordTitleCellId), true); + set(isInlineCellInEditModeFamilyState(recordTitleCellId), true); const fieldDefinitions = objectMetadataItem.fields.map( (fieldMetadataItem, index) => diff --git a/packages/twenty-front/src/modules/search/hooks/__tests__/useFilteredSearchRecordQuery.test.tsx b/packages/twenty-front/src/modules/search/hooks/__tests__/useFilteredSearchRecordQuery.test.tsx index c87dbfb515..c2f416a6b4 100644 --- a/packages/twenty-front/src/modules/search/hooks/__tests__/useFilteredSearchRecordQuery.test.tsx +++ b/packages/twenty-front/src/modules/search/hooks/__tests__/useFilteredSearchRecordQuery.test.tsx @@ -5,9 +5,9 @@ import { RecoilRoot, useSetRecoilState } from 'recoil'; import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState'; import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState'; -import { SnackBarComponentInstanceContextProvider } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider'; import { MultipleRecordPickerRecords } from '@/object-record/record-picker/multiple-record-picker/types/MultipleRecordPickerRecords'; +import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems'; import { query, @@ -55,9 +55,11 @@ const mocks = [ const Wrapper = ({ children }: { children: ReactNode }) => ( - + {children} - + ); diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx index 72b6b2c1dc..e7ef66e3fe 100644 --- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx @@ -19,7 +19,7 @@ type SettingsObjectFieldActiveActionDropdownProps = { onDeactivate?: () => void; onEdit: () => void; onSetAsLabelIdentifier?: () => void; - scopeKey: string; + fieldMetadataItemId: string; }; export const SettingsObjectFieldActiveActionDropdown = ({ @@ -27,9 +27,9 @@ export const SettingsObjectFieldActiveActionDropdown = ({ onDeactivate, onEdit, onSetAsLabelIdentifier, - scopeKey, + fieldMetadataItemId, }: SettingsObjectFieldActiveActionDropdownProps) => { - const dropdownId = `${scopeKey}-settings-field-active-action-dropdown`; + const dropdownId = `${fieldMetadataItemId}-settings-field-active-action-dropdown`; const { closeDropdown } = useCloseDropdown(); diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx index 85d1a983b2..2bd550411a 100644 --- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx @@ -21,17 +21,17 @@ type SettingsObjectFieldInactiveActionDropdownProps = { onActivate: () => void; onEdit: () => void; onDelete: () => void; - scopeKey: string; + fieldMetadataItemId: string; }; export const SettingsObjectFieldInactiveActionDropdown = ({ onActivate, - scopeKey, + fieldMetadataItemId, onDelete, onEdit, isCustomField, }: SettingsObjectFieldInactiveActionDropdownProps) => { - const dropdownId = `${scopeKey}-settings-field-disabled-action-dropdown`; + const dropdownId = `${fieldMetadataItemId}-settings-field-disabled-action-dropdown`; const { closeDropdown } = useCloseDropdown(); diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldItemTableRow.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldItemTableRow.tsx index 69952e4ca6..51d73f3c3c 100644 --- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldItemTableRow.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldItemTableRow.tsx @@ -270,7 +270,7 @@ export const SettingsObjectFieldItemTableRow = ({ mode === 'view' ? ( navigate(SettingsPath.ObjectFieldEdit, { objectNamePlural: objectMetadataItem.namePlural, @@ -300,7 +300,7 @@ export const SettingsObjectFieldItemTableRow = ({ ) : mode === 'view' ? ( navigate(SettingsPath.ObjectFieldEdit, { objectNamePlural: objectMetadataItem.namePlural, diff --git a/packages/twenty-front/src/modules/settings/data-model/objects/components/SettingsObjectInactiveMenuDropDown.tsx b/packages/twenty-front/src/modules/settings/data-model/objects/components/SettingsObjectInactiveMenuDropDown.tsx index 23d7423f50..859038042e 100644 --- a/packages/twenty-front/src/modules/settings/data-model/objects/components/SettingsObjectInactiveMenuDropDown.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/objects/components/SettingsObjectInactiveMenuDropDown.tsx @@ -11,16 +11,16 @@ type SettingsObjectInactiveMenuDropDownProps = { isCustomObject: boolean; onActivate: () => void; onDelete: () => void; - scopeKey: string; + objectMetadataItemNamePlural: string; }; export const SettingsObjectInactiveMenuDropDown = ({ onActivate, - scopeKey, + objectMetadataItemNamePlural, onDelete, isCustomObject, }: SettingsObjectInactiveMenuDropDownProps) => { - const dropdownId = `${scopeKey}-settings-object-inactive-menu-dropdown`; + const dropdownId = `${objectMetadataItemNamePlural}-settings-object-inactive-menu-dropdown`; const { closeDropdown } = useCloseDropdown(); diff --git a/packages/twenty-front/src/modules/settings/data-model/objects/components/__stories__/SettingsObjectInactiveMenuDropDown.stories.tsx b/packages/twenty-front/src/modules/settings/data-model/objects/components/__stories__/SettingsObjectInactiveMenuDropDown.stories.tsx index b160b46e86..735ce63293 100644 --- a/packages/twenty-front/src/modules/settings/data-model/objects/components/__stories__/SettingsObjectInactiveMenuDropDown.stories.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/objects/components/__stories__/SettingsObjectInactiveMenuDropDown.stories.tsx @@ -1,8 +1,8 @@ import { Decorator, Meta, StoryObj } from '@storybook/react'; import { expect, fn, userEvent, within } from '@storybook/test'; -import { SettingsObjectInactiveMenuDropDown } from '../SettingsObjectInactiveMenuDropDown'; import { ComponentDecorator } from 'twenty-ui/testing'; +import { SettingsObjectInactiveMenuDropDown } from '../SettingsObjectInactiveMenuDropDown'; const handleActivateMockFunction = fn(); const handleDeleteMockFunction = fn(); @@ -19,7 +19,7 @@ const meta: Meta = { title: 'Modules/Settings/DataModel/SettingsObjectInactiveMenuDropDown', component: SettingsObjectInactiveMenuDropDown, args: { - scopeKey: 'settings-object-inactive-menu-dropdown', + objectMetadataItemNamePlural: 'settings-object-inactive-menu-dropdown', onActivate: handleActivateMockFunction, onDelete: handleDeleteMockFunction, }, diff --git a/packages/twenty-front/src/modules/settings/hooks/__tests__/useSettingsNavigationItems.test.tsx b/packages/twenty-front/src/modules/settings/hooks/__tests__/useSettingsNavigationItems.test.tsx index 97e01e60d5..9a0befeef8 100644 --- a/packages/twenty-front/src/modules/settings/hooks/__tests__/useSettingsNavigationItems.test.tsx +++ b/packages/twenty-front/src/modules/settings/hooks/__tests__/useSettingsNavigationItems.test.tsx @@ -14,7 +14,7 @@ import { currentUserState } from '@/auth/states/currentUserState'; import { billingState } from '@/client-config/states/billingState'; import { labPublicFeatureFlagsState } from '@/client-config/states/labPublicFeatureFlagsState'; import { usePermissionFlagMap } from '@/settings/roles/hooks/usePermissionFlagMap'; -import { SnackBarComponentInstanceContextProvider } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider'; +import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; const mockCurrentUser = { id: 'fake-user-id', @@ -45,9 +45,11 @@ const Wrapper = ({ children }: { children: ReactNode }) => ( - + {children} - + diff --git a/packages/twenty-front/src/modules/settings/playground/components/__stories__/GraphQLPlayground.stories.tsx b/packages/twenty-front/src/modules/settings/playground/components/__stories__/GraphQLPlayground.stories.tsx index 52e9dd63e1..54b8ca6b6e 100644 --- a/packages/twenty-front/src/modules/settings/playground/components/__stories__/GraphQLPlayground.stories.tsx +++ b/packages/twenty-front/src/modules/settings/playground/components/__stories__/GraphQLPlayground.stories.tsx @@ -4,13 +4,12 @@ import { action } from '@storybook/addon-actions'; import { Meta, StoryObj } from '@storybook/react'; import { useEffect } from 'react'; import { useSetRecoilState } from 'recoil'; -import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator'; -import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; -import { graphqlMocks } from '~/testing/graphqlMocks'; import { ComponentDecorator, ComponentWithRouterDecorator, } from 'twenty-ui/testing'; +import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; +import { graphqlMocks } from '~/testing/graphqlMocks'; const PlaygroundApiKeySetterEffect = () => { const setPlaygroundApiKey = useSetRecoilState(playgroundApiKeyState); @@ -29,7 +28,6 @@ const meta: Meta = { ComponentDecorator, I18nFrontDecorator, ComponentWithRouterDecorator, - ComponentWithRecoilScopeDecorator, ], parameters: { docs: { diff --git a/packages/twenty-front/src/modules/settings/playground/components/__stories__/PlaygroundSetupForm.stories.tsx b/packages/twenty-front/src/modules/settings/playground/components/__stories__/PlaygroundSetupForm.stories.tsx index 351c2707ac..ef1c5acbae 100644 --- a/packages/twenty-front/src/modules/settings/playground/components/__stories__/PlaygroundSetupForm.stories.tsx +++ b/packages/twenty-front/src/modules/settings/playground/components/__stories__/PlaygroundSetupForm.stories.tsx @@ -1,18 +1,12 @@ import { Meta, StoryObj } from '@storybook/react'; -import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator'; +import { ComponentDecorator, RouterDecorator } from 'twenty-ui/testing'; import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; import { PlaygroundSetupForm } from '../PlaygroundSetupForm'; -import { ComponentDecorator, RouterDecorator } from 'twenty-ui/testing'; const meta: Meta = { title: 'Modules/Settings/Playground/PlaygroundSetupForm', component: PlaygroundSetupForm, - decorators: [ - ComponentDecorator, - RouterDecorator, - I18nFrontDecorator, - ComponentWithRecoilScopeDecorator, - ], + decorators: [ComponentDecorator, RouterDecorator, I18nFrontDecorator], parameters: { docs: { description: { diff --git a/packages/twenty-front/src/modules/settings/playground/components/__stories__/RestPlayground.stories.tsx b/packages/twenty-front/src/modules/settings/playground/components/__stories__/RestPlayground.stories.tsx index 2bfaded099..2c1c5b3367 100644 --- a/packages/twenty-front/src/modules/settings/playground/components/__stories__/RestPlayground.stories.tsx +++ b/packages/twenty-front/src/modules/settings/playground/components/__stories__/RestPlayground.stories.tsx @@ -2,13 +2,12 @@ import { playgroundApiKeyState } from '@/settings/playground/states/playgroundAp import { PlaygroundSchemas } from '@/settings/playground/types/PlaygroundSchemas'; import { action } from '@storybook/addon-actions'; import { Meta, StoryObj } from '@storybook/react'; -import { http, HttpResponse } from 'msw'; +import { HttpResponse, http } from 'msw'; import { useEffect } from 'react'; import { useSetRecoilState } from 'recoil'; -import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator'; +import { ComponentDecorator } from 'twenty-ui/testing'; import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; import { RestPlayground } from '../RestPlayground'; -import { ComponentDecorator } from 'twenty-ui/testing'; const PlaygroundApiKeySetterEffect = () => { const setPlaygroundApiKey = useSetRecoilState(playgroundApiKeyState); @@ -88,11 +87,7 @@ const openApiSpec = { const meta: Meta = { title: 'Modules/Settings/Playground/RestPlayground', component: RestPlayground, - decorators: [ - ComponentDecorator, - I18nFrontDecorator, - ComponentWithRecoilScopeDecorator, - ], + decorators: [ComponentDecorator, I18nFrontDecorator], parameters: { docs: { description: { diff --git a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesQueryEffect.tsx b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesQueryEffect.tsx index bee0af6713..24f90e61c4 100644 --- a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesQueryEffect.tsx +++ b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesQueryEffect.tsx @@ -2,7 +2,7 @@ import { settingsDraftRoleFamilyState } from '@/settings/roles/states/settingsDr import { settingsPersistedRoleFamilyState } from '@/settings/roles/states/settingsPersistedRoleFamilyState'; import { settingsRoleIdsState } from '@/settings/roles/states/settingsRoleIdsState'; import { settingsRolesIsLoadingState } from '@/settings/roles/states/settingsRolesIsLoadingState'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { useEffect } from 'react'; import { useRecoilCallback, useSetRecoilState } from 'recoil'; import { isDefined } from 'twenty-shared/utils'; diff --git a/packages/twenty-front/src/modules/settings/roles/role/components/SettingsRoleEditEffect.tsx b/packages/twenty-front/src/modules/settings/roles/role/components/SettingsRoleEditEffect.tsx index 04898aad84..8667ade15a 100644 --- a/packages/twenty-front/src/modules/settings/roles/role/components/SettingsRoleEditEffect.tsx +++ b/packages/twenty-front/src/modules/settings/roles/role/components/SettingsRoleEditEffect.tsx @@ -2,8 +2,8 @@ import { SETTINGS_ROLE_DETAIL_TABS } from '@/settings/roles/role/constants/Setti import { settingsDraftRoleFamilyState } from '@/settings/roles/states/settingsDraftRoleFamilyState'; import { settingsPersistedRoleFamilyState } from '@/settings/roles/states/settingsPersistedRoleFamilyState'; import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { useEffect, useState } from 'react'; import { useRecoilCallback, useRecoilValue } from 'recoil'; import { isDefined } from 'twenty-shared/utils'; diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/MatchColumns.stories.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/MatchColumns.stories.tsx index cd1d1811e8..cb9f8e5fee 100644 --- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/MatchColumns.stories.tsx +++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/MatchColumns.stories.tsx @@ -5,7 +5,7 @@ import { ReactSpreadsheetImportContextProvider } from '@/spreadsheet-import/comp import { SpreadSheetImportModalWrapper } from '@/spreadsheet-import/components/SpreadSheetImportModalWrapper'; import { MatchColumnsStep } from '@/spreadsheet-import/steps/components/MatchColumnsStep/MatchColumnsStep'; import { SpreadsheetImportStep } from '@/spreadsheet-import/steps/types/SpreadsheetImportStep'; -import { DialogManagerScope } from '@/ui/feedback/dialog-manager/scopes/DialogManagerScope'; +import { DialogComponentInstanceContext } from '@/ui/feedback/dialog-manager/contexts/DialogComponentInstanceContext'; import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; @@ -62,7 +62,9 @@ const mockData = [ ]; export const Default = () => ( - + ( /> - + ); diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/SelectHeader.stories.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/SelectHeader.stories.tsx index f59ff3f5f2..97b634c285 100644 --- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/SelectHeader.stories.tsx +++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/SelectHeader.stories.tsx @@ -8,7 +8,7 @@ import { ReactSpreadsheetImportContextProvider } from '@/spreadsheet-import/comp import { SpreadSheetImportModalWrapper } from '@/spreadsheet-import/components/SpreadSheetImportModalWrapper'; import { SelectHeaderStep } from '@/spreadsheet-import/steps/components/SelectHeaderStep/SelectHeaderStep'; import { SpreadsheetImportStepType } from '@/spreadsheet-import/steps/types/SpreadsheetImportStepType'; -import { DialogManagerScope } from '@/ui/feedback/dialog-manager/scopes/DialogManagerScope'; +import { DialogComponentInstanceContext } from '@/ui/feedback/dialog-manager/contexts/DialogComponentInstanceContext'; import { isModalOpenedComponentState } from '@/ui/layout/modal/states/isModalOpenedComponentState'; import { RecoilRoot } from 'recoil'; import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; @@ -40,7 +40,9 @@ const meta: Meta = { export default meta; export const Default = () => ( - + ( /> - + ); diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/SelectSheet.stories.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/SelectSheet.stories.tsx index 7dbc22c763..1a34e3f420 100644 --- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/SelectSheet.stories.tsx +++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/SelectSheet.stories.tsx @@ -5,7 +5,7 @@ import { ReactSpreadsheetImportContextProvider } from '@/spreadsheet-import/comp import { SpreadSheetImportModalWrapper } from '@/spreadsheet-import/components/SpreadSheetImportModalWrapper'; import { SelectSheetStep } from '@/spreadsheet-import/steps/components/SelectSheetStep/SelectSheetStep'; import { SpreadsheetImportStepType } from '@/spreadsheet-import/steps/types/SpreadsheetImportStepType'; -import { DialogManagerScope } from '@/ui/feedback/dialog-manager/scopes/DialogManagerScope'; +import { DialogComponentInstanceContext } from '@/ui/feedback/dialog-manager/contexts/DialogComponentInstanceContext'; import { isModalOpenedComponentState } from '@/ui/layout/modal/states/isModalOpenedComponentState'; import { RecoilRoot } from 'recoil'; import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; @@ -40,7 +40,9 @@ export default meta; const sheetNames = ['Sheet1', 'Sheet2', 'Sheet3']; export const Default = () => ( - + ( /> - + ); diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Steps.stories.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Steps.stories.tsx index 7d74d6021e..1e36f31b2e 100644 --- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Steps.stories.tsx +++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Steps.stories.tsx @@ -1,6 +1,5 @@ import { Meta, StoryObj } from '@storybook/react'; -import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator'; import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator'; import { stepBarInternalState } from '@/ui/navigation/step-bar/states/stepBarInternalState'; @@ -13,7 +12,6 @@ const meta: Meta = { title: 'Modules/SpreadsheetImport/Steps', component: SpreadsheetImportStepperContainer, decorators: [ - ComponentWithRecoilScopeDecorator, SnackBarDecorator, I18nFrontDecorator, ObjectMetadataItemsDecorator, diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Upload.stories.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Upload.stories.tsx index 73946a2417..4e5cc4bbb1 100644 --- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Upload.stories.tsx +++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Upload.stories.tsx @@ -5,7 +5,7 @@ import { ReactSpreadsheetImportContextProvider } from '@/spreadsheet-import/comp import { SpreadSheetImportModalWrapper } from '@/spreadsheet-import/components/SpreadSheetImportModalWrapper'; import { UploadStep } from '@/spreadsheet-import/steps/components/UploadStep/UploadStep'; import { SpreadsheetImportStepType } from '@/spreadsheet-import/steps/types/SpreadsheetImportStepType'; -import { DialogManagerScope } from '@/ui/feedback/dialog-manager/scopes/DialogManagerScope'; +import { DialogComponentInstanceContext } from '@/ui/feedback/dialog-manager/contexts/DialogComponentInstanceContext'; import { isModalOpenedComponentState } from '@/ui/layout/modal/states/isModalOpenedComponentState'; import { RecoilRoot } from 'recoil'; import { ContextStoreDecorator } from '~/testing/decorators/ContextStoreDecorator'; @@ -44,7 +44,9 @@ const meta: Meta = { export default meta; export const Default = () => ( - + null}> ( /> - + ); diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Validation.stories.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Validation.stories.tsx index 895e8614d1..b7f9544e1d 100644 --- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Validation.stories.tsx +++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/__stories__/Validation.stories.tsx @@ -8,7 +8,7 @@ import { import { ReactSpreadsheetImportContextProvider } from '@/spreadsheet-import/components/ReactSpreadsheetImportContextProvider'; import { SpreadSheetImportModalWrapper } from '@/spreadsheet-import/components/SpreadSheetImportModalWrapper'; import { ValidationStep } from '@/spreadsheet-import/steps/components/ValidationStep/ValidationStep'; -import { DialogManagerScope } from '@/ui/feedback/dialog-manager/scopes/DialogManagerScope'; +import { DialogComponentInstanceContext } from '@/ui/feedback/dialog-manager/contexts/DialogComponentInstanceContext'; import { isModalOpenedComponentState } from '@/ui/layout/modal/states/isModalOpenedComponentState'; import { RecoilRoot } from 'recoil'; import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator'; @@ -43,7 +43,9 @@ export default meta; const file = new File([''], 'file.csv'); export const Default = () => ( - + ( /> - + ); diff --git a/packages/twenty-front/src/modules/types/RecoilScopeContext.ts b/packages/twenty-front/src/modules/types/RecoilScopeContext.ts deleted file mode 100644 index 0a7b4188bc..0000000000 --- a/packages/twenty-front/src/modules/types/RecoilScopeContext.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Context } from 'react'; - -export type RecoilScopeContext = Context; diff --git a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/constants/DialogManagerHotkeyScopeMemoizeKey.ts b/packages/twenty-front/src/modules/ui/feedback/dialog-manager/constants/DialogManagerHotkeyScopeMemoizeKey.ts deleted file mode 100644 index 21e4fddcb2..0000000000 --- a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/constants/DialogManagerHotkeyScopeMemoizeKey.ts +++ /dev/null @@ -1 +0,0 @@ -export const DIALOG_MANAGER_HOTKEY_SCOPE_MEMOIZE_KEY = 'dialog-manager'; diff --git a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/hooks/__tests__/useDialogManager.test.tsx b/packages/twenty-front/src/modules/ui/feedback/dialog-manager/hooks/__tests__/useDialogManager.test.tsx index ba83b25a8e..a59a83ae50 100644 --- a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/hooks/__tests__/useDialogManager.test.tsx +++ b/packages/twenty-front/src/modules/ui/feedback/dialog-manager/hooks/__tests__/useDialogManager.test.tsx @@ -2,8 +2,8 @@ import { act, renderHook } from '@testing-library/react'; import { RecoilRoot } from 'recoil'; import { v4 as uuidv4 } from 'uuid'; +import { DialogComponentInstanceContext } from '@/ui/feedback/dialog-manager/contexts/DialogComponentInstanceContext'; import { useDialogManager } from '@/ui/feedback/dialog-manager/hooks/useDialogManager'; -import { DialogManagerScope } from '@/ui/feedback/dialog-manager/scopes/DialogManagerScope'; import { dialogInternalComponentState } from '@/ui/feedback/dialog-manager/states/dialogInternalComponentState'; import { DialogOptions } from '@/ui/feedback/dialog-manager/types/DialogOptions'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; @@ -13,12 +13,13 @@ jest.mock('uuid'); (uuidv4 as jest.Mock).mockReturnValue(mockedUuid); -const dialogManagerScopeId = 'dialog-manager'; const Wrapper = ({ children }: { children: React.ReactNode }) => ( - + {children} - + ); diff --git a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/scopes/DialogManagerScope.tsx b/packages/twenty-front/src/modules/ui/feedback/dialog-manager/scopes/DialogManagerScope.tsx deleted file mode 100644 index 82efa84401..0000000000 --- a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/scopes/DialogManagerScope.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { ReactNode } from 'react'; - -import { DialogComponentInstanceContext } from '@/ui/feedback/dialog-manager/contexts/DialogComponentInstanceContext'; - -type DialogManagerScopeProps = { - children: ReactNode; - dialogComponentInstanceId: string; -}; - -export const DialogManagerScope = ({ - children, - dialogComponentInstanceId, -}: DialogManagerScopeProps) => { - return ( - - {children} - - ); -}; diff --git a/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider.tsx b/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider.tsx deleted file mode 100644 index 6b09175986..0000000000 --- a/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { ReactNode } from 'react'; - -import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; - -type SnackBarComponentInstanceContextProviderProps = { - children: ReactNode; - snackBarComponentInstanceId: string; -}; - -export const SnackBarComponentInstanceContextProvider = ({ - children, - snackBarComponentInstanceId, -}: SnackBarComponentInstanceContextProviderProps) => { - return ( - - {children} - - ); -}; diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx index 6fa6f1ccea..fbf60f4c8e 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx @@ -4,7 +4,6 @@ import { DROPDOWN_RESIZE_MIN_HEIGHT } from '@/ui/layout/dropdown/constants/Dropd import { DROPDOWN_RESIZE_MIN_WIDTH } from '@/ui/layout/dropdown/constants/DropdownResizeMinWidth'; import { DropdownComponentInstanceContext } from '@/ui/layout/dropdown/contexts/DropdownComponentInstanceContext'; import { useToggleDropdown } from '@/ui/layout/dropdown/hooks/useToggleDropdown'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { dropdownMaxHeightComponentState } from '@/ui/layout/dropdown/states/internal/dropdownMaxHeightComponentState'; import { dropdownMaxWidthComponentState } from '@/ui/layout/dropdown/states/internal/dropdownMaxWidthComponentState'; import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState'; @@ -174,43 +173,39 @@ export const Dropdown = ({ - - <> - {isDefined(clickableComponent) ? ( - - {clickableComponent} - - ) : ( - - )} - {isDropdownOpen && ( - - )} - - - + {isDefined(clickableComponent) ? ( + + {clickableComponent} + + ) : ( + + )} + {isDropdownOpen && ( + + )} + ); }; diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/DropdownScope.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/DropdownScope.tsx deleted file mode 100644 index e6e53702da..0000000000 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/DropdownScope.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { ReactNode } from 'react'; - -import { DropdownScopeInternalContext } from './scope-internal-context/DropdownScopeInternalContext'; - -type DropdownScopeProps = { - children: ReactNode; - dropdownScopeId: string; -}; - -export const DropdownScope = ({ - children, - dropdownScopeId, -}: DropdownScopeProps) => { - return ( - - {children} - - ); -}; diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext.ts deleted file mode 100644 index ed9516be68..0000000000 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -type DropdownScopeInternalContextProps = RecoilComponentStateKey; - -export const DropdownScopeInternalContext = - createScopeInternalContext(); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/__tests__/useSelectableList.test.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/__tests__/useSelectableList.test.ts index f6a26777b3..dd68596cfc 100644 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/__tests__/useSelectableList.test.ts +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/__tests__/useSelectableList.test.ts @@ -8,7 +8,7 @@ import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2'; -const selectableListScopeId = 'testId'; +const selectableListComponentInstanceId = 'testId'; const testArr = [['1'], ['2'], ['3']]; const emptyArr = [[]]; @@ -18,12 +18,12 @@ describe('useSelectableList', () => { () => { const setSelectableItemIds = useSetRecoilComponentStateV2( selectableItemIdsComponentState, - selectableListScopeId, + selectableListComponentInstanceId, ); const selectableItemIds = useRecoilComponentValueV2( selectableItemIdsComponentState, - selectableListScopeId, + selectableListComponentInstanceId, ); return { @@ -45,18 +45,20 @@ describe('useSelectableList', () => { expect(result.current.selectableItemIds).toEqual(testArr); }); - it('Should resetSelectItem', async () => { + it('Should resetSelectedItem', async () => { const { result } = renderHook( () => { - const { resetSelectedItem } = useSelectableList(selectableListScopeId); + const { resetSelectedItem } = useSelectableList( + selectableListComponentInstanceId, + ); const selectedItemId = useRecoilComponentValueV2( selectedItemIdComponentState, - selectableListScopeId, + selectableListComponentInstanceId, ); const setSelectedItemId = useSetRecoilComponentStateV2( selectedItemIdComponentState, - selectableListScopeId, + selectableListComponentInstanceId, ); return { resetSelectedItem, diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.ts index 0fb586657d..0fc3f1edcd 100644 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.ts +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.ts @@ -6,7 +6,7 @@ import { selectableItemIdsComponentState } from '@/ui/layout/selectable-list/sta import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState'; import { isSelectedItemIdComponentFamilySelector } from '@/ui/layout/selectable-list/states/selectors/isSelectedItemIdComponentFamilySelector'; import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; type Direction = 'up' | 'down' | 'left' | 'right'; diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts index 7fc543aecc..ce33cb5525 100644 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts @@ -3,8 +3,8 @@ import { useRecoilCallback } from 'recoil'; import { SelectableListComponentInstanceContext } from '@/ui/layout/selectable-list/states/contexts/SelectableListComponentInstanceContext'; import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState'; import { isSelectedItemIdComponentFamilySelector } from '@/ui/layout/selectable-list/states/selectors/isSelectedItemIdComponentFamilySelector'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { isDefined } from 'twenty-shared/utils'; export const useSelectableList = (instanceId?: string) => { diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListListenToEnterHotkeyOnItem.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListListenToEnterHotkeyOnItem.ts index 9a5ef7eb44..02990dd742 100644 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListListenToEnterHotkeyOnItem.ts +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListListenToEnterHotkeyOnItem.ts @@ -1,8 +1,8 @@ import { SelectableListComponentInstanceContext } from '@/ui/layout/selectable-list/states/contexts/SelectableListComponentInstanceContext'; import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState'; import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { isNonEmptyString } from '@sniptt/guards'; import { useRecoilCallback } from 'recoil'; import { Key } from 'ts-key-enum'; diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/scopes/TabListScope.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/scopes/TabListScope.tsx deleted file mode 100644 index e1f52ef012..0000000000 --- a/packages/twenty-front/src/modules/ui/layout/tab-list/scopes/TabListScope.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { ReactNode } from 'react'; - -import { TabListScopeInternalContext } from './scope-internal-context/TabListScopeInternalContext'; - -type TabListScopeProps = { - children: ReactNode; - tabListScopeId: string; -}; - -export const TabListScope = ({ - children, - tabListScopeId, -}: TabListScopeProps) => { - return ( - - {children} - - ); -}; diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/scopes/scope-internal-context/TabListScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/layout/tab-list/scopes/scope-internal-context/TabListScopeInternalContext.ts deleted file mode 100644 index 5212b7bdba..0000000000 --- a/packages/twenty-front/src/modules/ui/layout/tab-list/scopes/scope-internal-context/TabListScopeInternalContext.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -type TabListScopeInternalContextProps = RecoilComponentStateKey; - -export const TabListScopeInternalContext = - createScopeInternalContext(); diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/hooks/useNavigationSection.ts b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/hooks/useNavigationSection.ts index 8785c90baf..33c3255a3b 100644 --- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/hooks/useNavigationSection.ts +++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/hooks/useNavigationSection.ts @@ -2,28 +2,28 @@ import { useRecoilCallback } from 'recoil'; import { isNavigationSectionOpenFamilyState } from '@/ui/navigation/navigation-drawer/states/isNavigationSectionOpenFamilyState'; -export const useNavigationSection = (scopeId: string) => { +export const useNavigationSection = (navigationSectionId: string) => { const closeNavigationSection = useRecoilCallback( ({ set }) => () => { - set(isNavigationSectionOpenFamilyState(scopeId), false); + set(isNavigationSectionOpenFamilyState(navigationSectionId), false); }, - [scopeId], + [navigationSectionId], ); const openNavigationSection = useRecoilCallback( ({ set }) => () => { - set(isNavigationSectionOpenFamilyState(scopeId), true); + set(isNavigationSectionOpenFamilyState(navigationSectionId), true); }, - [scopeId], + [navigationSectionId], ); const toggleNavigationSection = useRecoilCallback( ({ snapshot }) => () => { const isNavigationSectionOpen = snapshot - .getLoadable(isNavigationSectionOpenFamilyState(scopeId)) + .getLoadable(isNavigationSectionOpenFamilyState(navigationSectionId)) .getValue(); if (isNavigationSectionOpen) { @@ -32,11 +32,11 @@ export const useNavigationSection = (scopeId: string) => { openNavigationSection(); } }, - [closeNavigationSection, openNavigationSection, scopeId], + [closeNavigationSection, openNavigationSection, navigationSectionId], ); const isNavigationSectionOpenState = - isNavigationSectionOpenFamilyState(scopeId); + isNavigationSectionOpenFamilyState(navigationSectionId); return { isNavigationSectionOpenState, diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/components/RecoilScope.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/components/RecoilScope.tsx deleted file mode 100644 index b2ee0f6d10..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/components/RecoilScope.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { useRef } from 'react'; -import { v4 } from 'uuid'; - -import { RecoilScopeContext as RecoilScopeContextType } from '@/types/RecoilScopeContext'; - -import { RecoilScopeContext } from '../states/RecoilScopeContext'; - -/** - * - * @deprecated Use a custom scope context instead, see example with DropdownScope - */ -export const RecoilScope = ({ - children, - scopeId, - CustomRecoilScopeContext, -}: { - children: React.ReactNode; - scopeId?: string; - CustomRecoilScopeContext?: RecoilScopeContextType; -}) => { - // eslint-disable-next-line @nx/workspace-no-state-useref - const currentScopeId = useRef(scopeId ?? v4()); - - return CustomRecoilScopeContext ? ( - - {children} - - ) : ( - - {children} - - ); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useContextScopeId.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useContextScopeId.test.tsx deleted file mode 100644 index 810ba3fadb..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useContextScopeId.test.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { renderHook } from '@testing-library/react'; -import { createContext } from 'react'; - -import { useContextScopeId } from '@/ui/utilities/recoil-scope/hooks/useContextScopeId'; - -const mockedContextValue = 'mocked-scope-id'; -const MockedContext = createContext(mockedContextValue); -const nullContext = createContext(null); - -const ERROR_MESSAGE = - 'Using useContextScopedId outside of the specified context : undefined, verify that you are using a RecoilScope with the specific context you want to use.'; - -describe('useContextScopeId', () => { - it('Should return the scoped ID when used within the specified context', () => { - const { result } = renderHook(() => useContextScopeId(MockedContext), { - wrapper: ({ children }) => ( - - {children} - - ), - }); - - const scopeId = result.current; - expect(scopeId).toBe(mockedContextValue); - }); - - it('Should throw an error when used outside of the specified context', () => { - // Suppress console errors for this test since we're expecting an error - /* eslint-disable no-console */ - const originalConsoleError = console.error; - console.error = jest.fn(); - /* eslint-enable no-console */ - - expect(() => { - renderHook(() => useContextScopeId(nullContext)); - }).toThrow(ERROR_MESSAGE); - - // Restore console.error - /* eslint-disable no-console */ - console.error = originalConsoleError; - /* eslint-enable no-console */ - }); -}); diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopeId.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopeId.test.tsx deleted file mode 100644 index 9faa15c44a..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopeId.test.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { renderHook } from '@testing-library/react'; -import { createContext } from 'react'; - -import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId'; - -const mockedContextValue = 'mocked-scope-id'; -const MockedContext = createContext(mockedContextValue); -const nullContext = createContext(null); - -const ERROR_MESSAGE = - 'Using useRecoilScopeId outside of the specified context : undefined, verify that you are using a RecoilScope with the specific context you want to use.'; - -describe('useRecoilScopeId', () => { - it('Should return the scoped ID when used within the specified context', () => { - const { result } = renderHook(() => useRecoilScopeId(MockedContext), { - wrapper: ({ children }) => ( - - {children} - - ), - }); - - const scopeId = result.current; - expect(scopeId).toBe(mockedContextValue); - }); - - it('Should throw an error when used outside of the specified context', () => { - // Suppress console errors for this test since we're expecting an error - /* eslint-disable no-console */ - const originalConsoleError = console.error; - console.error = jest.fn(); - /* eslint-enable no-console */ - - expect(() => { - renderHook(() => useRecoilScopeId(nullContext)); - }).toThrow(ERROR_MESSAGE); - - // Restore console.error - /* eslint-disable no-console */ - console.error = originalConsoleError; - /* eslint-enable no-console */ - }); -}); diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useContextScopeId.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useContextScopeId.ts deleted file mode 100644 index bf92b9de25..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useContextScopeId.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Context, useContext } from 'react'; - -/** - * @deprecated use a custom scope instead and desctructure the scope id from the scope context - * Get the scope context with useScopeInternalContext - */ -export const useContextScopeId = (SpecificContext: Context) => { - const recoilScopeId = useContext(SpecificContext); - - if (!recoilScopeId) - throw new Error( - `Using useContextScopedId outside of the specified context : ${SpecificContext.displayName}, verify that you are using a RecoilScope with the specific context you want to use.`, - ); - - return recoilScopeId; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopeId.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopeId.ts deleted file mode 100644 index f14486f1fd..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopeId.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { useContext } from 'react'; - -import { RecoilScopeContext } from '@/types/RecoilScopeContext'; - -/** - * @deprecated Use a custom scope instead and desctructure the scope id from the scope context - */ -export const useRecoilScopeId = (RecoilScopeContext: RecoilScopeContext) => { - const recoilScopeId = useContext(RecoilScopeContext); - - if (!recoilScopeId) - throw new Error( - `Using useRecoilScopeId outside of the specified context : ${RecoilScopeContext.displayName}, verify that you are using a RecoilScope with the specific context you want to use.`, - ); - - return recoilScopeId; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedStateV2.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedStateV2.ts deleted file mode 100644 index cf3b747450..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedStateV2.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { RecoilState, useRecoilState } from 'recoil'; - -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -export const useRecoilScopedStateV2 = ( - recoilState: (scopedKey: RecoilComponentStateKey) => RecoilState, - scopeId: string, -) => { - return useRecoilState( - recoilState({ - scopeId, - }), - ); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useAvailableScopeId.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useAvailableScopeId.test.tsx deleted file mode 100644 index 05a638e717..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useAvailableScopeId.test.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { renderHook } from '@testing-library/react'; -import React from 'react'; - -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; -import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; - -const mockScopeIdFrom = { - Props: 'scopeIdFromProps', - Context: 'scopeIdFromContext', -}; -const MockedContext = createScopeInternalContext(); -const errorMessage = 'Scope id is not provided and cannot be found in context.'; - -const Wrapper = ({ children }: { children: React.ReactNode }) => ( - - {children} - -); - -describe('useAvailableScopeIdOrThrow', () => { - it('should return scopeIdFromProps if provided', () => { - const { - result: { - current: { availableScopeId }, - }, - } = renderHook( - () => ({ - availableScopeId: useAvailableScopeIdOrThrow( - MockedContext, - mockScopeIdFrom.Props, - ), - }), - { wrapper: Wrapper }, - ); - - expect(availableScopeId).toBe(mockScopeIdFrom.Props); - }); - - it('should return scopeIdFromContext if no scopeIdFromProps is present', () => { - const { - result: { - current: { availableScopeId }, - }, - } = renderHook( - () => ({ - availableScopeId: useAvailableScopeIdOrThrow(MockedContext), - }), - { wrapper: Wrapper }, - ); - - expect(availableScopeId).toBe(mockScopeIdFrom.Context); - }); - - it('should throw an error if no scopeId is provided and scopeId is undefined in the context', () => { - global.console.error = jest.fn(); - - const renderFunction = () => - renderHook(() => ({ - availableScopeId: useAvailableScopeIdOrThrow(MockedContext), - })); - - expect(renderFunction).toThrow(errorMessage); - }); -}); diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopeInternalContext.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopeInternalContext.test.tsx deleted file mode 100644 index dcd7159d56..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopeInternalContext.test.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { renderHook } from '@testing-library/react'; - -import { useScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContext'; -import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; - -const scopeId = 'scopeId'; -const MockedContext = createScopeInternalContext(); - -const Wrapper = ({ children }: { children: React.ReactNode }) => ( - - {children} - -); - -describe('useScopeInternalContext', () => { - it('should work as expected', () => { - const { - result: { - current: { scopeInternalContext }, - }, - } = renderHook( - () => ({ - scopeInternalContext: useScopeInternalContext(MockedContext), - }), - { - wrapper: Wrapper, - }, - ); - - expect(scopeInternalContext!.scopeId).toBe(scopeId); - }); -}); diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId.ts deleted file mode 100644 index 02a902c0ec..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { isNonEmptyString } from '@sniptt/guards'; - -import { ScopeInternalContext } from '../types/ScopeInternalContext'; - -import { useScopeInternalContext } from './useScopeInternalContext'; - -export const useAvailableScopeIdOrThrow = ( - Context: ScopeInternalContext, - scopeIdFromProps?: string, -): string => { - const scopeInternalContext = useScopeInternalContext(Context); - - const scopeIdFromContext = scopeInternalContext?.scopeId; - - if (isNonEmptyString(scopeIdFromProps)) { - return scopeIdFromProps; - } else if (isNonEmptyString(scopeIdFromContext)) { - return scopeIdFromContext; - } else { - throw new Error( - `Scope id is not provided and cannot be found in context.\n` + - `Context: ${Context.displayName || 'Unknown'}\n` + - `ScopeInternalContext.scopeId: ${scopeInternalContext?.scopeId || 'Unknown'}`, - ); - } -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContext.ts deleted file mode 100644 index 7b4c4f1c40..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContext.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { useContext } from 'react'; - -import { ScopeInternalContext } from '../types/ScopeInternalContext'; - -export const useScopeInternalContext = ( - Context: ScopeInternalContext, -) => { - const context = useContext(Context); - - return context; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopeInternalContext.ts deleted file mode 100644 index bd6ff6ee49..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopeInternalContext.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Context } from 'react'; - -export type ScopeInternalContext = - Context; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext.ts deleted file mode 100644 index 02d447a7fd..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; -import { Context, createContext } from 'react'; - -type ScopeInternalContext = - Context; - -export const createScopeInternalContext = ( - initialValue?: T, -) => { - return createContext( - initialValue ?? null, - ) as ScopeInternalContext; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/states/RecoilScopeContext.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/states/RecoilScopeContext.ts deleted file mode 100644 index b88dc68a24..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/states/RecoilScopeContext.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { createContext } from 'react'; - -export const RecoilScopeContext = createContext(null); diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedSelector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedSelector.ts deleted file mode 100644 index 5f680bbda0..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedSelector.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RecoilValueReadOnly } from 'recoil'; - -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -export type RecoilScopedSelector = ( - scopedKey: RecoilComponentStateKey, -) => RecoilValueReadOnly; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedState.ts deleted file mode 100644 index 44ed24a238..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedState.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RecoilState } from 'recoil'; - -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -export type RecoilScopedState = ( - scopedKey: RecoilComponentStateKey, -) => RecoilState; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopedStateDeprecated.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopedStateDeprecated.ts deleted file mode 100644 index db7a3cbd20..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopedStateDeprecated.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { RecoilScopedState } from '../types/RecoilScopedState'; - -export const getScopedStateDeprecated = ( - recoilScopedState: RecoilScopedState, - scopeId: string, -) => { - return recoilScopedState({ - scopeId, - }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSnapshotValue.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSnapshotValue.ts deleted file mode 100644 index 711d21a4ae..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSnapshotValue.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { RecoilState, RecoilValueReadOnly, Snapshot } from 'recoil'; - -export const getSnapshotValue = ( - snapshot: Snapshot, - state: RecoilState | RecoilValueReadOnly, -) => { - return snapshot.getLoadable(state).getValue(); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/guardRecoilDefaultValue.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/guardRecoilDefaultValue.ts deleted file mode 100644 index 8434960112..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/guardRecoilDefaultValue.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DefaultValue } from 'recoil'; - -export const guardRecoilDefaultValue = ( - candidate: any, -): candidate is DefaultValue => { - if (candidate instanceof DefaultValue) return true; - return false; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useExtractedComponentFamilyStateV2.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useExtractedComponentFamilyStateV2.ts deleted file mode 100644 index f5f05e49e5..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useExtractedComponentFamilyStateV2.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; -import { ComponentFamilyState } from '@/ui/utilities/state/component-state/types/ComponentFamilyState'; -import { SerializableParam } from 'recoil'; - -export const useExtractedComponentFamilyStateV2 = < - FamilyKey extends SerializableParam, - Value, ->( - componentFamilyState: ComponentFamilyState, - componentId?: string, -) => { - const componentContext = (window as any).componentContextStateMap?.get( - componentFamilyState.key, - ); - - if (!componentContext) { - throw new Error( - `Component context for key "${componentFamilyState.key}" is not defined`, - ); - } - - const internalScopeId = useAvailableScopeIdOrThrow( - componentContext, - componentId, - ); - - const extractedComponentFamilyState = (familyKey: FamilyKey) => - componentFamilyState.atomFamily({ - scopeId: internalScopeId, - familyKey, - }); - - return extractedComponentFamilyState; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyValue.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyValue.ts deleted file mode 100644 index 12654b0a5e..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyValue.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { SerializableParam, useRecoilValue } from 'recoil'; - -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; -import { ComponentFamilyState } from '@/ui/utilities/state/component-state/types/ComponentFamilyState'; - -export const useRecoilComponentFamilyValue = < - StateType, - FamilyKey extends SerializableParam, ->( - componentFamilyState: ComponentFamilyState, - familyKey: FamilyKey, - componentId?: string, -) => { - const componentContext = (window as any).componentContextStateMap?.get( - componentFamilyState.key, - ); - - if (!componentContext) { - throw new Error( - `Component context for key "${componentFamilyState.key}" is not defined`, - ); - } - - const internalComponentId = useAvailableScopeIdOrThrow( - componentContext, - componentId, - ); - - return useRecoilValue( - componentFamilyState.atomFamily({ - scopeId: internalComponentId, - familyKey, - }), - ); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentState.ts deleted file mode 100644 index 5c02f4df3d..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentState.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; -import { RecoilComponentState } from '@/ui/utilities/state/component-state/types/RecoilComponentState'; -import { useRecoilState } from 'recoil'; - -export const useRecoilComponentState = ( - componentState: RecoilComponentState, - componentId?: string, -) => { - const componentContext = (window as any).componentContextStateMap?.get( - componentState.key, - ); - - if (!componentContext) { - throw new Error( - `Component context for key "${componentState.key}" is not defined`, - ); - } - - const internalComponentId = useAvailableScopeIdOrThrow( - componentContext, - componentId, - ); - - return useRecoilState( - componentState.atomFamily({ scopeId: internalComponentId }), - ); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentValue.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentValue.ts deleted file mode 100644 index ed76e246dc..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useRecoilComponentValue.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { useRecoilValue } from 'recoil'; - -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; -import { RecoilComponentState } from '@/ui/utilities/state/component-state/types/RecoilComponentState'; - -export const useRecoilComponentValue = ( - componentState: RecoilComponentState, - componentId?: string, -) => { - const componentContext = (window as any).componentContextStateMap?.get( - componentState.key, - ); - - if (!componentContext) { - throw new Error( - `Component context for key "${componentState.key}" is not defined`, - ); - } - - const internalComponentId = useAvailableScopeIdOrThrow( - componentContext, - componentId, - ); - - return useRecoilValue( - componentState.atomFamily({ scopeId: internalComponentId }), - ); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useScopeIdFromStateContext.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useScopeIdFromStateContext.ts deleted file mode 100644 index fa30c4cd53..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useScopeIdFromStateContext.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { useScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContext'; -import { ComponentFamilyState } from '@/ui/utilities/state/component-state/types/ComponentFamilyState'; -import { RecoilComponentState } from '@/ui/utilities/state/component-state/types/RecoilComponentState'; - -export const useScopeIdFromStateContext = ( - componentState: RecoilComponentState | ComponentFamilyState, -) => { - const componentContext = (window as any).componentContextStateMap?.get( - componentState.key, - ); - - if (!componentContext) { - throw new Error( - `Component context for key "${componentState.key}" is not defined`, - ); - } - - const scopeInternalContext = useScopeInternalContext(componentContext); - - const scopeIdFromContext = scopeInternalContext?.scopeId; - - return { scopeId: scopeIdFromContext }; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useSetRecoilComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useSetRecoilComponentState.ts deleted file mode 100644 index c663801378..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/hooks/useSetRecoilComponentState.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { useSetRecoilState } from 'recoil'; - -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; -import { RecoilComponentState } from '@/ui/utilities/state/component-state/types/RecoilComponentState'; - -export const useSetRecoilComponentState = ( - componentState: RecoilComponentState, - componentId?: string, -) => { - const componentContext = (window as any).componentContextStateMap?.get( - componentState.key, - ); - - if (!componentContext) { - throw new Error( - `Component context for key "${componentState.key}" is not defined`, - ); - } - - const internalComponentId = useAvailableScopeIdOrThrow( - componentContext, - componentId, - ); - - return useSetRecoilState( - componentState.atomFamily({ scopeId: internalComponentId }), - ); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyState.ts deleted file mode 100644 index 1a4be07864..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyState.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { RecoilState, SerializableParam } from 'recoil'; - -import { ComponentFamilyStateKey } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKey'; - -export type ComponentFamilyState< - StateType, - FamilyKey extends SerializableParam, -> = { - key: string; - atomFamily: ( - componentStateKey: ComponentFamilyStateKey, - ) => RecoilState; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyStateKey.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyStateKey.ts deleted file mode 100644 index e5b9fa304a..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyStateKey.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { SerializableParam } from 'recoil'; - -export type ComponentFamilyStateKey = { - scopeId: string; - familyKey: FamilyKey; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/RecoilComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/RecoilComponentState.ts deleted file mode 100644 index 8c007e5bdd..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/RecoilComponentState.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { RecoilState } from 'recoil'; -import { RecoilComponentStateKey } from './RecoilComponentStateKey'; - -export type RecoilComponentState = { - key: string; - atomFamily: ( - componentStateKey: RecoilComponentStateKey, - ) => RecoilState; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/RecoilComponentStateKey.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/RecoilComponentStateKey.ts deleted file mode 100644 index 6627f39f92..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/RecoilComponentStateKey.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type RecoilComponentStateKey = { - scopeId: string; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilySelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilySelector.ts deleted file mode 100644 index af2c6c4271..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilySelector.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { selectorFamily, SerializableParam } from 'recoil'; - -import { ComponentFamilyStateKey } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKey'; -import { SelectorGetter } from '@/ui/utilities/state/types/SelectorGetter'; -import { SelectorSetter } from '@/ui/utilities/state/types/SelectorSetter'; - -export const createComponentFamilySelector = < - ValueType, - FamilyKey extends SerializableParam, ->({ - key, - get, - set, -}: { - key: string; - get: SelectorGetter>; - set: SelectorSetter>; -}) => { - return selectorFamily>({ - key, - get, - set, - }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilyState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilyState.ts deleted file mode 100644 index fea9894e1b..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilyState.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { atomFamily, SerializableParam } from 'recoil'; - -import { ComponentFamilyStateKey } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKey'; - -export const createComponentFamilyState = < - ValueType, - FamilyKey extends SerializableParam, ->({ - key, - defaultValue, -}: { - key: string; - defaultValue: ValueType; -}) => { - return atomFamily>({ - key, - default: defaultValue, - }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentReadOnlySelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentReadOnlySelector.ts deleted file mode 100644 index 5fa3378239..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentReadOnlySelector.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { selectorFamily } from 'recoil'; - -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; -import { SelectorGetter } from '@/ui/utilities/state/types/SelectorGetter'; - -export const createComponentReadOnlySelector = ({ - key, - get, -}: { - key: string; - get: SelectorGetter; -}) => { - return selectorFamily({ - key, - get, - }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentSelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentSelector.ts deleted file mode 100644 index 545845ccda..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentSelector.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { selectorFamily } from 'recoil'; - -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; -import { SelectorGetter } from '@/ui/utilities/state/types/SelectorGetter'; -import { SelectorSetter } from '@/ui/utilities/state/types/SelectorSetter'; - -export const createComponentSelector = ({ - key, - get, - set, -}: { - key: string; - get: SelectorGetter; - set: SelectorSetter; -}) => { - return selectorFamily({ - key, - get, - set, - }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentState.ts deleted file mode 100644 index 5f2cd0badc..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentState.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { AtomEffect, atomFamily } from 'recoil'; - -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -type CreateComponentStateType = { - key: string; - defaultValue: ValueType; - effects?: AtomEffect[]; -}; - -export const createComponentState = ({ - key, - defaultValue, - effects, -}: CreateComponentStateType) => { - return atomFamily({ - key, - default: defaultValue, - effects: effects, - }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentStateV2Alpha.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentStateV2Alpha.ts deleted file mode 100644 index 51c636c192..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentStateV2Alpha.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { AtomEffect, atomFamily } from 'recoil'; - -import { ScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopeInternalContext'; - -import { RecoilComponentState } from '@/ui/utilities/state/component-state/types/RecoilComponentState'; -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; -import { isDefined } from 'twenty-shared/utils'; - -type CreateComponentStateV2Type = { - key: string; - defaultValue: ValueType; - componentContext?: ScopeInternalContext | null; - effects?: AtomEffect[]; -}; - -export const createComponentStateV2_alpha = ({ - key, - defaultValue, - componentContext, - effects, -}: CreateComponentStateV2Type): RecoilComponentState => { - if (isDefined(componentContext)) { - if (!isDefined((window as any).componentContextStateMap)) { - (window as any).componentContextStateMap = new Map(); - } - - (window as any).componentContextStateMap.set(key, componentContext); - } - - return { - key, - atomFamily: atomFamily({ - key, - default: defaultValue, - effects: effects, - }), - }; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createEventContext.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createEventContext.ts deleted file mode 100644 index 723e1c3f3e..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createEventContext.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { createContext } from 'react'; - -export const createEventContext = < - Events extends Record void>, ->( - initialValue?: Events, -) => { - return createContext((initialValue ?? {}) as Events); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentFamilyState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentFamilyState.ts deleted file mode 100644 index 85ada7fd6c..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentFamilyState.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { RecoilState, SerializableParam } from 'recoil'; - -import { ComponentFamilyStateKey } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKey'; - -export const extractComponentFamilyState = < - StateType, - FamilyKey extends SerializableParam, ->( - componentfamilyState: ( - componentFamilyStateKey: ComponentFamilyStateKey, - ) => RecoilState, - scopeId: string, -) => { - return (familyKey: FamilyKey) => - componentfamilyState({ - scopeId, - familyKey: familyKey || ('' as FamilyKey), - }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector.ts deleted file mode 100644 index da5b494b6e..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { RecoilValueReadOnly } from 'recoil'; - -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -export const extractComponentReadOnlySelector = ( - componentSelector: ( - componentStateKey: RecoilComponentStateKey, - ) => RecoilValueReadOnly, - scopeId: string, -) => { - return () => componentSelector({ scopeId }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentSelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentSelector.ts deleted file mode 100644 index 40befcf6fe..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentSelector.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { RecoilState } from 'recoil'; - -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -export const extractComponentSelector = ( - componentSelector: ( - componentStateKey: RecoilComponentStateKey, - ) => RecoilState, - scopeId: string, -) => { - return () => componentSelector({ scopeId }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentState.ts deleted file mode 100644 index cac495c0c2..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentState.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { RecoilState } from 'recoil'; - -import { RecoilComponentStateKey } from '@/ui/utilities/state/component-state/types/RecoilComponentStateKey'; - -export const extractComponentState = ( - componentState: ( - componentStateKey: RecoilComponentStateKey, - ) => RecoilState, - scopeId: string, -) => { - return componentState({ scopeId }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/state/utils/guardRecoilDefaultValue.ts b/packages/twenty-front/src/modules/ui/utilities/state/utils/guardRecoilDefaultValue.ts deleted file mode 100644 index 8434960112..0000000000 --- a/packages/twenty-front/src/modules/ui/utilities/state/utils/guardRecoilDefaultValue.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DefaultValue } from 'recoil'; - -export const guardRecoilDefaultValue = ( - candidate: any, -): candidate is DefaultValue => { - if (candidate instanceof DefaultValue) return true; - return false; -}; diff --git a/packages/twenty-front/src/modules/views/components/ViewBarDetails.tsx b/packages/twenty-front/src/modules/views/components/ViewBarDetails.tsx index 97475f9f4d..d3e70d602d 100644 --- a/packages/twenty-front/src/modules/views/components/ViewBarDetails.tsx +++ b/packages/twenty-front/src/modules/views/components/ViewBarDetails.tsx @@ -4,7 +4,6 @@ import { ReactNode, useMemo } from 'react'; import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObjectNameSingularFromPlural'; import { ObjectFilterDropdownComponentInstanceContext } from '@/object-record/object-filter-dropdown/states/contexts/ObjectFilterDropdownComponentInstanceContext'; import { useHandleToggleTrashColumnFilter } from '@/object-record/record-index/hooks/useHandleToggleTrashColumnFilter'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; import { AdvancedFilterDropdownButton } from '@/views/components/AdvancedFilterDropdownButton'; import { EditableFilterDropdownButton } from '@/views/components/EditableFilterDropdownButton'; @@ -256,9 +255,7 @@ export const ViewBarDetails = ({ key={recordFilter.id} value={{ instanceId: recordFilter.id }} > - - - + ))} diff --git a/packages/twenty-front/src/modules/views/hooks/useCreateViewFromCurrentView.ts b/packages/twenty-front/src/modules/views/hooks/useCreateViewFromCurrentView.ts index e5b851914c..499df805bc 100644 --- a/packages/twenty-front/src/modules/views/hooks/useCreateViewFromCurrentView.ts +++ b/packages/twenty-front/src/modules/views/hooks/useCreateViewFromCurrentView.ts @@ -8,9 +8,9 @@ import { currentRecordFiltersComponentState } from '@/object-record/record-filte import { useRecordIndexContextOrThrow } from '@/object-record/record-index/contexts/RecordIndexContext'; import { currentRecordSortsComponentState } from '@/object-record/record-sort/states/currentRecordSortsComponentState'; import { prefetchViewFromViewIdFamilySelector } from '@/prefetch/states/selector/prefetchViewFromViewIdFamilySelector'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { usePersistViewFieldRecords } from '@/views/hooks/internal/usePersistViewFieldRecords'; import { usePersistViewFilterGroupRecords } from '@/views/hooks/internal/usePersistViewFilterGroupRecords'; import { usePersistViewFilterRecords } from '@/views/hooks/internal/usePersistViewFilterRecords'; diff --git a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerFavoriteFoldersDropdown.tsx b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerFavoriteFoldersDropdown.tsx index 587b3008b0..b1590de2b5 100644 --- a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerFavoriteFoldersDropdown.tsx +++ b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerFavoriteFoldersDropdown.tsx @@ -1,8 +1,7 @@ import { FavoriteFolderPicker } from '@/favorites/favorite-folder-picker/components/FavoriteFolderPicker'; import { FavoriteFolderPickerEffect } from '@/favorites/favorite-folder-picker/components/FavoriteFolderPickerEffect'; -import { FavoriteFolderPickerComponentInstanceContext } from '@/favorites/favorite-folder-picker/scopes/FavoriteFolderPickerScope'; +import { FavoriteFolderPickerInstanceContext } from '@/favorites/favorite-folder-picker/states/context/FavoriteFolderPickerInstanceContext'; import { prefetchViewFromViewIdFamilySelector } from '@/prefetch/states/selector/prefetchViewFromViewIdFamilySelector'; -import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope'; import { useRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentStateV2'; import { VIEW_PICKER_DROPDOWN_ID } from '@/views/view-picker/constants/ViewPickerDropdownId'; import { viewPickerReferenceViewIdComponentState } from '@/views/view-picker/states/viewPickerReferenceViewIdComponentState'; @@ -20,19 +19,15 @@ export const ViewPickerFavoriteFoldersDropdown = () => { ); return ( - - - <> - - - - - + + + ); }; diff --git a/packages/twenty-front/src/modules/views/view-picker/hooks/useCreateViewFromCurrentState.ts b/packages/twenty-front/src/modules/views/view-picker/hooks/useCreateViewFromCurrentState.ts index edd8421e54..e63ce88a6d 100644 --- a/packages/twenty-front/src/modules/views/view-picker/hooks/useCreateViewFromCurrentState.ts +++ b/packages/twenty-front/src/modules/views/view-picker/hooks/useCreateViewFromCurrentState.ts @@ -1,5 +1,5 @@ -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { useChangeView } from '@/views/hooks/useChangeView'; import { useCreateViewFromCurrentView } from '@/views/hooks/useCreateViewFromCurrentView'; import { useCloseAndResetViewPicker } from '@/views/view-picker/hooks/useCloseAndResetViewPicker'; diff --git a/packages/twenty-front/src/modules/views/view-picker/hooks/useDeleteViewFromCurrentState.ts b/packages/twenty-front/src/modules/views/view-picker/hooks/useDeleteViewFromCurrentState.ts index f6fad860d4..c8d0d80e6b 100644 --- a/packages/twenty-front/src/modules/views/view-picker/hooks/useDeleteViewFromCurrentState.ts +++ b/packages/twenty-front/src/modules/views/view-picker/hooks/useDeleteViewFromCurrentState.ts @@ -2,8 +2,8 @@ import { useRecoilCallback, useRecoilValue } from 'recoil'; import { useContextStoreObjectMetadataItemOrThrow } from '@/context-store/hooks/useContextStoreObjectMetadataItemOrThrow'; import { prefetchViewsFromObjectMetadataItemFamilySelector } from '@/prefetch/states/selector/prefetchViewsFromObjectMetadataItemFamilySelector'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { useChangeView } from '@/views/hooks/useChangeView'; import { useDeleteView } from '@/views/hooks/useDeleteView'; import { useGetCurrentViewOnly } from '@/views/hooks/useGetCurrentViewOnly'; diff --git a/packages/twenty-front/src/modules/views/view-picker/hooks/useUpdateViewFromCurrentState.ts b/packages/twenty-front/src/modules/views/view-picker/hooks/useUpdateViewFromCurrentState.ts index 9af68933cc..8ecdbcec4b 100644 --- a/packages/twenty-front/src/modules/views/view-picker/hooks/useUpdateViewFromCurrentState.ts +++ b/packages/twenty-front/src/modules/views/view-picker/hooks/useUpdateViewFromCurrentState.ts @@ -1,5 +1,5 @@ -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { useChangeView } from '@/views/hooks/useChangeView'; import { useUpdateView } from '@/views/hooks/useUpdateView'; import { useCloseAndResetViewPicker } from '@/views/view-picker/hooks/useCloseAndResetViewPicker'; diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramCanvasBase.tsx b/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramCanvasBase.tsx index fc42b7912e..d2d22cac73 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramCanvasBase.tsx +++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramCanvasBase.tsx @@ -1,10 +1,10 @@ import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext'; import { CommandMenuAnimationVariant } from '@/command-menu/types/CommandMenuAnimationVariant'; import { useListenToSidePanelClosing } from '@/ui/layout/right-drawer/hooks/useListenToSidePanelClosing'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { WorkflowDiagramCustomMarkers } from '@/workflow/workflow-diagram/components/WorkflowDiagramCustomMarkers'; import { useRightDrawerState } from '@/workflow/workflow-diagram/hooks/useRightDrawerState'; import { workflowDiagramComponentState } from '@/workflow/workflow-diagram/states/workflowDiagramComponentState'; diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowRunVisualizerEffect.tsx b/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowRunVisualizerEffect.tsx index 91516e265e..64d200f2f9 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowRunVisualizerEffect.tsx +++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowRunVisualizerEffect.tsx @@ -1,8 +1,8 @@ import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext'; import { useWorkflowCommandMenu } from '@/command-menu/hooks/useWorkflowCommandMenu'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { useStepsOutputSchema } from '@/workflow/hooks/useStepsOutputSchema'; import { useWorkflowRun } from '@/workflow/hooks/useWorkflowRun'; import { useWorkflowVersion } from '@/workflow/hooks/useWorkflowVersion'; diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/hooks/useHandleWorkflowRunDiagramCanvasInit.ts b/packages/twenty-front/src/modules/workflow/workflow-diagram/hooks/useHandleWorkflowRunDiagramCanvasInit.ts index a2a07e58d9..9953163e10 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-diagram/hooks/useHandleWorkflowRunDiagramCanvasInit.ts +++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/hooks/useHandleWorkflowRunDiagramCanvasInit.ts @@ -1,7 +1,7 @@ import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext'; import { useWorkflowCommandMenu } from '@/command-menu/hooks/useWorkflowCommandMenu'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { useWorkflowRunIdOrThrow } from '@/workflow/hooks/useWorkflowRunIdOrThrow'; import { workflowVisualizerWorkflowIdComponentState } from '@/workflow/states/workflowVisualizerWorkflowIdComponentState'; import { workflowDiagramStatusComponentState } from '@/workflow/workflow-diagram/states/workflowDiagramStatusComponentState'; diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useRemoveStepFilter.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useRemoveStepFilter.ts index bf8ed32381..416e559af7 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useRemoveStepFilter.ts +++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useRemoveStepFilter.ts @@ -1,5 +1,5 @@ -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { currentStepFilterGroupsComponentState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/currentStepFilterGroupsComponentState'; import { currentStepFiltersComponentState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/currentStepFiltersComponentState'; import { useContext } from 'react'; diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useRemoveStepFilterGroup.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useRemoveStepFilterGroup.ts index c2990ca398..6bf1288fe2 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useRemoveStepFilterGroup.ts +++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useRemoveStepFilterGroup.ts @@ -1,5 +1,5 @@ -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { WorkflowStepFilterContext } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/context/WorkflowStepFilterContext'; import { currentStepFilterGroupsComponentState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/currentStepFilterGroupsComponentState'; import { currentStepFiltersComponentState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/currentStepFiltersComponentState'; diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useUpsertStepFilterSettings.ts b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useUpsertStepFilterSettings.ts index c62877250d..cead117126 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useUpsertStepFilterSettings.ts +++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/hooks/useUpsertStepFilterSettings.ts @@ -1,5 +1,5 @@ -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { WorkflowStepFilterContext } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/context/WorkflowStepFilterContext'; import { currentStepFilterGroupsComponentState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/currentStepFilterGroupsComponentState'; import { currentStepFiltersComponentState } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/currentStepFiltersComponentState'; diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/find-records-action/components/WorkflowFindRecordsFilters.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/find-records-action/components/WorkflowFindRecordsFilters.tsx index fe8e866288..f620989e09 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/find-records-action/components/WorkflowFindRecordsFilters.tsx +++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/find-records-action/components/WorkflowFindRecordsFilters.tsx @@ -8,9 +8,9 @@ import { isRecordFilterGroupChildARecordFilterGroup } from '@/object-record/adva import { currentRecordFilterGroupsComponentState } from '@/object-record/record-filter-group/states/currentRecordFilterGroupsComponentState'; import { currentRecordFiltersComponentState } from '@/object-record/record-filter/states/currentRecordFiltersComponentState'; import { computeRecordGqlOperationFilter } from '@/object-record/record-filter/utils/computeRecordGqlOperationFilter'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; +import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue'; import { WorkflowAdvancedFilterRecordFilterColumn } from '@/workflow/workflow-steps/workflow-actions/find-records-action/components/WorkflowAdvancedFilterRecordFilterColumn'; import { WorkflowAdvancedFilterRecordFilterGroupColumn } from '@/workflow/workflow-steps/workflow-actions/find-records-action/components/WorkflowAdvancedFilterRecordFilterGroupColumn'; import { FindRecordsActionFilter } from '@/workflow/workflow-steps/workflow-actions/find-records-action/components/WorkflowEditActionFindRecords'; diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx index 4d7f24058d..c88b25a363 100644 --- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx +++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjects.tsx @@ -235,7 +235,7 @@ export const SettingsObjects = () => { isCustomObject={ objectSettingsItem.objectMetadataItem.isCustom } - scopeKey={ + objectMetadataItemNamePlural={ objectSettingsItem.objectMetadataItem.namePlural } onActivate={() => diff --git a/packages/twenty-front/src/testing/decorators/ComponentWithRecoilScopeDecorator.tsx b/packages/twenty-front/src/testing/decorators/ComponentWithRecoilScopeDecorator.tsx deleted file mode 100644 index 86b59fd04d..0000000000 --- a/packages/twenty-front/src/testing/decorators/ComponentWithRecoilScopeDecorator.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { Decorator } from '@storybook/react'; - -import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope'; - -export const ComponentWithRecoilScopeDecorator: Decorator = ( - Story, - context, -) => ( - - - -); diff --git a/packages/twenty-front/src/testing/decorators/PageDecorator.tsx b/packages/twenty-front/src/testing/decorators/PageDecorator.tsx index 7ae2dbeed4..51df56e591 100644 --- a/packages/twenty-front/src/testing/decorators/PageDecorator.tsx +++ b/packages/twenty-front/src/testing/decorators/PageDecorator.tsx @@ -13,7 +13,7 @@ import { RecoilRoot } from 'recoil'; import { ClientConfigProviderEffect } from '@/client-config/components/ClientConfigProviderEffect'; import { ApolloCoreClientMockedProvider } from '@/object-metadata/hooks/__mocks__/ApolloCoreClientMockedProvider'; -import { SnackBarComponentInstanceContextProvider } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider'; + import { DefaultLayout } from '@/ui/layout/page/components/DefaultLayout'; import { UserProviderEffect } from '@/users/components/UserProviderEffect'; import { ClientConfigProvider } from '~/modules/client-config/components/ClientConfigProvider'; @@ -28,6 +28,7 @@ import { RecordFilterGroupsComponentInstanceContext } from '@/object-record/reco import { RecordFiltersComponentInstanceContext } from '@/object-record/record-filter/states/context/RecordFiltersComponentInstanceContext'; import { RecordSortsComponentInstanceContext } from '@/object-record/record-sort/states/context/RecordSortsComponentInstanceContext'; import { PrefetchDataProvider } from '@/prefetch/components/PrefetchDataProvider'; +import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; import { WorkspaceProviderEffect } from '@/workspace/components/WorkspaceProviderEffect'; import { i18n } from '@lingui/core'; import { I18nProvider } from '@lingui/react'; @@ -77,7 +78,9 @@ await dynamicActivate(SOURCE_LOCALE); const Providers = () => { return ( - + @@ -125,7 +128,7 @@ const Providers = () => { - + ); }; diff --git a/packages/twenty-front/src/testing/decorators/SnackBarDecorator.tsx b/packages/twenty-front/src/testing/decorators/SnackBarDecorator.tsx index 6e89147dc3..d6e3b906d7 100644 --- a/packages/twenty-front/src/testing/decorators/SnackBarDecorator.tsx +++ b/packages/twenty-front/src/testing/decorators/SnackBarDecorator.tsx @@ -1,9 +1,10 @@ +import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; import { Decorator } from '@storybook/react'; -import { SnackBarComponentInstanceContextProvider } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider'; - export const SnackBarDecorator: Decorator = (Story) => ( - + - + ); diff --git a/packages/twenty-front/src/testing/jest/getJestMetadataAndApolloMocksWrapper.tsx b/packages/twenty-front/src/testing/jest/getJestMetadataAndApolloMocksWrapper.tsx index 94520d5c18..21f454ee35 100644 --- a/packages/twenty-front/src/testing/jest/getJestMetadataAndApolloMocksWrapper.tsx +++ b/packages/twenty-front/src/testing/jest/getJestMetadataAndApolloMocksWrapper.tsx @@ -6,7 +6,8 @@ import { ContextStoreComponentInstanceContext } from '@/context-store/states/con import { RecordFilterGroupsComponentInstanceContext } from '@/object-record/record-filter-group/states/context/RecordFilterGroupsComponentInstanceContext'; import { RecordFiltersComponentInstanceContext } from '@/object-record/record-filter/states/context/RecordFiltersComponentInstanceContext'; import { RecordSortsComponentInstanceContext } from '@/object-record/record-sort/states/context/RecordSortsComponentInstanceContext'; -import { SnackBarComponentInstanceContextProvider } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarComponentInstanceContextProvider'; + +import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext'; import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewComponentInstanceContext'; import { InMemoryCache } from '@apollo/client'; import { JestContextStoreSetter } from '~/testing/jest/JestContextStoreSetter'; @@ -25,7 +26,9 @@ export const getJestMetadataAndApolloMocksWrapper = ({ }) => { return ({ children }: { children: ReactNode }) => ( - + - + ); }; diff --git a/packages/twenty-front/src/types/ScopeContextProps.ts b/packages/twenty-front/src/types/ScopeContextProps.ts deleted file mode 100644 index dcb49f3c95..0000000000 --- a/packages/twenty-front/src/types/ScopeContextProps.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type ScopeContextProps = { - scopeId: string; -} & T; diff --git a/packages/twenty-website/src/content/twenty-ui/input/select.mdx b/packages/twenty-website/src/content/twenty-ui/input/select.mdx index 05bfe171be..48375c7c15 100644 --- a/packages/twenty-website/src/content/twenty-ui/input/select.mdx +++ b/packages/twenty-website/src/content/twenty-ui/input/select.mdx @@ -21,7 +21,6 @@ export const MyComponent = () => {