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(oauth): improve not configured section
Elian Doranfec4e0f05217
diff --git a/apps/client/src/stylesheets/theme-next/pages.css b/apps/client/src/stylesheets/theme-next/pages.cssindex 8062ac7a50..dc0811b6da 100644--- a/apps/client/src/stylesheets/theme-next/pages.css+++ b/apps/client/src/stylesheets/theme-next/pages.css@@ -202,12 +202,9 @@ body.desktop .options-section:not(.tn-no-card) {padding-bottom: var(--default-padding);}-.options-section:not(.tn-no-card) h4 {+.options-section h4 {text-transform: uppercase;letter-spacing: .4pt;-}--.options-section:not(.tn-no-card) h4 {font-size: var(--options-title-font-size);font-weight: 600;color: var(--launcher-pane-text-color);diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex c3cc450844..93d853dbe9 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1745,8 +1745,9 @@"oauth_status_not_connected": "Not connected","oauth_status_not_configured": "Not configured","oauth_description": "OpenID Connect lets you log in using an account from another service, like Google, to verify your identity. The default issuer is Google, but you can change it to any other OpenID Connect provider. Check <a href=\"#root/_hidden/_help/_help_Otzi9La2YAUX/_help_WOcw2SLH6tbX/_help_7DAiwaf8Z7Rz\">here</a> for more information. Follow these <a href=\"https://developers.google.com/identity/openid-connect/openid-connect\">instructions</a> to set up an OpenID Connect service through Google.",- "oauth_not_configured_hint": "Let people sign in with an account from another service, like Google. Set OpenID Connect up on the server to enable it as a login method.",- "oauth_missing_vars": "Still to set: {{-variables}}",+ "oauth_not_configured_title": "Set up OpenID Connect",+ "oauth_not_configured_hint": "OpenID Connect needs to be set up through the config.ini or environment variables first.",+ "oauth_missing_vars": "Left to configure: {{-variables}}","oauth_how_to_enable": "How to enable","oauth_server_config_hint": "Add the following to your config.ini file and restart the application:","oauth_server_env_hint": "Or set the following environment variables:",@@ -1757,7 +1758,9 @@"oauth_user_email": "Email address","oauth_user_not_logged_in": "Not logged in!","oauth_not_enrolled_title": "No account connected",- "oauth_not_enrolled_hint": "OpenID Connect is configured, but no account is connected yet. Connect your account to make it the active sign-in method; until then, you'll keep signing in with your password.",+ "oauth_not_enrolled_hint": "OpenID Connect is configured, but no account is connected yet.",+ "oauth_not_enrolled_details_label": "What does this mean?",+ "oauth_not_enrolled_details": "Until an account is connected, OpenID Connect isn't active and you'll keep signing in with your password. Connect your account below to switch it on.","oauth_connect_label": "Connect account","oauth_connect_description": "Sign in with your provider once to bind your account. Only this account will be able to sign in afterwards.","oauth_connect_button": "Connect account",diff --git a/apps/client/src/widgets/type_widgets/options/password.tsx b/apps/client/src/widgets/type_widgets/options/password.tsxindex d859dbb69f..0649689786 100644--- a/apps/client/src/widgets/type_widgets/options/password.tsx+++ b/apps/client/src/widgets/type_widgets/options/password.tsx@@ -10,9 +10,8 @@ import protected_session_holder from "../../../services/protected_session_holderimport server from "../../../services/server";import toast from "../../../services/toast";import { isElectron } from "../../../services/utils";-import Admonition, { ExtendedAdmonition } from "../../react/Admonition";+import { ExtendedAdmonition } from "../../react/Admonition";import Button from "../../react/Button";-import Collapsible from "../../react/Collapsible";import FormGroup from "../../react/FormGroup";import FormSelect from "../../react/FormSelect";import FormText from "../../react/FormText";@@ -284,21 +283,26 @@ function OAuthStatusCard({ status, refreshStatus }: { status?: OAuthStatus, refr<MfaStatusBadge tone={badge.tone} text={badge.text} /></span>}+ noCard={!configured}>{ !configured ? (- <>+ <ExtendedAdmonition+ type="note"+ icon="bx bx-info-circle"+ title={t("multi_factor_authentication.oauth_not_configured_title")}+ detailsLabel={t("multi_factor_authentication.oauth_how_to_enable")}+ details={<OAuthConfigInstructions />}+ ><p>{t("multi_factor_authentication.oauth_not_configured_hint")}</p>{ status?.missingVars && status.missingVars.length > 0 && (- <Admonition type="note">+ <p>{t("multi_factor_authentication.oauth_missing_vars", {variables: status.missingVars.map(v => `"${v}"`).join(", ")})}- </Admonition>+ </p>)}-- <OAuthConfigHint />- </>+ </ExtendedAdmonition>) : enrolled ? (<><OAuthProviderRows status={status} />@@ -324,6 +328,8 @@ function OAuthStatusCard({ status, refreshStatus }: { status?: OAuthStatus, refrtype="note"icon="bx bx-info-circle"title={t("multi_factor_authentication.oauth_not_enrolled_title")}+ detailsLabel={t("multi_factor_authentication.oauth_not_enrolled_details_label")}+ details={t("multi_factor_authentication.oauth_not_enrolled_details")}>{t("multi_factor_authentication.oauth_not_enrolled_hint")}</ExtendedAdmonition>@@ -389,20 +395,20 @@ function oauthProviderDisplayName(status?: OAuthStatus) {}/**- * Collapsible "How to enable" hint for OAuth, mirroring the security page's ServerConfigHint. Lists+ * "How to enable" instructions for OAuth, shown in the not-configured admonition's collapsible. Lists* the config.ini section and the equivalent environment variables the server reads — OAuth has no* in-app setup, so this is the only place the values are documented in the UI.*/-function OAuthConfigHint() {+function OAuthConfigInstructions() {// oauthBaseUrl is the app's externally-reachable base URL, which for the user reading this is// exactly the origin they're browsing from — so prefill it as a sensible example value.const baseUrl = window.location.origin;return (- <Collapsible title={t("multi_factor_authentication.oauth_how_to_enable")}>+ <><p>{t("multi_factor_authentication.oauth_server_config_hint")}</p><pre><code>{`[MultiFactorAuthentication]\noauthBaseUrl=${baseUrl}\noauthClientId=\noauthClientSecret=`}</code></pre><p>{t("multi_factor_authentication.oauth_server_env_hint")}</p><pre><code>{`TRILIUM_OAUTH_BASE_URL=${baseUrl}\nTRILIUM_OAUTH_CLIENT_ID=\nTRILIUM_OAUTH_CLIENT_SECRET=`}</code></pre>- </Collapsible>+ </>);}