Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(in-app-help): in-app help buttons not pointing to the right page
Elian Doranbe5e2f529fa3
diff --git a/src/public/app/widgets/floating_buttons/help_button.spec.ts b/src/public/app/widgets/floating_buttons/help_button.spec.tsnew file mode 100644index 0000000000..b59d3b50d2--- /dev/null+++ b/src/public/app/widgets/floating_buttons/help_button.spec.ts@@ -0,0 +1,37 @@+import { describe, expect, it } from "vitest";+import { byBookType, byNoteType } from "./help_button.js";+import fs from "fs";+import type { NoteMetaFile } from "../../../../services/meta/note_meta.js";+import type NoteMeta from "../../../../services/meta/note_meta.js";++describe("Help button", () => {+ it("All help notes are accessible", () => {+ function getNoteIds(item: NoteMeta | NoteMetaFile): string[] {+ const items = [];++ if ("noteId" in item && item.noteId) {+ items.push(item.noteId);+ }++ const children = "files" in item ? item.files : item.children;+ for (const child of children ?? []) {+ items.push(getNoteIds(child));+ }+ return items.flat();+ }++ const allHelpNotes = [+ ...Object.values(byNoteType),+ ...Object.values(byBookType)+ ].filter((noteId) => noteId) as string[];++ const meta: NoteMetaFile = JSON.parse(fs.readFileSync("src/public/app/doc_notes/en/User Guide/!!!meta.json", "utf-8"));+ const allNoteIds = new Set(getNoteIds(meta));++ for (const helpNote of allHelpNotes) {+ if (!allNoteIds.has(helpNote)) {+ expect.fail(`Help note with ID ${helpNote} does not exist in the in-app help.`);+ }+ }+ });+});diff --git a/src/public/app/widgets/floating_buttons/help_button.ts b/src/public/app/widgets/floating_buttons/help_button.tsindex be860f276b..b14bfb7b7a 100644--- a/src/public/app/widgets/floating_buttons/help_button.ts+++ b/src/public/app/widgets/floating_buttons/help_button.ts@@ -12,13 +12,13 @@ const TPL = `</button>`;-const byNoteType: Record<Exclude<NoteType, "book">, string | null> = {+export const byNoteType: Record<Exclude<NoteType, "book">, string | null> = {canvas: null,code: null,contentWidget: null,doc: null,file: null,- geoMap: "foPEtsL51pD2",+ geoMap: "81SGnPGMk7Xc",image: null,launcher: null,mermaid: null,@@ -31,10 +31,10 @@ const byNoteType: Record<Exclude<NoteType, "book">, string | null> = {webView: null};-const byBookType: Record<ViewTypeOptions, string | null> = {+export const byBookType: Record<ViewTypeOptions, string | null> = {list: null,grid: null,- calendar: "fDGg7QcJg3Xm"+ calendar: "xWbu3jpNWapp"};export default class ContextualHelpButton extends NoteContextAwareWidget {