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
client/collections/board: mark archived columns as archived in the item menu -> "Move to" submenu
Adorian Doran5703fa0994ab
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 465ef5c945..87c39ca1ed 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3353,6 +3353,7 @@"delete-column": "Delete column...","archive-column": "Archive column","unarchive-column": "Unarchive column",+ "archived-badge": "Archived","delete-column-confirmation": "Are you sure you want to delete this column? The corresponding attribute will be deleted in the notes under this column as well.","new-item": "New item","new-item-placeholder": "Enter note title...",diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.tsindex cea99b6b35..a9a9cf4bf9 100644--- a/apps/client/src/widgets/collections/board/api.ts+++ b/apps/client/src/widgets/collections/board/api.ts@@ -190,6 +190,11 @@ export default class BoardApi {this.updateColumn(column, { color: color ?? undefined });}+ /** Whether a column is archived, which the board shows only while archived notes are shown. */+ isColumnArchived(column: string) {+ return !!this.viewConfig?.columns?.find(col => col.value === column)?.archived;+ }+/*** Archives a column or brings it back. An archived one is shown only while the board is set to* show archived notes, and greyed out where it is.diff --git a/apps/client/src/widgets/collections/board/context_menu.spec.ts b/apps/client/src/widgets/collections/board/context_menu.spec.tsindex 160ad82d7d..0ba51f1640 100644--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts@@ -4,8 +4,15 @@ import { afterEach, describe, expect, it, vi } from "vitest";import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";import dialog from "../../../services/dialog";+import FNote from "../../../entities/fnote";+import { buildNote } from "../../../test/easy-froca";import BoardApi from "./api";-import { openColumnContextMenu } from "./context_menu";+import { openColumnContextMenu, openNoteContextMenu } from "./context_menu";++// The card menu opens with the shared link items, which reach for the active note context.+vi.mock("../../../menus/link_context_menu", () => ({+ default: { getItems: () => [], handleLinkContextMenuItem: () => {} }+}));describe("Board column context menu", () => {let container: HTMLElement | undefined;@@ -176,3 +183,34 @@ describe("Board column context menu", () => {expect(api.setColumnColor).toHaveBeenLastCalledWith("To Do", null);});});++describe("Board item context menu", () => {+ afterEach(() => vi.restoreAllMocks());++ it("marks the archived columns it offers to move a card to", () => {+ const show = vi.spyOn(contextMenu, "show").mockImplementation(async () => {});+ const api = {+ columns: [ "To Do", "Done" ],+ isColumnArchived: (column: string) => column === "Done"+ } as unknown as BoardApi;+ const event = {+ preventDefault: () => {},+ stopPropagation: () => {},+ pageX: 0,+ pageY: 0+ } as ContextMenuEvent;++ openNoteContextMenu(api, event, buildNote({ title: "Card" }) as FNote, "branchId", "To Do");++ const items = show.mock.calls.at(-1)?.[0].items ?? [];+ const moveTo = items.find(item =>+ item && "uiIcon" in item && item.uiIcon === "bx bx-transfer");+ if (!moveTo || !("items" in moveTo)) throw new Error("expected a move-to entry");++ // Presence rather than wording: i18next is never initialised under test, so every title is+ // undefined and asserting the text would prove nothing.+ expect((moveTo.items ?? [])+ .map(item => !!(item && "badges" in item && item.badges?.length)))+ .toEqual([ false, true ]);+ });+});diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.tsindex 90efa51ddd..582e8d3e23 100644--- a/apps/client/src/widgets/collections/board/context_menu.ts+++ b/apps/client/src/widgets/collections/board/context_menu.ts@@ -145,9 +145,14 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, note: FNo{title: t("board_view.move-to"),uiIcon: "bx bx-transfer",+ // Archived columns are offered like any other, since moving a card into one is a+ // fair thing to want; the badge is there so it is not a surprise when it goes.items: api.columns.map(columnToMoveTo => ({title: columnToMoveTo,enabled: columnToMoveTo !== column,+ badges: api.isColumnArchived(columnToMoveTo)+ ? [ { title: t("board_view.archived-badge") } ]+ : undefined,handler: () => api.changeColumn(note.noteId, columnToMoveTo)})),},