Closes https://github.com/twentyhq/core-team-issues/issues/324 Fixed typos: 'No results' is used when multiple results are expected and 'No result' is used when only one result is expected. https://github.com/user-attachments/assets/e3655ced-465a-44b1-92af-63878b9d8a94
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import { useCommandMenuCommands } from '@/command-menu/hooks/useCommandMenuCommands';
|
|
import { useMatchCommands } from '@/command-menu/hooks/useMatchCommands';
|
|
|
|
export const useMatchingCommandMenuCommands = ({
|
|
commandMenuSearch,
|
|
}: {
|
|
commandMenuSearch: string;
|
|
}) => {
|
|
const { matchCommands } = useMatchCommands({ commandMenuSearch });
|
|
|
|
const {
|
|
copilotCommands,
|
|
navigateCommands,
|
|
actionRecordSelectionCommands,
|
|
actionObjectCommands,
|
|
actionGlobalCommands,
|
|
workflowRunRecordSelectionCommands,
|
|
workflowRunGlobalCommands,
|
|
fallbackCommands,
|
|
} = useCommandMenuCommands();
|
|
|
|
const matchingNavigateCommands = matchCommands(navigateCommands);
|
|
|
|
const matchingStandardActionRecordSelectionCommands = matchCommands(
|
|
actionRecordSelectionCommands,
|
|
);
|
|
|
|
const matchingStandardActionObjectCommands =
|
|
matchCommands(actionObjectCommands);
|
|
|
|
const matchingStandardActionGlobalCommands =
|
|
matchCommands(actionGlobalCommands);
|
|
|
|
const matchingWorkflowRunRecordSelectionCommands = matchCommands(
|
|
workflowRunRecordSelectionCommands,
|
|
);
|
|
|
|
const matchingWorkflowRunGlobalCommands = matchCommands(
|
|
workflowRunGlobalCommands,
|
|
);
|
|
|
|
const noResults =
|
|
!matchingStandardActionRecordSelectionCommands.length &&
|
|
!matchingWorkflowRunRecordSelectionCommands.length &&
|
|
!matchingStandardActionGlobalCommands.length &&
|
|
!matchingWorkflowRunGlobalCommands.length &&
|
|
!matchingStandardActionObjectCommands.length &&
|
|
!matchingNavigateCommands.length;
|
|
|
|
return {
|
|
noResults,
|
|
copilotCommands,
|
|
matchingStandardActionRecordSelectionCommands,
|
|
matchingStandardActionObjectCommands,
|
|
matchingWorkflowRunRecordSelectionCommands,
|
|
matchingStandardActionGlobalCommands,
|
|
matchingWorkflowRunGlobalCommands,
|
|
matchingNavigateCommands,
|
|
fallbackCommands: noResults ? fallbackCommands : [],
|
|
};
|
|
};
|