Skip to content

Build your personal knowledge base with Trilium Notes

feat(tree): archive/unarchive notes

Elian Doranf42d375cc703
diff --git a/apps/client/src/menus/tree_context_menu.ts b/apps/client/src/menus/tree_context_menu.ts
index 8e8f2ed167..fdc5c20c68 100644
--- a/apps/client/src/menus/tree_context_menu.ts
+++ b/apps/client/src/menus/tree_context_menu.ts
@@ -13,6 +13,7 @@ import type NoteTreeWidget from "../widgets/note_tree.js";
import type FAttachment from "../entities/fattachment.js";
import type { SelectMenuItemEventListener } from "../components/events.js";
import utils from "../services/utils.js";
+import attributes from "../services/attributes.js";
// TODO: Deduplicate once client/server is well split.
interface ConvertToAttachmentResponse {
@@ -55,6 +56,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
const branch = froca.getBranch(this.node.data.branchId);
const isNotRoot = note?.noteId !== "root";
const isHoisted = note?.noteId === appContext.tabManager.getActiveContext()?.hoistedNoteId;
+ const isArchived = note?.isArchived;
const parentNote = isNotRoot && branch ? await froca.getNote(branch.parentNoteId) : null;
// some actions don't support multi-note, so they are disabled when notes are selected,
@@ -189,6 +191,19 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Tree
enabled: parentNotSearch && isNotRoot && !isHoisted && notOptionsOrHelp
},
+ {
+ title: !isArchived ? t("tree-context-menu.archive") : t("tree-context-menu.unarchive"),
+ uiIcon: !isArchived ? "bx bx-archive" : "bx bx-archive-out",
+ handler: () => {
+ if (!note) return;
+ if (!isArchived) {
+ attributes.addLabel(note.noteId, "archived");
+ } else {
+ attributes.removeOwnedLabelByName(note, "archived");
+ }
+ },
+ enabled: noSelectedNotes
+ },
{
title: `${t("tree-context-menu.delete")} <kbd data-command="deleteNotes"></kbd>`,
command: "deleteNotes",
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index c084cf7ec5..6a615ecef6 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1594,6 +1594,8 @@
"open-in-a-new-split": "Open in a new split",
"insert-note-after": "Insert note after",
"insert-child-note": "Insert child note",
+ "archive": "Archive",
+ "unarchive": "Unarchive",
"delete": "Delete",
"search-in-subtree": "Search in subtree",
"hoist-note": "Hoist note",