-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Feat: Navbar customization #17728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feat: Navbar customization #17728
Changes from 142 commits
Commits
Show all changes
193 commits
Select commit
Hold shift + click to select a range
ad10e0a
Enhance navigation menu item components with icon color customization
abdulrahmancodes 8cbbc1b
Refactor NavigationMenuItemIcon to enhance icon color handling
abdulrahmancodes 2a5c2cf
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes ef617aa
Add IS_NAVIGATION_MENU_ITEM_EDITING_ENABLED feature flag
abdulrahmancodes 986a36a
Add navigation menu edit mode hooks and state management
abdulrahmancodes 2affeaf
Enhance Save and Cancel Buttons with Inverted Style Support
abdulrahmancodes c8a7ce4
Add Navigation Menu Edit Mode Bar and Enhance Workspace Navigation Items
abdulrahmancodes 3672bb7
Add Navigation Menu Item Edit Page and Update Command Menu Configuration
abdulrahmancodes e80574b
Enhance Workspace Navigation Menu Items with Active Item Click Handling
abdulrahmancodes 2d04977
Refactor NavigationDrawerItemForObjectMetadataItem to Simplify Compon…
abdulrahmancodes 4224522
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes 9e487f0
Add Workflows Folder and Update Navigation Menu Structure
abdulrahmancodes 9f9c766
Refactor Navigation Menu Item Structure and Introduce Workspace Secti…
abdulrahmancodes b38039f
Refactor Navigation Menu Item State Management and Update Component L…
abdulrahmancodes a65322d
Update NavigationDrawerItem Width Calculation for Enhanced Layout
abdulrahmancodes 4611e83
Enhance Command Menu Navigation Item Editing with Move and Remove Fun…
abdulrahmancodes 3865922
Add New Sidebar Item Page to Command Menu and Update Navigation Struc…
abdulrahmancodes df50bf4
Remove unused targetObjectMetadataId assignment in useSaveNavigationM…
abdulrahmancodes 9aaefbb
Enhance Command Menu New Sidebar Item Page with System Object Support
abdulrahmancodes f3f8a0c
Add View Support to Command Menu New Sidebar Item Page
abdulrahmancodes c89eee4
Enhance Command Menu List with Custom No Results Text
abdulrahmancodes ff92bde
Enhance Back Navigation Logic in Command Menu New Sidebar Item Page
abdulrahmancodes e2d4375
Refactor Navigation Menu Item Draft Management and Enhance Command Me…
abdulrahmancodes 70a338b
Enhance Command Menu Navigation Item Editing and Sorting Logic
abdulrahmancodes b32d04b
Refactor Workspace Navigation Menu Item Rendering and Sorting Logic
abdulrahmancodes c516f95
Add Object Selection for View Editing in Command Menu
abdulrahmancodes 2cf2ea6
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes 5110c27
Enhance NavigationDrawerItem to include secondary label for object me…
abdulrahmancodes 41aa60d
Integrate command menu functionality into NavigationMenuEditModeBar
abdulrahmancodes fc592d3
Add CommandMenuFolderInfo component and integrate into CommandMenuPag…
abdulrahmancodes b26b28f
Add link field to NavigationMenuItem and related inputs
abdulrahmancodes b9e5dd3
Add CommandMenuLinkInfo component and integrate into CommandMenuPageInfo
abdulrahmancodes ebef220
Enhance navigation menu item functionality with drag-and-drop support
abdulrahmancodes aeb62f4
Add CommandMenuItemWithAddToNavigationDrag component for enhanced dra…
abdulrahmancodes e1925c5
Refactor command menu components for improved icon handling and searc…
abdulrahmancodes ea920aa
Enhance CommandMenuSubViewWithSearch component and integrate into nav…
abdulrahmancodes 3682e54
Add Command Menu Components for Enhanced Navigation Functionality
abdulrahmancodes 479dabc
Implement New Sidebar Item Components for Command Menu
abdulrahmancodes 8f079b2
Refactor CommandMenuNavigationMenuItemEditPage for improved search ha…
abdulrahmancodes 6b2bf17
Add Command Menu Components for Enhanced Editing Functionality
abdulrahmancodes d4d06a8
Refactor Command Menu Components for Improved Icon Handling and Styling
abdulrahmancodes ee57a19
Remove CommandMenuEditFolderRenameSubView Component
abdulrahmancodes 8237a41
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes 71e4db6
Fix import order and clean up GraphQL type definitions in generated m…
abdulrahmancodes 5153c73
Refactor Command Menu Components to Use Flattened Workspace Section I…
abdulrahmancodes 45af0ca
Refactor Command Menu Components to Integrate Owner Section
abdulrahmancodes 1061f81
Enhance Command Menu Folder Picker and Organize Actions Components
abdulrahmancodes 9c6a117
Refactor useMouseDownNavigation Hook to Simplify Event Handling
abdulrahmancodes 5b6798f
Refactor Command Menu Sub View to Integrate Navigation Header
abdulrahmancodes d04df4b
Refactor useNavigationMenuItemMoveRemove Hook to Improve Position Swa…
abdulrahmancodes e9cd87c
Add useFilteredPickerItems Hook and Refactor Command Menu Components
abdulrahmancodes 439ac3f
Add options to useCommandMenuHotKeys for form tag handling
abdulrahmancodes df86efe
Enhance Command Menu Components with Application ID Integration
abdulrahmancodes 20dbfcf
Refactor CommandMenuPageInfo to Improve Navigation Item Handling
abdulrahmancodes 0f9882b
Refactor Navigation Menu Item Handling to Use Direct IDs
abdulrahmancodes ff1f0aa
Refactor Navigation Menu Item Handling to Use New Utility Functions
abdulrahmancodes 02dd826
Refactor Command Menu Components for Improved Item Handling
abdulrahmancodes 3d16040
Refactor Command Menu Components for Enhanced Readability and Logic
abdulrahmancodes 73c529e
Refactor CommandMenuLinkInfo for Improved Clarity and Logic
abdulrahmancodes 5462dc5
Add CommandMenuFolderLinkInfo Component and Remove CommandMenuLinkInfo
abdulrahmancodes b7f9112
Refactor CommandMenuFolderLinkInfo to Use Styled Navigation Menu Item…
abdulrahmancodes 9f44d0a
Remove CommandMenuSharedStyles and Integrate Styles Directly into Com…
abdulrahmancodes a7a5532
Remove CommandMenuEditDefaultView and Integrate Its Logic into Comman…
abdulrahmancodes 27dd5f2
Remove CommandMenuEditFolderItemView and Update CommandMenuNavigation…
abdulrahmancodes 04e8a67
Refactor CommandMenuEditFolderPickerSubView for Improved Folder Handling
abdulrahmancodes 8672bbc
Refactor CommandMenuEdit Components for Improved Clarity
abdulrahmancodes 8912fb6
Update CommandMenuEditOwnerSection to Simplify Disabled Prop Usage
abdulrahmancodes 04c2995
Refactor CommandMenuEditLinkItemView to Enhance URL Handling
abdulrahmancodes 8a2b6f8
Enhance CommandMenuNavigationMenuItemEditPage with Utility Functions …
abdulrahmancodes 923bb1e
Refactor CommandMenuNewSidebarItemRecordSubView for Improved Permissi…
abdulrahmancodes a97eafc
Refactor CommandMenuNewSidebarItemViewObjectPickerSubView to Utilize …
abdulrahmancodes 09bf32d
Refactor CommandMenuNewSidebarItemViewPickerSubView to Use Custom Hoo…
abdulrahmancodes 1882fdf
Refactor CommandMenuNewSidebarItemViewSystemSubView to Use Custom Hoo…
abdulrahmancodes dd0b8de
Refactor CommandMenuObjectMenuItem for Improved Click Handling and Cl…
abdulrahmancodes 1bf80a3
Refactor CommandMenu Components to Enhance Rendering and Simplify Logic
abdulrahmancodes 61c1e85
Refactor AddToNavigationDragHandle for Improved Readability and Consi…
abdulrahmancodes abf32ad
Refactor AddToNavigationDragPreview for Improved Clarity and Consistency
abdulrahmancodes 8858696
Refactor Navigation Drawer Components for Improved Structure and Clarity
abdulrahmancodes 6dd068a
Refactor NavigationItemDropTarget for Improved Structure and Clarity
abdulrahmancodes 4c4d47b
Refactor NavigationMenuEditModeBar for Improved Clarity and Structure
abdulrahmancodes 1a047fe
Refactor CommandMenuNavigationMenuItemEditPage for Improved Clarity a…
abdulrahmancodes 485e880
Refactor CommandMenuNewSidebarItemPage for Improved Clarity and Struc…
abdulrahmancodes 7268332
Refactor NavigationItemDropTarget and NavigationSidebarNativeDropZone…
abdulrahmancodes 430f16e
Enhance NavigationMenuEditModeBar for Improved Theming and Clarity
abdulrahmancodes 5c12b0f
Refactor CommandMenuNewSidebarItemPage for Enhanced Rendering Logic
abdulrahmancodes e0b1f8b
Refactor NavigationSidebarNativeDropZone for Improved Clarity and Str…
abdulrahmancodes 02e1710
Refactor NavigationSidebarNativeDropZone for Enhanced Readability
abdulrahmancodes 521d28d
Refactor WorkspaceNavigationMenuItemsFolder for Improved Clarity and …
abdulrahmancodes c76d7ba
Refactor useAddToNavigationMenuDraft for Improved Code Clarity
abdulrahmancodes 76ceaa3
Refactor Navigation Menu Hooks to Utilize New Filtering Utility
abdulrahmancodes fa18caa
Refactor CommandMenuEditFolderPickerSubView for Improved Logic and Re…
abdulrahmancodes 6ec8b57
Refactor CommandMenuNavigationMenuItemEditPage for Improved Readability
abdulrahmancodes ed42de3
Refactor CommandMenuNavigationMenuItemEditPage and Related Hooks for …
abdulrahmancodes 5241c5a
Refactor CommandMenu Components for Enhanced Data Management and Read…
abdulrahmancodes 9456ac3
Refactor Command Menu Components for Improved Structure and Reusability
abdulrahmancodes 7f9128a
Refactor Navigation Menu Item Hooks and Components for Enhanced State…
abdulrahmancodes b5d9181
Refactor CommandMenuNavigationMenuItemEditPage for Improved Action Ha…
abdulrahmancodes f82bcb4
Refactor Command Menu Components to Enhance State Management and Clarity
abdulrahmancodes fe19af4
Refactor CommandMenuEditFolderPickerSubView for Enhanced Folder Selec…
abdulrahmancodes c9c7fc1
Refactor CommandMenuEditViewPickerSubView for Enhanced View Selection…
abdulrahmancodes 409e789
Refactor CommandMenuNavigationMenuItemEditPage for Improved Rendering…
abdulrahmancodes 9af54c5
Refactor CommandMenuNewSidebarItem Components for Enhanced Structure …
abdulrahmancodes 0956c72
Refactor Command Menu Components for Improved Data Handling and Clarity
abdulrahmancodes ea52343
Refactor CommandMenuNavigationMenuItemEditPage for Enhanced Rendering…
abdulrahmancodes dce2e0a
Refactor Command Menu Item Components to Standardize Icon Handling
abdulrahmancodes eddf0e1
Refactor Command Menu Item Hooks and Components for Improved Draft Ma…
abdulrahmancodes c12875e
Refactor Navigation Menu Item Drag and Drop Logic for Improved Clarity
abdulrahmancodes cb21655
Refactor Navigation Menu Edit Mode Logic for Improved State Management
abdulrahmancodes f16b724
Enhance Icon Component Handling in AddToNavigationIconSlot
abdulrahmancodes f1f0f74
Refactor StyledIcon Component for Improved CSS Handling
abdulrahmancodes ef57d5c
Enhance Navigation Menu Item Type Handling and Sorting Logic
abdulrahmancodes 195bdac
Refactor Navigation Menu Item Logic for Improved Type Handling
abdulrahmancodes ab42628
Refactor Navigation Menu Item Components for Enhanced Type Consistency
abdulrahmancodes 160f7ca
Refactor Workspace Navigation Menu Item Filtering for Enhanced Type S…
abdulrahmancodes 4faee65
Remove Unused Import in useSelectedNavigationMenuItemEditData Hook
abdulrahmancodes 55d55a6
Update Icon Sizes and Container Dimensions for Consistency
abdulrahmancodes 44602fc
Enhance Navigation Drawer Section Title Component with Always Visible…
abdulrahmancodes aaed421
Implement Navbar Drag Provider and Refactor Navigation Components for…
abdulrahmancodes a3bfa3b
Refactor Workspace Navigation Menu Items Folder Component for Improve…
abdulrahmancodes 84c8043
Refactor NavbarDragProvider to Improve Parameter Naming
abdulrahmancodes 19472a9
Add WorkspaceNavigationMenuItemFolderDragClone Component for Drag-and…
abdulrahmancodes 2b465f5
Refactor Workspace Navigation Menu Items Folder for Enhanced Structur…
abdulrahmancodes 8159a0c
Update Command Menu Icons for Improved Clarity
abdulrahmancodes fae016b
Refactor AddToNavigationIconSlot Component for Improved Icon Handling
abdulrahmancodes 439d81c
Enhance Command Menu Item with Contextual Drag Description
abdulrahmancodes d829206
Refactor AddToNavigationDragHandle Component for Enhanced Customization
abdulrahmancodes 5caa8df
Refactor Command Menu Components for Enhanced Icon Handling and Theming
abdulrahmancodes 92ba245
Refactor AddToNavigationDragHandle and IconWithBackground for Improve…
abdulrahmancodes e2da06c
Refactor NavigationSidebarNativeDropZone for Improved Drag-and-Drop H…
abdulrahmancodes 8f7b189
Enhance Drag Preview Functionality with Recoil Integration
abdulrahmancodes 6f78f9a
Implement Navigation Sections and Enhance Drag-and-Drop Functionality
abdulrahmancodes f9df7b8
Enhance Command Menu Sidebar Item with Displayable Views and System O…
abdulrahmancodes af1fcee
Enhance Command Menu New Sidebar Item with Submenu Support
abdulrahmancodes 26e67db
Update CommandMenuSubViewWithSearch styling for improved visual consi…
abdulrahmancodes 5b55f91
Enhance Navigation Item Drop Target and Workspace Menu with Add Item …
abdulrahmancodes a113468
Refactor Navigation Menu Components to Enhance Navigation Logic
abdulrahmancodes 09bf955
Refactor Command Menu Components to Streamline Object Editing and Rem…
abdulrahmancodes 326f32e
Refactor WorkspaceNavigationMenuItemsFolder for Enhanced Styling and …
abdulrahmancodes 2246970
Refactor WorkspaceNavigationMenuItemsFolder for Improved Padding Logic
abdulrahmancodes a95f152
Refactor Command Menu New Sidebar Item Components for Improved Logic …
abdulrahmancodes b048b7a
Add Add Before and Add After Functionality to Command Menu Components
abdulrahmancodes 919766c
Add CommandMenuObjectViewRecordInfo Component for Enhanced View and R…
abdulrahmancodes 4b0bd71
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes 6b27902
feat: add 'link' property to entity properties configuration
abdulrahmancodes b7798ef
refactor: simplify item type checks in CommandMenu components
abdulrahmancodes eaec7de
refactor: remove getNavigationMenuItemType utility and streamline ite…
abdulrahmancodes d2bf4a7
refactor: standardize navigation menu item type handling across compo…
abdulrahmancodes b8a2600
refactor: enhance folder selection logic in CommandMenu components
abdulrahmancodes d24264a
Potential fix for pull request finding 'Useless conditional'
abdulrahmancodes fa9dba8
refactor: improve item type handling and component logic in CommandMenu
abdulrahmancodes a3e242b
fix: add key prop to CommandMenuEditLinkItemView for improved rendering
abdulrahmancodes 4d12375
refactor: update contextual description logic in CommandMenuItemWithA…
abdulrahmancodes 67707da
refactor: optimize sorting of object metadata items in CommandMenu co…
abdulrahmancodes ab392e7
fix: include targetRecordId in navigation menu item comparison logic
abdulrahmancodes 1738fa0
fix: enhance search records handling in CommandMenuNewSidebarItemReco…
abdulrahmancodes 7c92aef
fix: handle non-function icon types in AddToNavigationIconSlot component
abdulrahmancodes 4f55adb
fix: update folder content drop disabled logic in CurrentWorkspaceMem…
abdulrahmancodes 655ec25
fix: include folderUniversalIdentifier in navigation menu item metadata
abdulrahmancodes b61377c
fix: refine icon type validation in AddToNavigationIconSlot component
abdulrahmancodes e5acbcf
fix: add link property to navigation menu item metadata
abdulrahmancodes 7bca98f
test: add unit tests for navigation menu item utilities
abdulrahmancodes ea8c910
fix: update navigation menu item error messages to include external l…
abdulrahmancodes 58bc4c4
test: add unit tests for workspace navigation menu item utilities
abdulrahmancodes 90de7f8
test: add unit tests for recordIdentifierToObjectRecordIdentifier uti…
abdulrahmancodes fcb5d7e
fix: simplify folder item handling in useWorkspaceSectionItems hook
abdulrahmancodes 5b16cde
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes aefe6f6
refactor: improve navigation menu item movement logic
abdulrahmancodes 7889fc6
refactor: update navigation menu item matching logic
abdulrahmancodes 584f13f
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes 01bb421
feat: implement drag-and-drop functionality for navigation menu items
abdulrahmancodes e6d9771
feat: integrate Recoil state management for navigation drag-and-drop
abdulrahmancodes 2c81170
refactor: streamline state management in navigation components
abdulrahmancodes c0bcbc1
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes 03971aa
test: add unit tests for navigation menu item utilities
abdulrahmancodes 7b2a5ff
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes bc93710
refactor: replace AddToNavigationIconSlot with AddToNavigationDragHan…
abdulrahmancodes 1420eba
refactor: enhance CommandMenuItemWithAddToNavigationDrag for improved…
abdulrahmancodes b9b8062
test: add unit tests for calculateNewPosition utility
abdulrahmancodes be1cae4
test: update navigation menu item utility tests for clarity and coverage
abdulrahmancodes 4d8046b
test: update coverage thresholds in jest configuration
abdulrahmancodes 51b6eff
test: adjust coverage thresholds in Jest configuration
abdulrahmancodes fe96cc6
refactor: simplify drop handling logic in useHandleAddToNavigationDro…
abdulrahmancodes e3228fa
test: lower coverage thresholds in Jest configuration
abdulrahmancodes 3797812
test: lower functions coverage threshold in Jest configuration
abdulrahmancodes 698074e
refactor: remove unused feature flag from seedFeatureFlags utility
abdulrahmancodes 1a7b1ab
refactor: improve code readability in tests and components
abdulrahmancodes 7391b7b
test: remove obsolete test files for navigation menu item utilities
abdulrahmancodes 8a769fe
Merge branch 'main' into feat/navbar-customization
abdulrahmancodes d8bb8e5
Enhance GraphQL schema with new input types and enums
abdulrahmancodes 56676a7
test: fix
Devessier 3e81789
chore: regenerate graphql
Devessier 2d92857
Merge remote-tracking branch 'origin/main' into feat/navbar-customiza…
Devessier 62abd18
test: update e2e test according to new navigation system
Devessier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
packages/twenty-front/src/modules/command-menu/components/CommandMenuFolderLinkInfo.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import { useTheme } from '@emotion/react'; | ||
| import { useLingui } from '@lingui/react/macro'; | ||
| import { useRecoilValue } from 'recoil'; | ||
| import { IconFolder, IconLink } from 'twenty-ui/display'; | ||
|
|
||
| import { CommandMenuPageInfoLayout } from '@/command-menu/components/CommandMenuPageInfoLayout'; | ||
| import { commandMenuPageInfoState } from '@/command-menu/states/commandMenuPageInfoState'; | ||
| import { commandMenuShouldFocusTitleInputComponentState } from '@/command-menu/states/commandMenuShouldFocusTitleInputComponentState'; | ||
| import { StyledNavigationMenuItemIconContainer } from '@/navigation-menu-item/components/NavigationMenuItemIconContainer'; | ||
| import { useUpdateFolderNameInDraft } from '@/navigation-menu-item/hooks/useUpdateFolderNameInDraft'; | ||
| import { useUpdateLinkInDraft } from '@/navigation-menu-item/hooks/useUpdateLinkInDraft'; | ||
| import { useWorkspaceSectionItems } from '@/navigation-menu-item/hooks/useWorkspaceSectionItems'; | ||
| import { selectedNavigationMenuItemInEditModeState } from '@/navigation-menu-item/states/selectedNavigationMenuItemInEditModeState'; | ||
| import { getNavigationMenuItemIconColors } from '@/navigation-menu-item/utils/getNavigationMenuItemIconColors'; | ||
| import { TitleInput } from '@/ui/input/components/TitleInput'; | ||
| import { useRecoilComponentState } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentState'; | ||
|
|
||
| const ICON_CONFIG = { | ||
| folder: { Icon: IconFolder, colorKey: 'folder' }, | ||
| link: { Icon: IconLink, colorKey: 'link' }, | ||
| } as const; | ||
|
|
||
| export const CommandMenuFolderLinkInfo = ({ | ||
| type, | ||
| }: { | ||
| type: 'folder' | 'link'; | ||
| }) => { | ||
| const theme = useTheme(); | ||
| const { t } = useLingui(); | ||
| const commandMenuPageInfo = useRecoilValue(commandMenuPageInfoState); | ||
| const [shouldFocusTitleInput, setShouldFocusTitleInput] = | ||
| useRecoilComponentState( | ||
| commandMenuShouldFocusTitleInputComponentState, | ||
| commandMenuPageInfo.instanceId, | ||
| ); | ||
| const selectedNavigationMenuItemInEditMode = useRecoilValue( | ||
| selectedNavigationMenuItemInEditModeState, | ||
| ); | ||
| const items = useWorkspaceSectionItems(); | ||
| const { updateFolderNameInDraft } = useUpdateFolderNameInDraft(); | ||
| const { updateLinkInDraft } = useUpdateLinkInDraft(); | ||
|
|
||
| const defaultLabel = type === 'folder' ? t`New folder` : t`Link label`; | ||
| const placeholder = type === 'folder' ? t`Folder name` : t`Link label`; | ||
|
|
||
| const selectedItem = selectedNavigationMenuItemInEditMode | ||
| ? items.find( | ||
| (item) => | ||
| item.itemType === type && | ||
| item.id === selectedNavigationMenuItemInEditMode, | ||
| ) | ||
| : undefined; | ||
|
|
||
| if (!selectedItem) return null; | ||
|
|
||
| const itemId = selectedItem.id; | ||
| const itemName = selectedItem.name ?? defaultLabel; | ||
|
|
||
| const handleChange = (text: string) => { | ||
| if (type === 'folder') { | ||
| updateFolderNameInDraft(itemId, text); | ||
| } else { | ||
| updateLinkInDraft(itemId, { name: text }); | ||
| } | ||
| }; | ||
|
|
||
| const handleSave = () => { | ||
| const trimmed = itemName.trim(); | ||
| const finalName = trimmed.length > 0 ? trimmed : defaultLabel; | ||
|
|
||
| if (finalName !== itemName) { | ||
| if (type === 'folder') { | ||
| updateFolderNameInDraft(itemId, finalName); | ||
| } else { | ||
| updateLinkInDraft(itemId, { name: finalName }); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| const { Icon, colorKey } = ICON_CONFIG[type]; | ||
|
|
||
| return ( | ||
| <CommandMenuPageInfoLayout | ||
| icon={ | ||
| <StyledNavigationMenuItemIconContainer | ||
| $backgroundColor={getNavigationMenuItemIconColors(theme)[colorKey]} | ||
| > | ||
| <Icon | ||
| size={theme.spacing(3.5)} | ||
| color={theme.grayScale.gray1} | ||
| stroke={theme.icon.stroke.md} | ||
| /> | ||
| </StyledNavigationMenuItemIconContainer> | ||
| } | ||
| title={ | ||
| <TitleInput | ||
| instanceId={ | ||
| type === 'folder' ? `folder-name-${itemId}` : `link-label-${itemId}` | ||
| } | ||
| sizeVariant="sm" | ||
| value={itemName} | ||
| onChange={handleChange} | ||
| placeholder={placeholder} | ||
| onEnter={handleSave} | ||
| onEscape={handleSave} | ||
| onClickOutside={handleSave} | ||
| onTab={handleSave} | ||
| onShiftTab={handleSave} | ||
| shouldFocus={shouldFocusTitleInput} | ||
| onFocus={() => setShouldFocusTitleInput(false)} | ||
| /> | ||
| } | ||
| label={type === 'link' ? t`link` : undefined} | ||
| /> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CommandMenuFolderLinkInfo component handles two different cases: folders and links.
Then, in the body of the component, we do different things based on the type.
Sometimes, it makes things clearer to duplicate code. Here, I would do one CommandMenuFolderInfo and one CommandMenuLinkInfo components. Most of the code would look the same, but duplication is fine when you reuse common bricks.