Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(collections/board): unarchive note
Elian Doran3175b75192dc
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex c6d0bdac3a..98797051bc 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1998,6 +1998,7 @@"board_view": {"delete-note": "Delete Note","archive-note": "Archive Note",+ "unarchive-note": "Unarchive Note","move-to": "Move to","insert-above": "Insert above","insert-below": "Insert below",diff --git a/apps/client/src/widgets/collections/board/card.tsx b/apps/client/src/widgets/collections/board/card.tsxindex b80510f615..68c1c1a377 100644--- a/apps/client/src/widgets/collections/board/card.tsx+++ b/apps/client/src/widgets/collections/board/card.tsx@@ -43,7 +43,7 @@ export default function Card({}, [note.noteId, branch.branchId, column, index]);const handleContextMenu = useCallback((e: ContextMenuEvent) => {- openNoteContextMenu(api, e, note.noteId, branch.branchId, column);+ openNoteContextMenu(api, e, note, branch.branchId, column);}, [ api, note, branch, column ]);const handleOpen = useCallback(() => {diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.tsindex a2489fcf2d..9e4a98465c 100644--- a/apps/client/src/widgets/collections/board/context_menu.ts+++ b/apps/client/src/widgets/collections/board/context_menu.ts@@ -1,3 +1,4 @@+import FNote from "../../../entities/fnote";import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";import link_context_menu from "../../../menus/link_context_menu";import attributes from "../../../services/attributes";@@ -31,7 +32,7 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:});}-export function openNoteContextMenu(api: Api, event: ContextMenuEvent, noteId: string, branchId: string, column: string) {+export function openNoteContextMenu(api: Api, event: ContextMenuEvent, note: FNote, branchId: string, column: string) {event.preventDefault();event.stopPropagation();@@ -47,7 +48,7 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, noteId: sitems: api.columns.map(columnToMoveTo => ({title: columnToMoveTo,enabled: columnToMoveTo !== column,- handler: () => api.changeColumn(noteId, columnToMoveTo)+ handler: () => api.changeColumn(note.noteId, columnToMoveTo)}))},{ title: "----" },@@ -67,12 +68,26 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, noteId: suiIcon: "bx bx-trash",handler: () => branches.deleteNotes([ branchId ], false, false)},- {- title: t("board_view.archive-note"),- uiIcon: "bx bx-archive",- handler: () => attributes.addLabel(noteId, "archived")- }+ getArchiveMenuItem(note)],- selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, noteId),+ selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, note.noteId),});}++function getArchiveMenuItem(note: FNote) {+ if (!note.isArchived) {+ return {+ title: t("board_view.archive-note"),+ uiIcon: "bx bx-archive",+ handler: () => attributes.addLabel(note.noteId, "archived")+ }+ } else {+ return {+ title: t("board_view.unarchive-note"),+ uiIcon: "bx bx-archive-out",+ handler: async () => {+ attributes.removeOwnedLabelByName(note, "archived")+ }+ }+ }+}