From 9cd9e505f358ba3c0cd1952a42619a55f8b59e18 Mon Sep 17 00:00:00 2001 From: Abdul Rahman Date: Wed, 11 Feb 2026 11:19:35 +0530 Subject: [PATCH] refactor: streamline CommandMenuNavigationMenuItemEditPage logic with switch statement Refactored the CommandMenuNavigationMenuItemEditPage component to replace multiple if statements with a switch statement for improved readability and maintainability. This change enhances the handling of different navigation menu item types, ensuring clearer logic flow and reducing code duplication. --- .../CommandMenuNavigationMenuItemEditPage.tsx | 142 ++++++++---------- 1 file changed, 66 insertions(+), 76 deletions(-) diff --git a/packages/twenty-front/src/modules/command-menu/pages/navigation-menu-item/components/CommandMenuNavigationMenuItemEditPage.tsx b/packages/twenty-front/src/modules/command-menu/pages/navigation-menu-item/components/CommandMenuNavigationMenuItemEditPage.tsx index 4fdefb23a7e..9a5a23a52a9 100644 --- a/packages/twenty-front/src/modules/command-menu/pages/navigation-menu-item/components/CommandMenuNavigationMenuItemEditPage.tsx +++ b/packages/twenty-front/src/modules/command-menu/pages/navigation-menu-item/components/CommandMenuNavigationMenuItemEditPage.tsx @@ -68,60 +68,12 @@ export const CommandMenuNavigationMenuItemEditPage = () => { return ; } - if ( - selectedItemType === NavigationMenuItemType.VIEW && - !selectedItemObjectMetadata - ) { - return null; - } - - if (selectedItemType === NavigationMenuItemType.VIEW) { - return ( - - ); - } - - if ( - isDefined(selectedItem) && - selectedItem.itemType === NavigationMenuItemType.LINK - ) { - return ( - updateLinkInDraft(linkId, { link })} - onOpenFolderPicker={setFolderPicker} - canMoveUp={canMoveUp} - canMoveDown={canMoveDown} - onMoveUp={onMoveUp} - onMoveDown={onMoveDown} - onRemove={onRemove} - onAddBefore={onAddBefore} - onAddAfter={onAddAfter} - /> - ); - } - - if (selectedItemType === NavigationMenuItemType.LINK) { - return null; - } - - if (selectedItemType === NavigationMenuItemType.FOLDER) { - return ( - - { onAddBefore={onAddBefore} onAddAfter={onAddAfter} /> - - - ); + ); + case NavigationMenuItemType.LINK: + if ( + isDefined(selectedItem) && + selectedItem.itemType === NavigationMenuItemType.LINK + ) { + return ( + updateLinkInDraft(linkId, { link })} + onOpenFolderPicker={setFolderPicker} + canMoveUp={canMoveUp} + canMoveDown={canMoveDown} + onMoveUp={onMoveUp} + onMoveDown={onMoveDown} + onRemove={onRemove} + onAddBefore={onAddBefore} + onAddAfter={onAddAfter} + /> + ); + } + return null; + case NavigationMenuItemType.FOLDER: + return ( + + + + + ); + default: + return ( + + + + ); } - - return ( - - - - ); };