Refactor actions (#8761)
Closes #8737 - Refactored actions by creating hooks to add the possibility to register actions programatically. - Small fixes from #8610 review - Fixed shortcuts display inside the command menu - Removed `actionMenuEntriesComponentState` and introduced `actionMenuEntriesComponentSelector`
This commit is contained in:
@ -0,0 +1,23 @@
|
||||
import { actionMenuEntriesComponentSelector } from '@/action-menu/states/actionMenuEntriesComponentSelector';
|
||||
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
||||
import { Command } from '@/command-menu/types/Command';
|
||||
import { computeCommandMenuCommands } from '@/command-menu/utils/computeCommandMenuCommands';
|
||||
import { createComponentSelectorV2 } from '@/ui/utilities/state/component-state/utils/createComponentSelectorV2';
|
||||
|
||||
export const commandMenuCommandsComponentSelector = createComponentSelectorV2<
|
||||
Command[]
|
||||
>({
|
||||
key: 'commandMenuCommandsComponentSelector',
|
||||
componentInstanceContext: ActionMenuComponentInstanceContext,
|
||||
get:
|
||||
({ instanceId }) =>
|
||||
({ get }) => {
|
||||
const actionMenuEntries = get(
|
||||
actionMenuEntriesComponentSelector.selectorFamily({
|
||||
instanceId,
|
||||
}),
|
||||
);
|
||||
|
||||
return computeCommandMenuCommands(actionMenuEntries);
|
||||
},
|
||||
});
|
||||
@ -1,15 +0,0 @@
|
||||
import { createState } from 'twenty-ui';
|
||||
|
||||
import { Command, CommandType } from '../types/Command';
|
||||
|
||||
export const commandMenuCommandsState = createState<Command[]>({
|
||||
key: 'command-menu/commandMenuCommandsState',
|
||||
defaultValue: [
|
||||
{
|
||||
id: '',
|
||||
to: '',
|
||||
label: '',
|
||||
type: CommandType.Navigate,
|
||||
},
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user