From 3175b75192dc6c068b01e867eaf55a8e02d1cef0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 12 Sep 2025 22:08:32 +0300 Subject: [PATCH] feat(collections/board): unarchive note --- .../src/translations/en/translation.json | 1 + .../src/widgets/collections/board/card.tsx | 2 +- .../widgets/collections/board/context_menu.ts | 31 ++++++++++++++----- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index c6d0bdac3..98797051b 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.tsx index b80510f61..68c1c1a37 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.ts index a2489fcf2..9e4a98465 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: s items: 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: s uiIcon: "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") + } + } + } +}