From 16073ea4aa2073b3686f0b278c0658d64e577f27 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 17 Aug 2024 02:01:12 +0300 Subject: [PATCH] client: Disable some context options in settings (closes #346) --- src/public/app/menus/tree_context_menu.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/public/app/menus/tree_context_menu.js b/src/public/app/menus/tree_context_menu.js index 38c245251..e3e19dc93 100644 --- a/src/public/app/menus/tree_context_menu.js +++ b/src/public/app/menus/tree_context_menu.js @@ -43,6 +43,7 @@ export default class TreeContextMenu { || (selNodes.length === 1 && selNodes[0] === this.node); const notSearch = note.type !== 'search'; + const notOptions = !note.noteId.startsWith("_options"); const parentNotSearch = !parentNote || parentNote.type !== 'search'; const insertNoteAfterEnabled = isNotRoot && !isHoisted && parentNotSearch; @@ -51,25 +52,25 @@ export default class TreeContextMenu { { title: 'Open in a new split', command: "openNoteInSplit", uiIcon: "bx bx-dock-right", enabled: noSelectedNotes }, { title: 'Insert note after ', command: "insertNoteAfter", uiIcon: "bx bx-plus", items: insertNoteAfterEnabled ? await noteTypesService.getNoteTypeItems("insertNoteAfter") : null, - enabled: insertNoteAfterEnabled && noSelectedNotes }, + enabled: insertNoteAfterEnabled && noSelectedNotes && notOptions }, { title: 'Insert child note ', command: "insertChildNote", uiIcon: "bx bx-plus", items: notSearch ? await noteTypesService.getNoteTypeItems("insertChildNote") : null, - enabled: notSearch && noSelectedNotes }, + enabled: notSearch && noSelectedNotes && notOptions }, { title: 'Delete ', command: "deleteNotes", uiIcon: "bx bx-trash", - enabled: isNotRoot && !isHoisted && parentNotSearch }, + enabled: isNotRoot && !isHoisted && parentNotSearch && notOptions }, { title: "----" }, { title: 'Search in subtree ', command: "searchInSubtree", uiIcon: "bx bx-search", enabled: notSearch && noSelectedNotes }, isHoisted ? null : { title: 'Hoist note ', command: "toggleNoteHoisting", uiIcon: "bx bx-empty", enabled: noSelectedNotes && notSearch }, !isHoisted || !isNotRoot ? null : { title: 'Unhoist note ', command: "toggleNoteHoisting", uiIcon: "bx bx-door-open" }, { title: 'Edit branch prefix ', command: "editBranchPrefix", uiIcon: "bx bx-empty", - enabled: isNotRoot && parentNotSearch && noSelectedNotes}, + enabled: isNotRoot && parentNotSearch && noSelectedNotes && notOptions }, { title: "Advanced", uiIcon: "bx bx-empty", enabled: true, items: [ { title: 'Expand subtree ', command: "expandSubtree", uiIcon: "bx bx-expand", enabled: noSelectedNotes }, { title: 'Collapse subtree ', command: "collapseSubtree", uiIcon: "bx bx-collapse", enabled: noSelectedNotes }, { title: 'Sort by ... ', command: "sortChildNotes", uiIcon: "bx bx-empty", enabled: noSelectedNotes && notSearch }, - { title: 'Recent changes in subtree', command: "recentChangesInSubtree", uiIcon: "bx bx-history", enabled: noSelectedNotes }, - { title: 'Convert to attachment', command: "convertNoteToAttachment", uiIcon: "bx bx-empty", enabled: isNotRoot && !isHoisted }, + { title: 'Recent changes in subtree', command: "recentChangesInSubtree", uiIcon: "bx bx-history", enabled: noSelectedNotes && notOptions }, + { title: 'Convert to attachment', command: "convertNoteToAttachment", uiIcon: "bx bx-empty", enabled: isNotRoot && !isHoisted && notOptions }, { title: 'Copy note path to clipboard', command: "copyNotePathToClipboard", uiIcon: "bx bx-empty", enabled: true } ] }, { title: "----" }, @@ -89,12 +90,12 @@ export default class TreeContextMenu { { title: 'Paste after', command: "pasteNotesAfterFromClipboard", uiIcon: "bx bx-paste", enabled: !clipboard.isClipboardEmpty() && isNotRoot && !isHoisted && parentNotSearch && noSelectedNotes }, { title: `Duplicate subtree `, command: "duplicateSubtree", uiIcon: "bx bx-empty", - enabled: parentNotSearch && isNotRoot && !isHoisted }, + enabled: parentNotSearch && isNotRoot && !isHoisted && notOptions }, { title: "----" }, { title: "Export", command: "exportNote", uiIcon: "bx bx-empty", - enabled: notSearch && noSelectedNotes }, + enabled: notSearch && noSelectedNotes && notOptions }, { title: "Import into note", command: "importIntoNote", uiIcon: "bx bx-empty", - enabled: notSearch && noSelectedNotes }, + enabled: notSearch && noSelectedNotes && notOptions }, { title: "Apply bulk actions", command: "openBulkActionsDialog", uiIcon: "bx bx-list-plus", enabled: true } ].filter(row => row !== null);