Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: reorganize the column menu

Adorian Doran9e599c05b4d5
diff --git a/apps/client/src/widgets/collections/board/context_menu.spec.ts b/apps/client/src/widgets/collections/board/context_menu.spec.ts
index c64b06ecf5..ffbbe54622 100644
--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts
@@ -228,13 +228,23 @@ describe("Board column context menu", () => {
const titled = openMenu({} as BoardApi).filter(item => item && "uiIcon" in item);
expect(titled.map(item => "uiIcon" in item ? item.uiIcon : undefined))
.toEqual([
- "bx bx-edit-alt", "bx bx-collapse-horizontal", "bx bx-lock-alt", "bx bx-tachometer",
- "bx bx-plus", "bx bx-link",
- "bx bx-columns", "bx bx-sort-alt-2", "bx bx-horizontal-left", "bx bx-archive",
- "bx bx-trash"
+ "bx bx-edit-alt",
+ "bx bx-plus", "bx bx-link", "bx bx-columns",
+ "bx bx-collapse-horizontal", "bx bx-lock-alt", "bx bx-sort-alt-2",
+ "bx bx-tachometer",
+ "bx bx-horizontal-left",
+ "bx bx-archive", "bx bx-trash"
]);
});
+ /** A collapsed column offers no rename, so the group above the first divider is empty. */
+ it("opens on an entry rather than a divider when it has nothing to rename", () => {
+ const items = openMenu({} as BoardApi, { canRename: false, isCollapsed: true });
+
+ expect(items[0]).not.toMatchObject({ kind: "separator" });
+ expect(items[0]).toMatchObject({ uiIcon: "bx bx-plus" });
+ });
+
/** Every place offered has to actually move the column, or the menu promises nothing. */
it("offers only the places that would move the column", () => {
const api = {
diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.ts
index d6facbe40d..47ae3f3e3e 100644
--- a/apps/client/src/widgets/collections/board/context_menu.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.ts
@@ -57,41 +57,29 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:
event.preventDefault();
event.stopPropagation();
+ // What the column is, which a collapsed column that is not the inbox has nothing of. Kept in
+ // a group of its own only while it holds something, or the menu opens on a divider.
+ const identity: MenuItem<string>[] = [
+ ...(column.canRename ? [ {
+ title: t("board_view.rename-column"),
+ uiIcon: "bx bx-edit-alt",
+ shortcut: "F2",
+ handler: column.onEditTitle
+ } ] : []),
+ ...(isInbox ? [ {
+ title: t("board_view.inbox-nested"),
+ uiIcon: "bx bx-subdirectory-right",
+ checked: !!column.nested,
+ handler: () => api.setInboxNested(!column.nested)
+ } ] : [])
+ ];
+
contextMenu.show({
x: event.pageX,
y: event.pageY,
items: [
- ...(column.canRename ? [ {
- title: t("board_view.rename-column"),
- uiIcon: "bx bx-edit-alt",
- shortcut: "F2",
- handler: column.onEditTitle
- } ] : []),
- // Already a strip, so there is nothing to collapse.
- ...(column.isCollapsed ? [] : [ {
- title: t("board_view.collapse-column"),
- uiIcon: "bx bx-collapse-horizontal",
- handler: () => column.onCollapse(true)
- } ]),
- {
- title: t("board_view.keep-column-collapsed"),
- uiIcon: "bx bx-lock-alt",
- // At the trailing edge, so the entry keeps its own icon in front.
- trailingIcon: column.keepCollapsed ? "bx bx-check" : undefined,
- handler: () => column.onKeepCollapsed(!column.keepCollapsed)
- },
- {
- title: t("board_view.set-limit"),
- uiIcon: "bx bx-tachometer",
- handler: column.onSetLimit
- },
- ...(isInbox ? [ {
- title: t("board_view.inbox-nested"),
- uiIcon: "bx bx-subdirectory-right",
- checked: !!column.nested,
- handler: () => api.setInboxNested(!column.nested)
- } ] : []),
- { kind: "separator" },
+ ...identity,
+ ...(identity.length ? [ { kind: "separator" } as MenuItem<string> ] : []),
{
title: t("board_view.add-new-item"),
uiIcon: "bx bx-plus",
@@ -127,11 +115,30 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:
]
},
{ kind: "separator" },
+ // Already a strip, so there is nothing to collapse.
+ ...(column.isCollapsed ? [] : [ {
+ title: t("board_view.collapse-column"),
+ uiIcon: "bx bx-collapse-horizontal",
+ handler: () => column.onCollapse(true)
+ } ]),
+ {
+ title: t("board_view.keep-column-collapsed"),
+ uiIcon: "bx bx-lock-alt",
+ // At the trailing edge, so the entry keeps its own icon in front.
+ trailingIcon: column.keepCollapsed ? "bx bx-check" : undefined,
+ handler: () => column.onKeepCollapsed(!column.keepCollapsed)
+ },
{
title: t("board_view.sort"),
uiIcon: "bx bx-sort-alt-2",
items: buildSortItems(api, column.value)
},
+ {
+ title: t("board_view.set-limit"),
+ uiIcon: "bx bx-tachometer",
+ handler: column.onSetLimit
+ },
+ { kind: "separator" },
{
title: t("board_view.move-column"),
uiIcon: "bx bx-horizontal-left",