A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: don't allow adding/removing groups & items in non-editable presets
thecodrr6ec5937a15a6
diff --git a/apps/web/src/common/toolbar-config.ts b/apps/web/src/common/toolbar-config.tsindex 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<PresetId, Preset> = {default: { id: "default", title: "Default", tools: DEFAULT_TOOLS },@@ -25,7 +26,7 @@ const presets: Record<PresetId, Preset> = {],],},- 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.tsxindex 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) {</Label>))}</Flex>- <Button- variant={"secondary"}- sx={{- display: "flex",- flexShrink: 0,- alignItems: "center",- p: 1,- }}- title="Add group"- onClick={() => {- setItems(addGroup);- showToast("success", "Group added successfully");- }}- >- <Icon path={Icons.plus} color="text" size={18} />- </Button>+ {currentPreset.editable && (+ <Button+ variant={"secondary"}+ sx={{+ display: "flex",+ flexShrink: 0,+ alignItems: "center",+ p: 1,+ }}+ title="Add group"+ onClick={() => {+ setItems(addGroup);+ showToast("success", "Group added successfully");+ }}+ >+ <Icon path={Icons.plus} color="text" size={18} />+ </Button>+ )}</Flex><DndContext@@ -184,6 +186,10 @@ export function ToolbarConfigDialog(props: ToolbarConfigDialogProps) {const hasSubGroup =isGroup(item) &&!!getGroup(items, item.id)?.items.some((t) => isSubgroup(t));+ const canAddSubGroup =+ currentPreset.editable && !deleted && !hasSubGroup;+ const canRemoveGroup = currentPreset.editable && !deleted;+ const canRemoveItem = currentPreset.editable && !deleted;return (<TreeNodeComponent@@ -191,26 +197,26 @@ export function ToolbarConfigDialog(props: ToolbarConfigDialogProps) {item={item}activeItem={activeItem}onAddSubGroup={- deleted || hasSubGroup- ? undefined- : () => {+ 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}/>);