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
chore(standalone/setup): make fields required
Elian Doran28c57813db14
diff --git a/apps/client/src/setup.tsx b/apps/client/src/setup.tsxindex 511fe1438b..95e3fe665b 100644--- a/apps/client/src/setup.tsx+++ b/apps/client/src/setup.tsx@@ -212,6 +212,7 @@ function SyncFromServer({ setState }: { setState: (state: State) => void }) {const [ syncServerHost, setSyncServerHost ] = useState("");const [ password, setPassword ] = useState("");const [ syncProxy, setSyncProxy ] = useState("");+ const isValid = syncServerHost.trim() !== "" && password !== "";async function handleFinishSetup() {await server.post("setup/sync-from-server", {@@ -229,13 +230,13 @@ function SyncFromServer({ setState }: { setState: (state: State) => void }) {<p>{t("setup.sync-from-server-page-description")}</p><main>- <form>+ <form onSubmit={handleFinishSetup}><FormItemWithIcon icon="bx bx-server">- <FormTextBox placeholder="https://example.com" currentValue={syncServerHost} onChange={setSyncServerHost} />+ <FormTextBox placeholder="https://example.com" currentValue={syncServerHost} onChange={setSyncServerHost} required /></FormItemWithIcon><FormItemWithIcon icon="bx bx-lock">- <FormTextBox placeholder={t("setup.password-placeholder")} type="password" currentValue={password} onChange={setPassword} />+ <FormTextBox placeholder={t("setup.password-placeholder")} type="password" currentValue={password} onChange={setPassword} required /></FormItemWithIcon><Collapsible title={t("setup.advanced-options")} initiallyExpanded={false}>@@ -248,7 +249,7 @@ function SyncFromServer({ setState }: { setState: (state: State) => void }) {<footer><Button text={t("setup.button-back")} onClick={() => setState("firstOptions")} kind="lowProfile" />- <Button text={t("setup.button-finish-setup")} kind="primary" onClick={handleFinishSetup} />+ <Button text={t("setup.button-finish-setup")} kind="primary" onClick={handleFinishSetup} disabled={!isValid} /></footer></div>);diff --git a/apps/client/src/setup_old.ts b/apps/client/src/setup_old.tsindex 98881a36ff..02aa5bcca4 100644--- a/apps/client/src/setup_old.ts+++ b/apps/client/src/setup_old.ts@@ -15,7 +15,6 @@ class SetupController {private setupTypeNextButton: HTMLButtonElement;private setupTypeInputs: HTMLInputElement[];private syncServerHostInput: HTMLInputElement;- private syncProxyInput: HTMLInputElement;private passwordInput: HTMLInputElement;private sections: Record<SetupStep, HTMLElement>;@@ -27,7 +26,6 @@ class SetupController {this.setupTypeNextButton = mustGetElement("setup-type-next", HTMLButtonElement);this.setupTypeInputs = Array.from(document.querySelectorAll<HTMLInputElement>("input[name='setup-type']"));this.syncServerHostInput = mustGetElement("sync-server-host", HTMLInputElement);- this.syncProxyInput = mustGetElement("sync-proxy", HTMLInputElement);this.passwordInput = mustGetElement("password", HTMLInputElement);this.sections = {"setup-type": mustGetElement("setup-type-section", HTMLElement),@@ -113,13 +111,6 @@ class SetupController {return;}- // not using server.js because it loads too many dependencies- const resp = await $.post("api/setup/sync-from-server", {- syncServerHost,- syncProxy,- password- });-if (resp.result === "success") {hideAlert();this.setStep("sync-in-progress");