Files
twenty/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuActions.tsx
T
Félix Malfait 464a480043 Continue ESLINT9 Migration (#13795)
Might already fix #13793
2025-08-10 23:25:58 +02:00

65 lines
2.0 KiB
TypeScript

import { type ActionConfig } from '@/action-menu/actions/types/ActionConfig';
import { ActionScope } from '@/action-menu/actions/types/ActionScope';
import { ActionType } from '@/action-menu/actions/types/ActionType';
import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext';
import { useContext } from 'react';
export const useCommandMenuActions = () => {
const { actions } = useContext(ActionMenuContext);
const navigateActions = actions?.filter(
(action) => action.type === ActionType.Navigation,
);
const actionRecordSelectionActions: ActionConfig[] = actions?.filter(
(action) =>
action.type === ActionType.Standard &&
action.scope === ActionScope.RecordSelection,
);
const actionObjectActions: ActionConfig[] = actions?.filter(
(action) =>
action.type === ActionType.Standard &&
action.scope === ActionScope.Object,
);
const actionGlobalActions: ActionConfig[] = actions?.filter(
(action) =>
action.type === ActionType.Standard &&
action.scope === ActionScope.Global,
);
const workflowRunRecordSelectionActions: ActionConfig[] = actions?.filter(
(action) =>
action.type === ActionType.WorkflowRun &&
action.scope === ActionScope.RecordSelection,
);
const workflowRunGlobalActions: ActionConfig[] = actions?.filter(
(action) =>
action.type === ActionType.WorkflowRun &&
action.scope === ActionScope.Global,
);
const fallbackActions: ActionConfig[] = actions?.filter(
(action) => action.type === ActionType.Fallback,
);
const createRelatedRecordActions: ActionConfig[] = actions?.filter(
(action) =>
action.type === ActionType.Standard &&
action.scope === ActionScope.CreateRelatedRecord,
);
return {
navigateActions,
actionRecordSelectionActions,
actionGlobalActions,
actionObjectActions,
workflowRunRecordSelectionActions,
workflowRunGlobalActions,
fallbackActions,
createRelatedRecordActions,
};
};