Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: add a "Board properties" command to collection options

Adorian Doran1b59980faa35
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsx
index 9e75cf0e26..59cc8fc148 100644
--- a/apps/client/src/widgets/collections/board/index.spec.tsx
+++ b/apps/client/src/widgets/collections/board/index.spec.tsx
@@ -4229,10 +4229,38 @@ describe("Board properties from the note menu", () => {
expect(isOpen()).toBe(true);
});
+ /**
+ * The same dialog from the collection bar, where it sits last in the settings menu so that
+ * the view options above it stay together.
+ */
+ it("opens the dialog from the collection settings menu, below a divider", async () => {
+ await renderBoardInContext("ntx-1");
+
+ const cog = container?.querySelector<HTMLElement>(".collection-properties button.bx-cog");
+ const options = cog?.closest(".dropdown");
+ if (!options) throw new Error("expected a settings menu on the collection bar");
+ await act(async () => {
+ $(options as HTMLElement).trigger("show.bs.dropdown");
+ await flush();
+ });
+
+ const entry = [ ...options.querySelectorAll<HTMLElement>(".dropdown-item") ].at(-1);
+ if (!entry) throw new Error("expected an entry in the settings menu");
+ expect(entry.textContent).toContain("board_view.properties");
+ expect(entry.previousElementSibling?.className).toContain("dropdown-divider");
+
+ await act(async () => {
+ entry.click();
+ await flush();
+ });
+ expect(document.querySelector(".board-properties-dialog .modal-dialog")).toBeTruthy();
+ });
+
/** Mounts a board belonging to the given tab, returning what events reach it through. */
async function renderBoardInContext(ntxId: string) {
const note = buildNote({
title: "Board",
+ type: "book",
"#collection": "",
"#viewType": "board",
children: [
diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsx
index 2941ad830b..fe7be63ae1 100644
--- a/apps/client/src/widgets/collections/board/index.tsx
+++ b/apps/client/src/widgets/collections/board/index.tsx
@@ -28,6 +28,7 @@ import { type NoteTypeOption, resolveNoteTypeOptions } from "../../../services/n
import { type PromotedAttributeSetting, resolvePromotedAttributes } from "../promoted_attributes";
import type { SortContext } from "../sorting";
import CollectionProperties from "../../note_bars/CollectionProperties";
+import { FormListItem } from "../../react/FormList";
import FormTextArea from "../../react/FormTextArea";
import FormTextBox from "../../react/FormTextBox";
import {
@@ -1233,6 +1234,12 @@ export default function BoardView({
/>
<CollectionProperties
note={parentNote}
+ optionsChildren={
+ <FormListItem
+ icon="bx bx-cog"
+ onClick={() => setIsEditingProperties(true)}
+ >{t("board_view.properties")}</FormListItem>
+ }
rightChildren={<>
<BoardGroupBy
note={parentNote}
diff --git a/apps/client/src/widgets/note_bars/CollectionProperties.tsx b/apps/client/src/widgets/note_bars/CollectionProperties.tsx
index bfcd52b30a..2b1368a324 100644
--- a/apps/client/src/widgets/note_bars/CollectionProperties.tsx
+++ b/apps/client/src/widgets/note_bars/CollectionProperties.tsx
@@ -41,10 +41,12 @@ export const VIEW_TYPE_MAPPINGS: Record<ViewTypeOptions, string> = {
const MAX_OPEN_TABS = 50;
-export default function CollectionProperties({ note, centerChildren, rightChildren }: {
+export default function CollectionProperties({ note, centerChildren, rightChildren, optionsChildren }: {
note: FNote;
centerChildren?: ComponentChildren;
rightChildren?: ComponentChildren;
+ /** Entries appended below a divider at the end of the settings dropdown. */
+ optionsChildren?: ComponentChildren;
}) {
const [ viewType, setViewType ] = useViewType(note);
const noteType = useNoteProperty(note, "type");
@@ -54,7 +56,7 @@ export default function CollectionProperties({ note, centerChildren, rightChildr
<div className="collection-properties">
<div className="left-container">
<ViewTypeSwitcher viewType={viewType} setViewType={setViewType} />
- <ViewOptions note={note} viewType={viewType} />
+ <ViewOptions note={note} viewType={viewType} optionsChildren={optionsChildren} />
</div>
<div className="center-container">
{centerChildren}
@@ -151,7 +153,11 @@ function ViewTypeSwitcher({ viewType, setViewType }: { viewType: ViewTypeOptions
);
}
-function ViewOptions({ note, viewType }: { note: FNote, viewType: ViewTypeOptions }) {
+function ViewOptions({ note, viewType, optionsChildren }: {
+ note: FNote,
+ viewType: ViewTypeOptions,
+ optionsChildren?: ComponentChildren
+}) {
const properties = bookPropertiesConfig[viewType].properties;
return (
@@ -180,6 +186,11 @@ function ViewOptions({ note, viewType }: { note: FNote, viewType: ViewTypeOption
label: t("book_properties.include_archived_notes"),
bindToLabel: "includeArchived"
} as CheckBoxProperty} />
+
+ {optionsChildren && <>
+ <FormDropdownDivider />
+ {optionsChildren}
+ </>}
</Dropdown>
);
}