refactor(command-menu-item): rename Actions to CommandMenuItem (#18489)

actions are being renamed to command menu item, they will be migrated to
server and will be served as headless front components

---------

Co-authored-by: Raphaël Bosi <71827178+bosiraphael@users.noreply.github.com>
This commit is contained in:
nitin
2026-03-09 19:33:12 +05:30
committed by GitHub
parent 06bdb5ad6a
commit 36bcc71f3d
275 changed files with 4544 additions and 4436 deletions
@@ -0,0 +1,60 @@
import { CommandMenuContext } from '@/command-menu-item/contexts/CommandMenuContext';
import { CommandMenuComponentInstanceContext } from '@/command-menu/states/contexts/CommandMenuComponentInstanceContext';
import { getCommandMenuDropdownIdFromCommandMenuId } from '@/command-menu-item/utils/getCommandMenuDropdownIdFromCommandMenuId';
import { getSidePanelCommandMenuDropdownIdFromCommandMenuId } from '@/command-menu-item/utils/getSidePanelCommandMenuDropdownIdFromCommandMenuId';
import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';
import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useContext } from 'react';
import { isDefined } from 'twenty-shared/utils';
export const useCloseCommandMenu = ({
closeSidePanelOnShowPageOptionsExecution = false,
closeSidePanelOnCommandMenuListExecution = true,
}: {
closeSidePanelOnShowPageOptionsExecution?: boolean;
closeSidePanelOnCommandMenuListExecution?: boolean;
} = {}) => {
const { containerType, isInSidePanel } = useContext(CommandMenuContext);
const { closeSidePanelMenu } = useSidePanelMenu();
const { closeDropdown } = useCloseDropdown();
const commandMenuId = useAvailableComponentInstanceIdOrThrow(
CommandMenuComponentInstanceContext,
);
const dropdownId = isInSidePanel
? getSidePanelCommandMenuDropdownIdFromCommandMenuId(commandMenuId)
: getCommandMenuDropdownIdFromCommandMenuId(commandMenuId);
const closeCommandMenu = () => {
if (containerType === 'command-menu-list') {
if (
isDefined(closeSidePanelOnCommandMenuListExecution) &&
!closeSidePanelOnCommandMenuListExecution
) {
return;
}
closeSidePanelMenu();
}
if (
containerType === 'index-page-dropdown' ||
containerType === 'command-menu-show-page-dropdown'
) {
closeDropdown(dropdownId);
}
if (
containerType === 'command-menu-show-page-dropdown' &&
isDefined(closeSidePanelOnShowPageOptionsExecution) &&
closeSidePanelOnShowPageOptionsExecution
) {
closeSidePanelMenu();
}
};
return { closeCommandMenu };
};