Refactor command menu items deprecated code (#19508)
- Removes the intermediate `CommandMenuItemConfig` / `CommandConfigContext` / `CommandMenuItemDisplay` abstraction layers, replacing them with a single `CommandMenuItemRenderer` that renders directly from the command menu items from the backend - Eliminates the server-items/ subdirectory by moving its contents (hooks/, contexts/, states/, display/, edit/) up into the parent command-menu-item/ module, removing an unnecessary nesting level.
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
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 { CommandMenuComponentInstanceContext } from '@/command-menu/states/contexts/CommandMenuComponentInstanceContext';
|
||||
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,
|
||||
@@ -15,7 +14,9 @@ export const useCloseCommandMenu = ({
|
||||
closeSidePanelOnShowPageOptionsExecution?: boolean;
|
||||
closeSidePanelOnCommandMenuListExecution?: boolean;
|
||||
} = {}) => {
|
||||
const { containerType, isInSidePanel } = useContext(CommandMenuContext);
|
||||
const { containerType, commandMenuContextApi } =
|
||||
useContext(CommandMenuContext);
|
||||
const isInSidePanel = commandMenuContextApi.isInSidePanel;
|
||||
|
||||
const { closeSidePanelMenu } = useSidePanelMenu();
|
||||
|
||||
@@ -31,10 +32,7 @@ export const useCloseCommandMenu = ({
|
||||
|
||||
const closeCommandMenu = () => {
|
||||
if (containerType === 'command-menu-list') {
|
||||
if (
|
||||
isDefined(closeSidePanelOnCommandMenuListExecution) &&
|
||||
!closeSidePanelOnCommandMenuListExecution
|
||||
) {
|
||||
if (!closeSidePanelOnCommandMenuListExecution) {
|
||||
return;
|
||||
}
|
||||
closeSidePanelMenu();
|
||||
@@ -49,7 +47,6 @@ export const useCloseCommandMenu = ({
|
||||
|
||||
if (
|
||||
containerType === 'command-menu-show-page-dropdown' &&
|
||||
isDefined(closeSidePanelOnShowPageOptionsExecution) &&
|
||||
closeSidePanelOnShowPageOptionsExecution
|
||||
) {
|
||||
closeSidePanelMenu();
|
||||
|
||||
Reference in New Issue
Block a user