diff --git a/apps/web/src/common/toolbar-config.ts b/apps/web/src/common/toolbar-config.ts index ff0647973..c752c9250 100644 --- a/apps/web/src/common/toolbar-config.ts +++ b/apps/web/src/common/toolbar-config.ts @@ -7,6 +7,7 @@ export type Preset = { id: PresetId; title: string; tools: ToolbarGroupDefinition[]; + editable?: boolean; }; const presets: Record = { default: { id: "default", title: "Default", tools: DEFAULT_TOOLS }, @@ -25,7 +26,7 @@ const presets: Record = { ], ], }, - custom: { id: "custom", title: "Custom", tools: [] }, + custom: { id: "custom", title: "Custom", tools: [], editable: true }, }; export function getCurrentPreset() { diff --git a/apps/web/src/components/dialogs/toolbar-config-dialog.tsx b/apps/web/src/components/dialogs/toolbar-config-dialog.tsx index 80d50ccf1..68e87a1d2 100644 --- a/apps/web/src/components/dialogs/toolbar-config-dialog.tsx +++ b/apps/web/src/components/dialogs/toolbar-config-dialog.tsx @@ -124,22 +124,24 @@ export function ToolbarConfigDialog(props: ToolbarConfigDialogProps) { ))} - + {currentPreset.editable && ( + + )} isSubgroup(t)); + const canAddSubGroup = + currentPreset.editable && !deleted && !hasSubGroup; + const canRemoveGroup = currentPreset.editable && !deleted; + const canRemoveItem = currentPreset.editable && !deleted; return ( { + canAddSubGroup + ? () => { setItems((items) => addSubGroup(items, item.id)); showToast("success", "Subgroup added successfully"); } + : undefined } onRemoveGroup={ - deleted - ? undefined - : (group) => { + canRemoveGroup + ? (group) => { setItems(removeGroup(items, group.id)); } + : undefined } onRemoveItem={ - deleted - ? undefined - : (item) => { + canRemoveItem + ? (item) => { setItems(removeItem(items, item.id)); } + : undefined } /> );