685 Move all navigation actions inside the actions configs (#11303)
Move all navigation actions inside the actions configs
This commit is contained in:
@ -21,6 +21,7 @@ import { commandMenuNavigationStackState } from '@/command-menu/states/commandMe
|
||||
import { isCommandMenuOpenedState } from '@/command-menu/states/isCommandMenuOpenedState';
|
||||
import { CommandMenuPages } from '@/command-menu/types/CommandMenuPages';
|
||||
import { ContextStoreComponentInstanceContext } from '@/context-store/states/contexts/ContextStoreComponentInstanceContext';
|
||||
import { ContextStoreViewType } from '@/context-store/types/ContextStoreViewType';
|
||||
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';
|
||||
@ -49,7 +50,11 @@ const ContextStoreDecorator: Decorator = (Story) => {
|
||||
<ActionMenuComponentInstanceContext.Provider
|
||||
value={{ instanceId: COMMAND_MENU_COMPONENT_INSTANCE_ID }}
|
||||
>
|
||||
<JestContextStoreSetter contextStoreCurrentObjectMetadataNameSingular="company">
|
||||
<JestContextStoreSetter
|
||||
contextStoreCurrentObjectMetadataNameSingular="company"
|
||||
contextStoreCurrentViewId="1"
|
||||
contextStoreCurrentViewType={ContextStoreViewType.Table}
|
||||
>
|
||||
<Story />
|
||||
</JestContextStoreSetter>
|
||||
</ActionMenuComponentInstanceContext.Provider>
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
import {
|
||||
IconBuildingSkyscraper,
|
||||
IconCheckbox,
|
||||
IconSettings,
|
||||
IconTargetArrow,
|
||||
IconUser,
|
||||
} from 'twenty-ui';
|
||||
|
||||
import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { getAppPath } from '~/utils/navigation/getAppPath';
|
||||
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||
import { Command, CommandType } from '../types/Command';
|
||||
|
||||
export const COMMAND_MENU_NAVIGATE_COMMANDS: { [key: string]: Command } = {
|
||||
people: {
|
||||
id: 'go-to-people',
|
||||
to: getAppPath(AppPath.RecordIndexPage, {
|
||||
objectNamePlural: CoreObjectNamePlural.Person,
|
||||
}),
|
||||
label: 'Go to People',
|
||||
type: CommandType.Navigate,
|
||||
hotKeys: ['G', 'P'],
|
||||
Icon: IconUser,
|
||||
shouldCloseCommandMenuOnClick: true,
|
||||
},
|
||||
companies: {
|
||||
id: 'go-to-companies',
|
||||
to: getAppPath(AppPath.RecordIndexPage, {
|
||||
objectNamePlural: CoreObjectNamePlural.Company,
|
||||
}),
|
||||
label: 'Go to Companies',
|
||||
type: CommandType.Navigate,
|
||||
hotKeys: ['G', 'C'],
|
||||
Icon: IconBuildingSkyscraper,
|
||||
shouldCloseCommandMenuOnClick: true,
|
||||
},
|
||||
opportunities: {
|
||||
id: 'go-to-activities',
|
||||
to: getAppPath(AppPath.RecordIndexPage, {
|
||||
objectNamePlural: CoreObjectNamePlural.Opportunity,
|
||||
}),
|
||||
label: 'Go to Opportunities',
|
||||
type: CommandType.Navigate,
|
||||
hotKeys: ['G', 'O'],
|
||||
Icon: IconTargetArrow,
|
||||
shouldCloseCommandMenuOnClick: true,
|
||||
},
|
||||
settings: {
|
||||
id: 'go-to-settings',
|
||||
to: getSettingsPath(SettingsPath.ProfilePage),
|
||||
label: 'Go to Settings',
|
||||
type: CommandType.Navigate,
|
||||
hotKeys: ['G', 'S'],
|
||||
Icon: IconSettings,
|
||||
shouldCloseCommandMenuOnClick: true,
|
||||
},
|
||||
tasks: {
|
||||
id: 'go-to-tasks',
|
||||
to: getAppPath(AppPath.RecordIndexPage, {
|
||||
objectNamePlural: CoreObjectNamePlural.Task,
|
||||
}),
|
||||
label: 'Go to Tasks',
|
||||
type: CommandType.Navigate,
|
||||
hotKeys: ['G', 'T'],
|
||||
Icon: IconCheckbox,
|
||||
shouldCloseCommandMenuOnClick: true,
|
||||
},
|
||||
};
|
||||
@ -3,7 +3,6 @@ import {
|
||||
ActionMenuEntryScope,
|
||||
ActionMenuEntryType,
|
||||
} from '@/action-menu/types/ActionMenuEntry';
|
||||
import { COMMAND_MENU_NAVIGATE_COMMANDS } from '@/command-menu/constants/CommandMenuNavigateCommands';
|
||||
import {
|
||||
Command,
|
||||
CommandScope,
|
||||
@ -32,14 +31,6 @@ export const useCommandMenuCommands = () => {
|
||||
hotKeys: actionMenuEntry.hotKeys,
|
||||
})) as Command[];
|
||||
|
||||
// TODO: refactor this to use the config
|
||||
const navigateCommandsFromConstants = Object.values(
|
||||
COMMAND_MENU_NAVIGATE_COMMANDS,
|
||||
);
|
||||
const allNavigateCommands = navigateCommands.concat(
|
||||
navigateCommandsFromConstants,
|
||||
);
|
||||
|
||||
const actionRecordSelectionCommands: Command[] = actionMenuEntries
|
||||
?.filter(
|
||||
(actionMenuEntry) =>
|
||||
@ -136,7 +127,7 @@ export const useCommandMenuCommands = () => {
|
||||
}));
|
||||
|
||||
return {
|
||||
navigateCommands: allNavigateCommands,
|
||||
navigateCommands,
|
||||
actionRecordSelectionCommands,
|
||||
actionGlobalCommands,
|
||||
actionObjectCommands,
|
||||
|
||||
Reference in New Issue
Block a user