Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: remove the limit option for the inbox column

Adorian Dorana50ffe706396
diff --git a/apps/client/src/widgets/collections/board/api.spec.ts b/apps/client/src/widgets/collections/board/api.spec.ts
index 58a269139a..5fb7edee5f 100644
--- a/apps/client/src/widgets/collections/board/api.spec.ts
+++ b/apps/client/src/widgets/collections/board/api.spec.ts
@@ -2006,6 +2006,25 @@ describe("filing a card under the inbox", () => {
});
});
+describe("the limit set on a column", () => {
+ /**
+ * The inbox is where every card without a grouping value goes, so a limit there is not
+ * enforceable. One stored by an older board is read as none.
+ */
+ it("reads no limit for the inbox and writes none to it", async () => {
+ const { api, saved } = createApi(
+ { columns: [ { value: "", limit: 2 }, { value: "To Do", limit: 3 } ] },
+ [ "", "To Do" ]);
+
+ expect(api.getColumnLimit("")).toBeUndefined();
+ expect(api.getColumnLimit("To Do")).toBe(3);
+
+ await api.setColumnLimit("", 5);
+
+ expect(saved).toHaveLength(0);
+ });
+});
+
describe("the promoted attributes a card shows", () => {
/** A board defining two promoted labels, which is what the cards can show. */
function boardWithAttributes() {
diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.ts
index 8483f5051d..0a1940c048 100644
--- a/apps/client/src/widgets/collections/board/api.ts
+++ b/apps/client/src/widgets/collections/board/api.ts
@@ -739,13 +739,21 @@ export default class BoardApi {
await attributes.setLabel(note.noteId, COLUMN_WIDTH_LABEL, width);
}
- /** The note limit set for a column, absent if disabled. */
+ /** The note limit set for a column, absent if disabled or for the inbox. */
getColumnLimit(column: string) {
+ if (column === INBOX_COLUMN) {
+ return undefined;
+ }
+
return this.storedColumns.find(col => col.value === column)?.limit;
}
/** Sets a column's note limit. Pass `undefined` to disable it. */
async setColumnLimit(column: string, limit: number | undefined) {
+ if (column === INBOX_COLUMN) {
+ return;
+ }
+
await this.updateColumn(column, { limit });
}
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 1bb6dce030..6f12b9fa8d 100644
--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts
@@ -199,10 +199,10 @@ describe("Board column context menu", () => {
/**
* The inbox holds a name of its own, so it is renamed like any other column; what it has not
- * is anything to archive, or anywhere to go, and it is put away by the board's own setting
- * instead.
+ * is anything to archive, anywhere to go or a limit, and it is put away by the board's own
+ * setting instead.
*/
- it("offers the inbox no archive and no move, and puts it away instead", () => {
+ it("offers the inbox no archive, move or limit, and puts it away instead", () => {
const api = {
getColumnIcon: () => DEFAULT_COLUMN_ICON,
getColumnColorClass: () => "",
@@ -219,6 +219,9 @@ describe("Board column context menu", () => {
expect(icons).not.toContain("bx bx-archive");
// The inbox leads the board and cannot be moved off the head of it.
expect(icons).not.toContain("bx bx-horizontal-left");
+ // The inbox is where every card without a grouping value goes, so a limit there is not
+ // enforceable.
+ expect(icons).not.toContain("bx bx-tachometer");
const remove = items.find(item =>
item && "uiIcon" in item && item.uiIcon === "bx bx-trash");
diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.ts
index 12a76e3721..fc694fdfff 100644
--- a/apps/client/src/widgets/collections/board/context_menu.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.ts
@@ -144,11 +144,13 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:
uiIcon: "bx bx-sort-alt-2",
items: buildSortMenuItems<string>(sortMenuOptions(api, column.value))
},
- {
+ // The inbox is where every card without a grouping value goes, so a limit there is
+ // not enforceable.
+ ...(isInbox ? [] : [ {
title: t("board_view.set-limit"),
uiIcon: "bx bx-tachometer",
handler: column.onSetLimit
- },
+ } ]),
{ kind: "separator" },
// The inbox leads the board and `moveColumn` refuses to move it, so it is not offered.
...(isInbox ? [] : [ {
diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsx
index 7abac0db08..64c466cbee 100644
--- a/apps/client/src/widgets/collections/board/index.tsx
+++ b/apps/client/src/widgets/collections/board/index.tsx
@@ -1485,7 +1485,7 @@ export default function BoardView({
: 0}
cardTemplates={cardTemplates}
nested={storedColumns.get(column)?.nested}
- limit={storedColumns.get(column)?.limit}
+ limit={api.getColumnLimit(column)}
columnIndex={index}
columns={shownColumns}
onMoveColumn={handleColumnDrop}