Remove CommandMenuEditFolderRenameSubView Component
- Deleted the `CommandMenuEditFolderRenameSubView` component from the command menu, streamlining the editing interface. - Updated `CommandMenuNavigationMenuItemEditPage` to remove references to the deleted component, enhancing code clarity and maintainability. These changes simplify the command menu structure and improve overall code organization.
This commit is contained in:
-47
@@ -1,47 +0,0 @@
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { CommandMenuSubViewWithSearch } from '@/command-menu/components/CommandMenuSubViewWithSearch';
|
||||
import { useUpdateNavigationMenuItemsDraft } from '@/navigation-menu-item/hooks/useUpdateNavigationMenuItemsDraft';
|
||||
|
||||
type CommandMenuEditFolderRenameSubViewProps = {
|
||||
folderId: string;
|
||||
onBack: () => void;
|
||||
onSuccess: () => void;
|
||||
};
|
||||
|
||||
export const CommandMenuEditFolderRenameSubView = ({
|
||||
folderId,
|
||||
onBack,
|
||||
onSuccess,
|
||||
}: CommandMenuEditFolderRenameSubViewProps) => {
|
||||
const { t } = useLingui();
|
||||
const [folderRenameInput, setFolderRenameInput] = useState('');
|
||||
const { updateFolderNameInDraft } = useUpdateNavigationMenuItemsDraft();
|
||||
|
||||
const handleRename = () => {
|
||||
const trimmed = folderRenameInput.trim();
|
||||
if (trimmed.length > 0) {
|
||||
updateFolderNameInDraft(folderId, trimmed);
|
||||
setFolderRenameInput('');
|
||||
onSuccess();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<CommandMenuSubViewWithSearch
|
||||
backBarTitle={t`Rename folder`}
|
||||
onBack={onBack}
|
||||
searchPlaceholder={t`Folder name`}
|
||||
searchValue={folderRenameInput}
|
||||
onSearchChange={setFolderRenameInput}
|
||||
searchInputProps={{
|
||||
onKeyDown: (event) => {
|
||||
if (event.key === 'Enter' && folderRenameInput.trim().length > 0) {
|
||||
handleRename();
|
||||
}
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { IconSettings } from 'twenty-ui/display';
|
||||
|
||||
import { CommandGroup } from '@/command-menu/components/CommandGroup';
|
||||
import { CommandMenuList } from '@/command-menu/components/CommandMenuList';
|
||||
|
||||
-15
@@ -11,7 +11,6 @@ import {
|
||||
import { CommandMenuEditDefaultView } from '@/command-menu/pages/navigation-menu-item/components/CommandMenuEditDefaultView';
|
||||
import { CommandMenuEditFolderItemView } from '@/command-menu/pages/navigation-menu-item/components/CommandMenuEditFolderItemView';
|
||||
import { CommandMenuEditFolderPickerSubView } from '@/command-menu/pages/navigation-menu-item/components/CommandMenuEditFolderPickerSubView';
|
||||
import { CommandMenuEditFolderRenameSubView } from '@/command-menu/pages/navigation-menu-item/components/CommandMenuEditFolderRenameSubView';
|
||||
import { CommandMenuEditLinkItemView } from '@/command-menu/pages/navigation-menu-item/components/CommandMenuEditLinkItemView';
|
||||
import { CommandMenuEditObjectItemView } from '@/command-menu/pages/navigation-menu-item/components/CommandMenuEditObjectItemView';
|
||||
import { CommandMenuEditObjectPickerSubView } from '@/command-menu/pages/navigation-menu-item/components/CommandMenuEditObjectPickerSubView';
|
||||
@@ -55,7 +54,6 @@ export const CommandMenuNavigationMenuItemEditPage = () => {
|
||||
| 'object-picker-system'
|
||||
| 'folder-picker'
|
||||
| 'view-picker'
|
||||
| 'folder-rename'
|
||||
| null
|
||||
>(null);
|
||||
const [
|
||||
@@ -340,19 +338,6 @@ export const CommandMenuNavigationMenuItemEditPage = () => {
|
||||
);
|
||||
}
|
||||
|
||||
if (editSubView === 'folder-rename' && selectedItem?.type === 'folder') {
|
||||
return (
|
||||
<CommandMenuEditFolderRenameSubView
|
||||
folderId={selectedItem.folder.folderId}
|
||||
onBack={() => setEditSubView(null)}
|
||||
onSuccess={() => {
|
||||
setEditSubView(null);
|
||||
closeCommandMenu();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (isObjectItem && selectedItem?.type === 'objectView') {
|
||||
return (
|
||||
<CommandMenuEditObjectItemView
|
||||
|
||||
Reference in New Issue
Block a user