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(options): add MFA active/inactive status badge to page header
Elian Doran68e47864bf6d
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex d908d73737..5b09a3a43e 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1693,6 +1693,10 @@},"multi_factor_authentication": {"title": "Multi-Factor Authentication",+ "status_active": "Active",+ "status_inactive": "Inactive",+ "status_active_tooltip": "Multi-Factor Authentication is enabled for your account.",+ "status_inactive_tooltip": "Multi-Factor Authentication is currently disabled.","description": "Multi-Factor Authentication (MFA) adds an extra layer of security to your account. Instead of just entering a password to log in, MFA requires you to provide one or more additional pieces of evidence to verify your identity. This way, even if someone gets hold of your password, they still can't access your account without the second piece of information. It's like adding an extra lock to your door, making it much harder for anyone else to break in.<br><br>Please follow the instructions below to enable MFA. If you don't config correctly, login will fall back to password only.","mfa_enabled": "Enable Multi-Factor Authentication","mfa_method": "MFA Method",diff --git a/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.css b/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.cssnew file mode 100644index 0000000000..f619ff0409--- /dev/null+++ b/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.css@@ -0,0 +1,21 @@+/* Flex row holding the status badge, so the badge sizes to its content instead of stretching to+ fill the full header width (the shared actions slot isn't itself a flex container). */+.mfa-header-actions {+ display: flex;+ align-items: center;+}++/* Status badge on the MFA page header, mirroring the shortcuts page's outline badge: a colored+ outline whose hue is driven by the --color variable (green when active, muted when inactive). */+.mfa-status-badge {+ flex: 0 0 auto;+ margin-inline-end: auto;+}++.mfa-status-badge.active {+ --color: var(--admonition-tip-accent-color, #40c025);+}++.mfa-status-badge.inactive {+ --color: var(--muted-text-color, #888);+}diff --git a/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.tsx b/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.tsxindex 08d4e1ff09..f7bf46af3b 100644--- a/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.tsx+++ b/apps/client/src/widgets/type_widgets/options/multi_factor_authentication.tsx@@ -1,5 +1,8 @@+import "./multi_factor_authentication.css"+import { Trans } from "react-i18next"import { t } from "../../../services/i18n"+import { Badge } from "../../react/Badge"import FormText from "../../react/FormText"import OptionsPageHeader from "./components/OptionsPageHeader"import OptionsSection from "./components/OptionsSection"@@ -22,7 +25,7 @@ export default function MultiFactorAuthenticationSettings() {return (!isElectron()? (<>- <OptionsPageHeader />+ <OptionsPageHeader actions={<MfaStatusBadge mfaEnabled={mfaEnabled} />} /><EnableMultiFactor mfaEnabled={mfaEnabled} setMfaEnabled={setMfaEnabled} />{ mfaEnabled && <MultiFactorMethod /> }</>@@ -35,6 +38,20 @@ export default function MultiFactorAuthenticationSettings() {)}+function MfaStatusBadge({ mfaEnabled }: { mfaEnabled: boolean }) {+ return (+ <div className="mfa-header-actions">+ <Badge+ className={`mfa-status-badge ${mfaEnabled ? "active" : "inactive"}`}+ icon={mfaEnabled ? "bx bx-check-shield" : "bx bx-shield-x"}+ text={mfaEnabled ? t("multi_factor_authentication.status_active") : t("multi_factor_authentication.status_inactive")}+ tooltip={mfaEnabled ? t("multi_factor_authentication.status_active_tooltip") : t("multi_factor_authentication.status_inactive_tooltip")}+ outline+ />+ </div>+ );+}+function EnableMultiFactor({ mfaEnabled, setMfaEnabled }: { mfaEnabled: boolean, setMfaEnabled: (newValue: boolean) => Promise<void>}) {return (<OptionsSection title={t("multi_factor_authentication.title")}>