Action menu refactoring (#11454)
# Description Closes [#696](https://github.com/twentyhq/core-team-issues/issues/696) - `useAction` hooks have been removed for all actions - Every action can now declare a react component - Some standard action components have been introduced: `Action`, `ActionLink` and `ActionModal` - The `ActionDisplay` component uses the new `displayType` prop of the `ActionMenuContext` to render the right component for the action according to its container: `ActionButton`, `ActionDropdownItem` or `ActionListItem` - The `ActionDisplayer` wraps the action component inside a context which gives it all the information about the action -`actionMenuEntriesComponenState` has been removed and now all actions are computed directly using `useRegisteredAction` - This computation is done inside `ActionMenuContextProvider` and the actions are passed inside a context - `actionMenuType` gives information about the container of the action, so the action can know wether or not to close this container upon execution
This commit is contained in:
@ -4,7 +4,6 @@ import { useContext, useRef } from 'react';
|
||||
import { useRecoilCallback, useSetRecoilState } from 'recoil';
|
||||
import { Key } from 'ts-key-enum';
|
||||
|
||||
import { ActionBarHotkeyScope } from '@/action-menu/types/ActionBarHotKeyScope';
|
||||
import { getActionMenuIdFromRecordIndexId } from '@/action-menu/utils/getActionMenuIdFromRecordIndexId';
|
||||
import { RecordBoardHeader } from '@/object-record/record-board/components/RecordBoardHeader';
|
||||
import { RecordBoardStickyHeaderEffect } from '@/object-record/record-board/components/RecordBoardStickyHeaderEffect';
|
||||
@ -136,13 +135,8 @@ export const RecordBoard = () => {
|
||||
);
|
||||
|
||||
useScopedHotkeys('ctrl+a,meta+a', selectAll, TableHotkeyScope.Table);
|
||||
useScopedHotkeys('ctrl+a,meta+a', selectAll, ActionBarHotkeyScope.ActionBar);
|
||||
|
||||
useScopedHotkeys(
|
||||
Key.Escape,
|
||||
resetRecordSelection,
|
||||
ActionBarHotkeyScope.ActionBar,
|
||||
);
|
||||
useScopedHotkeys(Key.Escape, resetRecordSelection, TableHotkeyScope.Table);
|
||||
|
||||
const setIsRemoveSortingModalOpen = useSetRecoilState(
|
||||
isRemoveSortingModalOpenState,
|
||||
|
||||
@ -44,8 +44,6 @@ export const RecordIndexPageHeader = () => {
|
||||
const { getIcon } = useIcons();
|
||||
const Icon = getIcon(objectMetadataItem?.icon);
|
||||
|
||||
const { recordIndexId } = useRecordIndexContextOrThrow();
|
||||
|
||||
const label = objectMetadataItem?.labelPlural ?? capitalize(objectNamePlural);
|
||||
|
||||
const pageHeaderTitle =
|
||||
@ -70,7 +68,7 @@ export const RecordIndexPageHeader = () => {
|
||||
<PageHeader title={pageHeaderTitle} Icon={Icon}>
|
||||
{isDefined(contextStoreCurrentViewId) && (
|
||||
<>
|
||||
<RecordIndexActionMenu indexId={recordIndexId} />
|
||||
<RecordIndexActionMenu />
|
||||
<PageHeaderToggleCommandMenuButton />
|
||||
</>
|
||||
)}
|
||||
|
||||
@ -9,8 +9,8 @@ import { lastShowPageRecordIdState } from '@/object-record/record-field/states/l
|
||||
import { useRecordIdsFromFindManyCacheRootQuery } from '@/object-record/record-show/hooks/useRecordIdsFromFindManyCacheRootQuery';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { useQueryVariablesFromActiveFieldsOfViewOrDefaultView } from '@/views/hooks/useQueryVariablesFromActiveFieldsOfViewOrDefaultView';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
|
||||
export const useRecordShowPagePagination = (
|
||||
propsObjectNameSingular: string,
|
||||
|
||||
@ -13,7 +13,6 @@ import { mapColumnDefinitionsToViewFields } from '@/views/utils/mapColumnDefinit
|
||||
import { RecordUpdateContext } from '../contexts/EntityUpdateMutationHookContext';
|
||||
import { useRecordTable } from '../hooks/useRecordTable';
|
||||
|
||||
import { ActionBarHotkeyScope } from '@/action-menu/types/ActionBarHotKeyScope';
|
||||
import { RecordTableComponentInstance } from '@/object-record/record-table/components/RecordTableComponentInstance';
|
||||
import { RecordTableContextProvider } from '@/object-record/record-table/components/RecordTableContextProvider';
|
||||
import { TableHotkeyScope } from '@/object-record/record-table/types/TableHotkeyScope';
|
||||
@ -55,17 +54,8 @@ export const RecordTableWithWrappers = ({
|
||||
handleSelectAllRows,
|
||||
TableHotkeyScope.Table,
|
||||
);
|
||||
useScopedHotkeys(
|
||||
'ctrl+a,meta+a',
|
||||
handleSelectAllRows,
|
||||
ActionBarHotkeyScope.ActionBar,
|
||||
);
|
||||
|
||||
useScopedHotkeys(
|
||||
Key.Escape,
|
||||
resetTableRowSelection,
|
||||
ActionBarHotkeyScope.ActionBar,
|
||||
);
|
||||
useScopedHotkeys(Key.Escape, resetTableRowSelection, TableHotkeyScope.Table);
|
||||
|
||||
const { saveViewFields } = useSaveCurrentViewFields();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user