Skip to content

Build your personal knowledge base with Trilium Notes

feat(collections/dashboard): add as a beta collection

Elian Doranaa7ad652dc37
diff --git a/apps/client/src/services/note_types.ts b/apps/client/src/services/note_types.ts
index e12e3c5440..3ba92aee1f 100644
--- a/apps/client/src/services/note_types.ts
+++ b/apps/client/src/services/note_types.ts
@@ -186,8 +186,15 @@ async function getBuiltInTemplates(title: string | null, command: TreeCommandNam
templateNoteId: templateNote.noteId
};
+ const badges: MenuItemBadge[] = [];
if (await isNewTemplate(templateNote.noteId)) {
- item.badges = [NEW_BADGE];
+ badges.push(NEW_BADGE);
+ }
+ if (templateNote.hasLabel("beta")) {
+ badges.push(BETA_BADGE);
+ }
+ if (badges.length > 0) {
+ item.badges = badges;
}
items.push(item);
diff --git a/apps/server/src/assets/translations/en/server.json b/apps/server/src/assets/translations/en/server.json
index fb5e9773a6..8c77e157d8 100644
--- a/apps/server/src/assets/translations/en/server.json
+++ b/apps/server/src/assets/translations/en/server.json
@@ -419,7 +419,8 @@
"presentation_slide": "Presentation slide",
"presentation_slide_first": "First slide",
"presentation_slide_second": "Second slide",
- "background": "Background"
+ "background": "Background",
+ "dashboard": "Dashboard"
},
"sql_init": {
"db_not_initialized_desktop": "DB not initialized, please follow on-screen instructions.",
diff --git a/packages/trilium-core/src/services/hidden_subtree_templates.spec.ts b/packages/trilium-core/src/services/hidden_subtree_templates.spec.ts
index fc8be179a7..80d30d3084 100644
--- a/packages/trilium-core/src/services/hidden_subtree_templates.spec.ts
+++ b/packages/trilium-core/src/services/hidden_subtree_templates.spec.ts
@@ -46,7 +46,8 @@ describe("buildHiddenSubtreeTemplates", () => {
"_template_geo_map",
"_template_board",
"_template_presentation_slide",
- "_template_presentation"
+ "_template_presentation",
+ "_template_dashboard"
]);
// No duplicate ids.
expect(new Set(ids).size).toBe(ids.length);
@@ -62,6 +63,7 @@ describe("buildHiddenSubtreeTemplates", () => {
expect(viewTypeOf(childById(templates, "_template_geo_map"))).toBe("geoMap");
expect(viewTypeOf(childById(templates, "_template_board"))).toBe("board");
expect(viewTypeOf(childById(templates, "_template_presentation"))).toBe("presentation");
+ expect(viewTypeOf(childById(templates, "_template_dashboard"))).toBe("dashboard");
});
it("flags collection templates as templates and as collections", () => {
@@ -73,7 +75,8 @@ describe("buildHiddenSubtreeTemplates", () => {
"_template_table",
"_template_geo_map",
"_template_board",
- "_template_presentation"
+ "_template_presentation",
+ "_template_dashboard"
];
for (const id of collectionIds) {
@@ -84,6 +87,15 @@ describe("buildHiddenSubtreeTemplates", () => {
}
});
+ it("marks the dashboard collection template as beta", () => {
+ const templates = buildHiddenSubtreeTemplates();
+ const dashboard = childById(templates, "_template_dashboard");
+
+ const beta = dashboard.attributes?.find((a) => a.name === "beta");
+ expect(beta).toBeDefined();
+ expect(beta?.type).toBe("label");
+ });
+
it("configures the text snippet template as a text note with promoted description", () => {
const templates = buildHiddenSubtreeTemplates();
const snippet = childById(templates, "_template_text_snippet");
diff --git a/packages/trilium-core/src/services/hidden_subtree_templates.ts b/packages/trilium-core/src/services/hidden_subtree_templates.ts
index 80ced0d94b..5e81c9fca9 100644
--- a/packages/trilium-core/src/services/hidden_subtree_templates.ts
+++ b/packages/trilium-core/src/services/hidden_subtree_templates.ts
@@ -358,6 +358,32 @@ export default function buildHiddenSubtreeTemplates() {
]
}
]
+ },
+ {
+ id: "_template_dashboard",
+ type: "book",
+ title: t("hidden_subtree_templates.dashboard"),
+ icon: "bx bxs-dashboard",
+ attributes: [
+ {
+ name: "template",
+ type: "label"
+ },
+ {
+ name: "collection",
+ type: "label"
+ },
+ {
+ name: "viewType",
+ type: "label",
+ value: "dashboard"
+ },
+ {
+ // Marks the collection as a beta feature in the note creation menu.
+ name: "beta",
+ type: "label"
+ }
+ ]
}
]
};