A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
feat(app): report sign-in step titles to the layout
Hampus3841ca80c494
diff --git a/fluxer_app/src/features/auth/components/pages/RecoverAccountPage.tsx b/fluxer_app/src/features/auth/components/pages/RecoverAccountPage.tsxindex 16fa5200a..152d9c61a 100644--- a/fluxer_app/src/features/auth/components/pages/RecoverAccountPage.tsx+++ b/fluxer_app/src/features/auth/components/pages/RecoverAccountPage.tsx@@ -11,10 +11,15 @@ import {AuthRouterLink} from '@app/features/auth/flow/AuthRouterLink';import {AuthRuntimeTargetGate} from '@app/features/auth/flow/AuthRuntimeTargetGate';import MfaScreen from '@app/features/auth/flow/MfaScreen';import {useAuthPresentation} from '@app/features/auth/flow/useAuthPresentation';+import {type StepTitleChangeHandler, useReportStepTitle} from '@app/features/auth/flow/useReportStepTitle';import {resolveAuthBannerError, useAuthForm} from '@app/features/auth/hooks/useAuthForm';import {type LoginSuccessPayload, type MfaChallenge, recoverAccount} from '@app/features/auth/state/AuthFlow';import {AuthCardVariant} from '@app/features/auth/state/AuthLayoutContext';-import {BACK_TO_SIGN_IN_DESCRIPTOR, USERNAME_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';+import {+ BACK_TO_SIGN_IN_DESCRIPTOR,+ TWO_FACTOR_AUTHENTICATION_DESCRIPTOR,+ USERNAME_DESCRIPTOR,+} from '@app/features/i18n/utils/CommonMessageDescriptors';import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';import {Button} from '@app/features/ui/button/Button';import {rememberRecoveryKit} from '@app/features/user/commands/RecoveryKitCommands';@@ -96,6 +101,7 @@ interface RecoverAccountFormProps {readonly fragment?: RecoveryFragment;readonly footerLink?: ReactNode;readonly onRecovered: (payload: LoginSuccessPayload) => Promise<void>;+ readonly onStepTitleChange?: StepTitleChangeHandler | null;}export const RecoverAccountForm = observer(function RecoverAccountForm({@@ -103,6 +109,7 @@ export const RecoverAccountForm = observer(function RecoverAccountForm({fragment = EMPTY_RECOVERY_FRAGMENT,footerLink,onRecovered,+ onStepTitleChange = null,}: RecoverAccountFormProps) {const {i18n} = useLingui();const loginId = useId();@@ -111,6 +118,10 @@ export const RecoverAccountForm = observer(function RecoverAccountForm({const confirmPasswordId = useId();const [mfaChallenge, setMfaChallenge] = useState<MfaChallenge | null>(null);const [pendingKit, setPendingKit] = useState<PendingRecoveryKit | null>(null);+ useReportStepTitle(+ onStepTitleChange,+ i18n._(mfaChallenge ? TWO_FACTOR_AUTHENTICATION_DESCRIPTOR : RECOVER_ACCOUNT_DESCRIPTOR),+ );const {form, isLoading, error, fieldErrors} = useAuthForm({initialValues: {login: fragment.username,@@ -169,6 +180,7 @@ export const RecoverAccountForm = observer(function RecoverAccountForm({challenge={mfaChallenge}onSuccess={handleMfaSuccess}onCancel={handleMfaCancel}+ onStepTitleChange={onStepTitleChange}data-flx="auth.recover-account-page.mfa-screen"/>);@@ -176,9 +188,11 @@ export const RecoverAccountForm = observer(function RecoverAccountForm({const bannerError = resolveAuthBannerError(error, fieldErrors, API_RENDERED_FIELDS);return (<>- <h1 className={styles.title} data-flx="auth.recover-account-page.title">- {i18n._(RECOVER_ACCOUNT_DESCRIPTOR)}- </h1>+ {onStepTitleChange == null ? (+ <h1 className={styles.title} data-flx="auth.recover-account-page.title">+ {i18n._(RECOVER_ACCOUNT_DESCRIPTOR)}+ </h1>+ ) : null}<p className={styles.description} data-flx="auth.recover-account-page.description"><Trans>Enter your username and the recovery key from your recovery kit, then choose a new password.</Trans></p>diff --git a/fluxer_app/src/features/auth/flow/AccountRestrictionScreen.tsx b/fluxer_app/src/features/auth/flow/AccountRestrictionScreen.tsxindex a9ee52f91..f6ea97abc 100644--- a/fluxer_app/src/features/auth/flow/AccountRestrictionScreen.tsx+++ b/fluxer_app/src/features/auth/flow/AccountRestrictionScreen.tsx@@ -11,6 +11,7 @@ import {import * as AuthenticationCommands from '@app/features/auth/commands/AuthenticationCommands';import styles from '@app/features/auth/flow/AccountRestrictionScreen.module.css';import {useAuthPresentation} from '@app/features/auth/flow/useAuthPresentation';+import {type StepTitleChangeHandler, useReportStepTitle} from '@app/features/auth/flow/useReportStepTitle';import type {AccountRestriction} from '@app/features/auth/state/AccountRestriction';import Authentication from '@app/features/auth/state/Authentication';import {AuthCardVariant} from '@app/features/auth/state/AuthLayoutContext';@@ -194,7 +195,15 @@ function ScreenRoot({children, footer}: {children: ReactNode; footer: ReactNode});}-function NoticeView({notice, onBackToSignIn}: {notice: EnforcementNotice; onBackToSignIn: () => void}) {+function NoticeView({+ notice,+ showTitle,+ onBackToSignIn,+}: {+ notice: EnforcementNotice;+ showTitle: boolean;+ onBackToSignIn: () => void;+}) {const {i18n} = useLingui();const showWhy = notice.rule != null || notice.facts.length > 0 || notice.statement != null;return (@@ -210,9 +219,11 @@ function NoticeView({notice, onBackToSignIn}: {notice: EnforcementNotice; onBack}data-flx="auth.flow.account-restriction-screen.notice-view.screen-root">- <h1 className={styles.title} data-flx="auth.flow.account-restriction-screen.notice.title">- {i18n._(resolveNoticeTitle(notice))}- </h1>+ {showTitle ? (+ <h1 className={styles.title} data-flx="auth.flow.account-restriction-screen.notice.title">+ {i18n._(resolveNoticeTitle(notice))}+ </h1>+ ) : null}<Sectionheading={i18n._(WHAT_HAPPENED_DESCRIPTOR)}data-flx="auth.flow.account-restriction-screen.notice-view.section"@@ -320,15 +331,27 @@ interface AccountRestrictionScreenProps {restriction: AccountRestriction;onBackToSignIn: () => void;onTryAgain: () => void;+ onStepTitleChange?: StepTitleChangeHandler | null;}-export function AccountRestrictionScreen({restriction, onBackToSignIn, onTryAgain}: AccountRestrictionScreenProps) {+export function AccountRestrictionScreen({+ restriction,+ onBackToSignIn,+ onTryAgain,+ onStepTitleChange = null,+}: AccountRestrictionScreenProps) {const {i18n} = useLingui();useAuthPresentation({variant: AuthCardVariant.STANDARD});+ useReportStepTitle(+ onStepTitleChange,+ i18n._(restriction.type === 'notice' ? resolveNoticeTitle(restriction.notice) : NETWORK_BLOCKED_DESCRIPTOR),+ );+ const showTitle = onStepTitleChange == null;if (restriction.type === 'notice') {return (<NoticeViewnotice={restriction.notice}+ showTitle={showTitle}onBackToSignIn={onBackToSignIn}data-flx="auth.flow.account-restriction-screen.notice-view"/>@@ -347,9 +370,11 @@ export function AccountRestrictionScreen({restriction, onBackToSignIn, onTryAgai}data-flx="auth.flow.account-restriction-screen.network-blocked">- <h1 className={styles.title} data-flx="auth.flow.account-restriction-screen.network-blocked.title">- {i18n._(NETWORK_BLOCKED_DESCRIPTOR)}- </h1>+ {showTitle ? (+ <h1 className={styles.title} data-flx="auth.flow.account-restriction-screen.network-blocked.title">+ {i18n._(NETWORK_BLOCKED_DESCRIPTOR)}+ </h1>+ ) : null}<NetworkBlockDetailsblock={restriction.block}data-flx="auth.flow.account-restriction-screen.network-block-details"diff --git a/fluxer_app/src/features/auth/flow/ForgotPasswordForm.tsx b/fluxer_app/src/features/auth/flow/ForgotPasswordForm.tsxindex 2549a119d..3e36ff053 100644--- a/fluxer_app/src/features/auth/flow/ForgotPasswordForm.tsx+++ b/fluxer_app/src/features/auth/flow/ForgotPasswordForm.tsx@@ -1,21 +1,30 @@// SPDX-License-Identifier: AGPL-3.0-or-laterimport type {RuntimeConfigSnapshot} from '@app/features/app/state/InstanceSnapshotStore';+import {FORGOT_YOUR_PASSWORD_DESCRIPTOR} from '@app/features/auth/AuthMessageDescriptors';import styles from '@app/features/auth/components/pages/ForgotPasswordPage.module.css';import FormField from '@app/features/auth/flow/AuthFormField';import {useForgotPasswordForm} from '@app/features/auth/flow/useForgotPasswordForm';+import {type StepTitleChangeHandler, useReportStepTitle} from '@app/features/auth/flow/useReportStepTitle';import {EMAIL_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';import {instanceTargetFromSnapshot} from '@app/features/platform/transport/InstanceHTTP';import {Button} from '@app/features/ui/button/Button';+import {msg} from '@lingui/core/macro';import {Trans, useLingui} from '@lingui/react/macro';import {observer} from 'mobx-react-lite';import type {ReactNode} from 'react';+const CHECK_YOUR_EMAIL_DESCRIPTOR = msg({+ message: 'Check your email',+ comment: 'Heading shown after a password reset link was requested.',+});+interface ForgotPasswordFormProps {readonly runtimeSnapshot: RuntimeConfigSnapshot;readonly sentFooter?: ReactNode;readonly formFooter?: ReactNode;readonly renderContainer?: (children: ReactNode, isSent: boolean) => ReactNode;+ readonly onStepTitleChange?: StepTitleChangeHandler | null;}export const ForgotPasswordForm = observer(function ForgotPasswordForm({@@ -23,15 +32,22 @@ export const ForgotPasswordForm = observer(function ForgotPasswordForm({sentFooter,formFooter,renderContainer,+ onStepTitleChange = null,}: ForgotPasswordFormProps) {const {i18n} = useLingui();const {form, emailId, isSent} = useForgotPasswordForm(instanceTargetFromSnapshot(runtimeSnapshot));+ const title = i18n._(isSent ? CHECK_YOUR_EMAIL_DESCRIPTOR : FORGOT_YOUR_PASSWORD_DESCRIPTOR);+ useReportStepTitle(onStepTitleChange, title);+ const heading =+ onStepTitleChange == null ? (+ <h1 className={styles.title} data-flx="auth.forgot-password-page.title">+ {title}+ </h1>+ ) : null;if (isSent) {const content = (<>- <h1 className={styles.title} data-flx="auth.forgot-password-page.title">- <Trans>Check your email</Trans>- </h1>+ {heading}<p className={styles.description} role="status" data-flx="auth.forgot-password-page.description"><Trans>If an account uses that address, we've sent it password reset instructions. Check your inbox for the reset@@ -51,9 +67,7 @@ export const ForgotPasswordForm = observer(function ForgotPasswordForm({}const content = (<>- <h1 className={styles.title} data-flx="auth.forgot-password-page.title--2">- <Trans>Forgot your password?</Trans>- </h1>+ {heading}<p className={styles.description} data-flx="auth.forgot-password-page.description--2"><Trans>Enter your email address and we'll send you a link to reset your password.</Trans></p>diff --git a/fluxer_app/src/features/auth/flow/IpAuthorizationScreen.tsx b/fluxer_app/src/features/auth/flow/IpAuthorizationScreen.tsxindex be35a28ff..b4352a42c 100644--- a/fluxer_app/src/features/auth/flow/IpAuthorizationScreen.tsx+++ b/fluxer_app/src/features/auth/flow/IpAuthorizationScreen.tsx@@ -3,6 +3,7 @@import type {RuntimeConfigSnapshot} from '@app/features/app/state/InstanceSnapshotStore';import * as AuthenticationCommands from '@app/features/auth/commands/AuthenticationCommands';import styles from '@app/features/auth/flow/IpAuthorizationScreen.module.css';+import {type StepTitleChangeHandler, useReportStepTitle} from '@app/features/auth/flow/useReportStepTitle';import type {IpAuthorizationChallenge, LoginSuccessPayload} from '@app/features/auth/state/AuthFlow';import {TRY_AGAIN_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';import {getCachedNumberFormat} from '@app/features/i18n/utils/IntlCache';@@ -22,6 +23,7 @@ interface IpAuthorizationScreenProps {runtimeSnapshot: RuntimeConfigSnapshot;onAuthorized: (payload: LoginSuccessPayload) => Promise<void> | void;onBack?: () => void;+ onStepTitleChange?: StepTitleChangeHandler | null;}const POLL_INTERVAL_MS = 2000;@@ -30,12 +32,28 @@ const CHECK_INBOX_FOR_AUTHORIZATION_LINK_DESCRIPTOR = msg({message: 'Check your inbox at {emailAddress} for the authorization link.',comment: 'Instruction on the IP authorization screen. emailAddress is the address that received the login email.',});+const CHECK_YOUR_EMAIL_DESCRIPTOR = msg({+ message: 'Check your email',+ comment: 'Heading of the IP authorization screen while it waits for the emailed authorization link.',+});+const CONNECTION_LOST_DESCRIPTOR = msg({+ message: 'Connection lost',+ comment: 'Heading of the IP authorization screen when it can no longer check whether the link was used.',+});const logger = new Logger('IpAuthorizationScreen');-const IpAuthorizationScreen = ({challenge, runtimeSnapshot, onAuthorized, onBack}: IpAuthorizationScreenProps) => {+const IpAuthorizationScreen = ({+ challenge,+ runtimeSnapshot,+ onAuthorized,+ onBack,+ onStepTitleChange = null,+}: IpAuthorizationScreenProps) => {const {i18n} = useLingui();const [resendUsed, setResendUsed] = useState(false);const [resendIn, setResendIn] = useState(challenge.resendAvailableIn);const [pollingState, setPollingState] = useState<PollingState>('polling');+ const title = i18n._(pollingState === 'error' ? CONNECTION_LOST_DESCRIPTOR : CHECK_YOUR_EMAIL_DESCRIPTOR);+ useReportStepTitle(onStepTitleChange, title);const onAuthorizedRef = useRef(onAuthorized);onAuthorizedRef.current = onAuthorized;useEffect(() => {@@ -125,9 +143,11 @@ const IpAuthorizationScreen = ({challenge, runtimeSnapshot, onAuthorized, onBack/>)}</div>- <h1 className={styles.title} data-flx="auth.flow.ip-authorization-screen.title">- {pollingState === 'error' ? <Trans>Connection lost</Trans> : <Trans>Check your email</Trans>}- </h1>+ {onStepTitleChange == null ? (+ <h1 className={styles.title} data-flx="auth.flow.ip-authorization-screen.title">+ {title}+ </h1>+ ) : null}<pclassName={styles.description}role={pollingState === 'error' ? 'alert' : 'status'}diff --git a/fluxer_app/src/features/auth/flow/MfaScreen.tsx b/fluxer_app/src/features/auth/flow/MfaScreen.tsxindex 1b003ca1b..294a04db8 100644--- a/fluxer_app/src/features/auth/flow/MfaScreen.tsx+++ b/fluxer_app/src/features/auth/flow/MfaScreen.tsx@@ -4,6 +4,7 @@ import {MFA_CODE_DIGIT_COUNT} from '@app/features/app/config/I18nDisplayConstantimport FormField from '@app/features/auth/flow/AuthFormField';import styles from '@app/features/auth/flow/MfaScreen.module.css';import {useAuthPresentation} from '@app/features/auth/flow/useAuthPresentation';+import {type StepTitleChangeHandler, useReportStepTitle} from '@app/features/auth/flow/useReportStepTitle';import {useMfaController} from '@app/features/auth/hooks/useLoginFlow';import type {LoginSuccessPayload, MfaChallenge} from '@app/features/auth/state/AuthFlow';import {AuthCardVariant} from '@app/features/auth/state/AuthLayoutContext';@@ -44,10 +45,13 @@ interface MfaScreenProps {inviteCode?: string;onSuccess: (payload: LoginSuccessPayload) => Promise<void> | void;onCancel: () => void;+ onStepTitleChange?: StepTitleChangeHandler | null;}-const MfaScreen = ({challenge, inviteCode, onSuccess, onCancel}: MfaScreenProps) => {+const MfaScreen = ({challenge, inviteCode, onSuccess, onCancel, onStepTitleChange = null}: MfaScreenProps) => {const {i18n} = useLingui();+ const title = i18n._(TWO_FACTOR_AUTHENTICATION_DESCRIPTOR);+ useReportStepTitle(onStepTitleChange, title);const {form, isLoading, fieldErrors, handleWebAuthn, isWebAuthnLoading, supports} = useMfaController({ticket: challenge.ticket,methods: {totp: challenge.totp, webauthn: challenge.webauthn, backupCodes: challenge.backupCodes},@@ -61,9 +65,11 @@ const MfaScreen = ({challenge, inviteCode, onSuccess, onCancel}: MfaScreenProps)const isCodePrimary = supports.totp || !showWebAuthn;return (<div className={styles.container} data-flx="auth.flow.mfa-screen.container--2">- <h1 className={styles.title} data-flx="auth.flow.mfa-screen.title">- {i18n._(TWO_FACTOR_AUTHENTICATION_DESCRIPTOR)}- </h1>+ {onStepTitleChange == null ? (+ <h1 className={styles.title} data-flx="auth.flow.mfa-screen.title">+ {title}+ </h1>+ ) : null}{showCodeForm && (<p className={styles.description} data-flx="auth.flow.mfa-screen.description">{backupCodeOnly