Skip to content

Build your personal knowledge base with Trilium Notes

client/content manager: add extra information for items

Adorian Doran987baec24fba
diff --git a/apps/client/src/services/content_manager.spec.ts b/apps/client/src/services/content_manager.spec.ts
index bec46c64f5..3e50071b1e 100644
--- a/apps/client/src/services/content_manager.spec.ts
+++ b/apps/client/src/services/content_manager.spec.ts
@@ -191,6 +191,25 @@ describe("resolveProperties", () => {
expect(resolveProperties(buildNote({ title: "T" }), category)).toEqual([]);
});
+ it("describes the instance restriction and the workspace scope of real categories", () => {
+ const script = buildNote({ title: "S", "#run": "daily", "#runOnInstance": "main" });
+
+ expect(resolveProperties(script, categoryById("backendScripts"))).toEqual([
+ { titleKey: "content_manager.property_trigger", values: [ { titleKey: "content_manager.trigger_daily" } ] },
+ { titleKey: "content_manager.property_instance", values: [ { text: "main" } ] }
+ ]);
+
+ // The bare `workspaceTemplate` condition is a presence test, so an unrestricted template
+ // shows no scope at all.
+ const workspace = buildNote({ title: "W", "#template": "", "#workspaceTemplate": "" });
+ const plain = buildNote({ title: "P", "#template": "" });
+
+ expect(resolveProperties(workspace, categoryById("templates"))).toEqual([
+ { titleKey: "content_manager.property_scope", values: [ { titleKey: "content_manager.scope_workspace" } ] }
+ ]);
+ expect(resolveProperties(plain, categoryById("templates"))).toEqual([]);
+ });
+
it("returns nothing for a category that declares no properties", () => {
expect(resolveProperties(buildNote({ title: "X", "#appCss": "" }), categoryById("customCss"))).toEqual([]);
});
diff --git a/apps/client/src/services/content_manager.ts b/apps/client/src/services/content_manager.ts
index a51302eda9..c8d1cab51e 100644
--- a/apps/client/src/services/content_manager.ts
+++ b/apps/client/src/services/content_manager.ts
@@ -57,14 +57,22 @@ export const CONTENT_CATEGORIES: ContentCategory[] = [
titleKey: "content_manager.category_backend_scripts",
filter: "#run = backendStartup OR #run = hourly OR #run = daily"
+ " OR #disabled:run = backendStartup OR #disabled:run = hourly OR #disabled:run = daily",
- properties: [ {
- titleKey: "content_manager.property_trigger",
- values: [
- { titleKey: "content_manager.trigger_backend_startup", condition: { label: "run", is: "backendStartup" } },
- { titleKey: "content_manager.trigger_hourly", condition: { label: "run", is: "hourly" } },
- { titleKey: "content_manager.trigger_daily", condition: { label: "run", is: "daily" } }
- ]
- } ]
+ properties: [
+ {
+ titleKey: "content_manager.property_trigger",
+ values: [
+ { titleKey: "content_manager.trigger_backend_startup", condition: { label: "run", is: "backendStartup" } },
+ { titleKey: "content_manager.trigger_hourly", condition: { label: "run", is: "hourly" } },
+ { titleKey: "content_manager.trigger_daily", condition: { label: "run", is: "daily" } }
+ ]
+ },
+ {
+ // The scheduler skips the script on any instance not named here, so a script can look
+ // enabled yet never run.
+ titleKey: "content_manager.property_instance",
+ values: [ { valueOfLabel: "runOnInstance" } ]
+ }
+ ]
},
{
id: "frontendScripts",
@@ -115,7 +123,12 @@ export const CONTENT_CATEGORIES: ContentCategory[] = [
{
id: "templates",
titleKey: "content_manager.category_templates",
- filter: "#template OR #disabled:template"
+ filter: "#template OR #disabled:template",
+ properties: [ {
+ titleKey: "content_manager.property_scope",
+ // A bare condition tests only that the label is present.
+ values: [ { titleKey: "content_manager.scope_workspace", condition: { label: "workspaceTemplate" } } ]
+ } ]
},
{
id: "snippets",
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 4b94408f2e..d636580cac 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2613,6 +2613,9 @@
"toggle_enable": "Enable",
"toggle_disable": "Disable",
"property_trigger": "Trigger",
+ "property_instance": "Instance",
+ "property_scope": "Scope",
+ "scope_workspace": "Workspace",
"property_base_theme": "Base theme",
"property_prefix": "Prefix",
"trigger_backend_startup": "Backend startup",