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
feat(setup): show setup errors as an extended admonition
Elian Doranf6b50097ac8c
diff --git a/apps/client/src/setup.spec.tsx b/apps/client/src/setup.spec.tsxindex c3691de975..9aaa5e7e9b 100644--- a/apps/client/src/setup.spec.tsx+++ b/apps/client/src/setup.spec.tsx@@ -451,7 +451,8 @@ describe("SyncFromServer", () => {await flushEffects();expect(window.glob.hasExistingData).toBe(false);- expect(c.querySelector(".page-error")?.textContent).toContain("setup.sync-failed");+ expect(c.querySelector(".page-error .admonition-title")?.textContent).toBe("setup.sync-from-server-failed");+ expect(c.querySelector(".page-error-message")?.textContent).toBe("the disk is full");});it("keeps it where the server refused the credentials, which erases nothing", async () => {diff --git a/apps/client/src/setup.tsx b/apps/client/src/setup.tsxindex 9116177c6c..0a483eb3a9 100644--- a/apps/client/src/setup.tsx+++ b/apps/client/src/setup.tsx@@ -690,7 +690,7 @@ export function SyncFromServer({ setState }: { setState: (state: State) => voidif (resp.error.includes("Incorrect password")) {setIsWrongPassword(true);} else {- raiseError(t("setup.sync-failed", { message: resp.error }));+ raiseError(resp.error);}} catch (e) {raiseError(e instanceof Error ? e.message : String(e));@@ -704,6 +704,7 @@ export function SyncFromServer({ setState }: { setState: (state: State) => voiddescription={t("setup.sync-from-server-page-description")}illustration={<SyncIllustration targetDevice="server" />}error={error}+ errorTitle={t("setup.sync-from-server-failed")}errorId={errorId}onBack={() => setState("firstOptions")}footer={<Button text={t("setup.button-finish-setup")} kind="primary" onClick={handleFinishSetup} disabled={!isValid} />}diff --git a/apps/client/src/translations/en/entry.json b/apps/client/src/translations/en/entry.jsonindex c77246d833..f554d03517 100644--- a/apps/client/src/translations/en/entry.json+++ b/apps/client/src/translations/en/entry.json@@ -67,7 +67,7 @@"sync-from-desktop-unreachable-description": "To sync, the other desktop has to connect to this one over the network. For security, this desktop app only accepts connections from this computer, so that other desktop can't reach it yet. Allow network access below — Trilium will restart to apply it.","sync-from-desktop-allow-access": "Allow network access & restart","advanced-options": "Advanced options",- "sync-failed": "Failed to sync: {{- message}}",+ "sync-from-server-failed": "Failed to sync","sync-failed-title": "Sync failed","sync-failed-description": "The initial synchronization could not be completed. You can retry, or go back to check the server address and credentials.","sync-failed-admonition-title": "The last sync attempt failed",diff --git a/apps/client/src/widgets/react/SetupPage.tsx b/apps/client/src/widgets/react/SetupPage.tsxindex 9c9541e125..f4bffb47f4 100644--- a/apps/client/src/widgets/react/SetupPage.tsx+++ b/apps/client/src/widgets/react/SetupPage.tsx@@ -5,7 +5,7 @@ import { useEffect, useState } from "preact/hooks";import { t } from "../../services/i18n";import { replaceHtmlEscapedSlashes } from "../../services/utils";import ActionButton from "./ActionButton";-import Admonition from "./Admonition";+import { ExtendedAdmonition } from "./Admonition";import Button from "./Button";/**@@ -15,7 +15,7 @@ import Button from "./Button";* sticky footer) on top of the gradient background defined by `body.setup` in* `setup.css`. Consumers are expected to mount this inside a `.setup-container`.*/-export default function SetupPage({ title, description, className, illustration, children, footer, error, errorId, onBack }: {+export default function SetupPage({ title, description, className, illustration, children, footer, error, errorTitle, errorId, onBack }: {title: string;description?: string;/**@@ -23,6 +23,8 @@ export default function SetupPage({ title, description, className, illustration,* with the technical detail underneath it rather than in place of it.*/error?: ComponentChildren;+ /** Heading above `error` that names what failed. Without it, the icon sits beside the message. */+ errorTitle?: string;errorId?: number;className?: string;illustration?: ComponentChildren;@@ -49,12 +51,14 @@ export default function SetupPage({ title, description, className, illustration,/>)}{error && showError && (- <Admonition className="page-error" type="caution">+ <ExtendedAdmonition className="page-error" type="caution" icon="bx bx-error-circle" title={errorTitle}><ActionButton icon="bx bx-x" text={t("setup.dismiss-error")} onClick={() => setShowError(false)} />{/* A message built from components renders as it was built; a bare sentence stillgets the slashes a server error may have had escaped along the way. */}- {typeof error === "string" ? replaceHtmlEscapedSlashes(error) : error}- </Admonition>+ <div className="page-error-message">+ {typeof error === "string" ? replaceHtmlEscapedSlashes(error) : error}+ </div>+ </ExtendedAdmonition>)}{illustration}