This PR removes any V2 naming in state management logic and some minor utils and hooks. It has a lot of changes but nearly all of them were made by the rename functionality of vscode which is deterministic, so it shouldn't introduce any regression. QA has been made on this PR on the main features of the app without any noticeable issue. Also renamed some other v2 naming related items : - TextInputV2 => TextInput - TextInput => SettingsTextInput - ObjectFilterDropdownFilterSelectMenuItemV2 => ObjectFilterDropdownFilterSelectMenuItem - useInitDraftValueV2 => useInitDraftValue - useOpenRecordTableCellV2 => useOpenRecordTableCell
85 lines
4.0 KiB
TypeScript
85 lines
4.0 KiB
TypeScript
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
|
import { CommandMenuOpenContainer } from '@/command-menu/components/CommandMenuOpenContainer';
|
|
import { COMMAND_MENU_COMPONENT_INSTANCE_ID } from '@/command-menu/constants/CommandMenuComponentInstanceId';
|
|
import { useCommandMenuCloseAnimationCompleteCleanup } from '@/command-menu/hooks/useCommandMenuCloseAnimationCompleteCleanup';
|
|
import { useCommandMenuHotKeys } from '@/command-menu/hooks/useCommandMenuHotKeys';
|
|
import { isCommandMenuOpenedState } from '@/command-menu/states/isCommandMenuOpenedState';
|
|
import { contextStoreCurrentObjectMetadataItemIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataItemIdComponentState';
|
|
import { contextStoreCurrentViewIdComponentState } from '@/context-store/states/contextStoreCurrentViewIdComponentState';
|
|
import { ContextStoreComponentInstanceContext } from '@/context-store/states/contexts/ContextStoreComponentInstanceContext';
|
|
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
|
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 { getRecordIndexIdFromObjectNamePluralAndViewId } from '@/object-record/utils/getRecordIndexIdFromObjectNamePluralAndViewId';
|
|
import { useRecoilComponentValue } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValue';
|
|
import { AnimatePresence } from 'framer-motion';
|
|
import { useRecoilValue } from 'recoil';
|
|
|
|
export const CommandMenuContainer = ({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) => {
|
|
const { commandMenuCloseAnimationCompleteCleanup } =
|
|
useCommandMenuCloseAnimationCompleteCleanup();
|
|
|
|
const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState);
|
|
|
|
const objectMetadataItemId = useRecoilComponentValue(
|
|
contextStoreCurrentObjectMetadataItemIdComponentState,
|
|
COMMAND_MENU_COMPONENT_INSTANCE_ID,
|
|
);
|
|
|
|
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
|
|
|
|
const objectMetadataItem = objectMetadataItems.find(
|
|
(objectMetadataItem) => objectMetadataItem.id === objectMetadataItemId,
|
|
);
|
|
|
|
const currentViewId = useRecoilComponentValue(
|
|
contextStoreCurrentViewIdComponentState,
|
|
COMMAND_MENU_COMPONENT_INSTANCE_ID,
|
|
);
|
|
|
|
const recordIndexId = getRecordIndexIdFromObjectNamePluralAndViewId(
|
|
objectMetadataItem?.namePlural ?? '',
|
|
currentViewId ?? '',
|
|
);
|
|
|
|
useCommandMenuHotKeys();
|
|
|
|
return (
|
|
<RecordFilterGroupsComponentInstanceContext.Provider
|
|
value={{ instanceId: recordIndexId }}
|
|
>
|
|
<RecordFiltersComponentInstanceContext.Provider
|
|
value={{ instanceId: recordIndexId }}
|
|
>
|
|
<RecordSortsComponentInstanceContext.Provider
|
|
value={{ instanceId: recordIndexId }}
|
|
>
|
|
<ContextStoreComponentInstanceContext.Provider
|
|
value={{ instanceId: COMMAND_MENU_COMPONENT_INSTANCE_ID }}
|
|
>
|
|
<ActionMenuComponentInstanceContext.Provider
|
|
value={{ instanceId: COMMAND_MENU_COMPONENT_INSTANCE_ID }}
|
|
>
|
|
<AnimatePresence
|
|
mode="wait"
|
|
onExitComplete={commandMenuCloseAnimationCompleteCleanup}
|
|
>
|
|
{isCommandMenuOpened && (
|
|
<CommandMenuOpenContainer>
|
|
{children}
|
|
</CommandMenuOpenContainer>
|
|
)}
|
|
</AnimatePresence>
|
|
</ActionMenuComponentInstanceContext.Provider>
|
|
</ContextStoreComponentInstanceContext.Provider>
|
|
</RecordSortsComponentInstanceContext.Provider>
|
|
</RecordFiltersComponentInstanceContext.Provider>
|
|
</RecordFilterGroupsComponentInstanceContext.Provider>
|
|
);
|
|
};
|