Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

refactor(app): move setup wizard steps into their own files

Hampusc196e644a1c8
diff --git a/fluxer_app/src/features/app/components/setup/SetupAccountStep.tsx b/fluxer_app/src/features/app/components/setup/SetupAccountStep.tsx
new file mode 100644
index 000000000..cdac2894f
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupAccountStep.tsx
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
+import {Note, StepHeader} from '@app/features/app/components/setup/SetupWizardSteps';
+import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
+import {AuthRegisterFormCore} from '@app/features/auth/flow/AuthRegisterFormCore';
+import type {MissingField} from '@app/features/auth/flow/SubmitTooltip';
+import type {AuthRegisterFormDraft} from '@app/features/auth/state/AuthRegisterDraftContext';
+import type {ThemeType} from '@fluxer/constants/src/UserConstants';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {makeAutoObservable, observableRef} from 'mobx';
+import {observer} from 'mobx-react-lite';
+import type {ReactNode, RefObject} from 'react';
+
+const ACCOUNT_TITLE_DESCRIPTOR = msg({
+ message: 'Create your account',
+ comment: 'Setup wizard title for creating the first account, which becomes the administrator.',
+});
+const ACCOUNT_BODY_DESCRIPTOR = msg({
+ message: 'This is your own account, and it can change every setting on this instance.',
+ comment: 'Setup wizard body for creating the administrator account.',
+});
+const ACCOUNT_NO_EMAIL_DESCRIPTOR = msg({
+ message: "Your instance can't send email yet, so keep this password safe.",
+ comment: 'Extra line on the setup wizard account screen when the instance has no email service.',
+});
+export const CREATE_ACCOUNT_DESCRIPTOR = msg({
+ message: 'Create account',
+ comment: 'Button that creates the administrator account in the setup wizard.',
+});
+
+export interface SetupAccountValues {
+ username: string;
+ email: string;
+}
+
+export class SetupAccountDraft {
+ values: SetupAccountValues;
+ readonly passwordRef: RefObject<string | null> = {current: null};
+ private readonly drafts = new Map<string, AuthRegisterFormDraft>();
+ private readonly restoredDraft: SetupAccountValues;
+
+ constructor(restoredDraft: Partial<Record<keyof SetupAccountValues, unknown>> | null) {
+ this.values = {
+ username: typeof restoredDraft?.username === 'string' ? restoredDraft.username : '',
+ email: typeof restoredDraft?.email === 'string' ? restoredDraft.email : '',
+ };
+ this.restoredDraft = {...this.values};
+ makeAutoObservable<this, 'drafts' | 'restoredDraft'>(
+ this,
+ {values: observableRef, passwordRef: false, drafts: false, restoredDraft: false},
+ {autoBind: true},
+ );
+ }
+
+ getRegisterFormDraft(draftKey: string): AuthRegisterFormDraft | undefined {
+ const draft = this.drafts.get(draftKey);
+ if (draft) return {...draft, formValues: {...draft.formValues}};
+ if (!this.restoredDraft.username && !this.restoredDraft.email) return undefined;
+ return {
+ formValues: {...this.restoredDraft},
+ selectedMonth: '',
+ selectedDay: '',
+ selectedYear: '',
+ };
+ }
+
+ setRegisterFormDraft(draftKey: string, draft: AuthRegisterFormDraft): void {
+ this.drafts.set(draftKey, {...draft, formValues: {...draft.formValues}});
+ this.values = {username: draft.formValues.username ?? '', email: draft.formValues.email ?? ''};
+ }
+
+ clearRegisterFormDraft(draftKey: string): void {
+ this.drafts.delete(draftKey);
+ }
+
+ resetSession(): void {
+ this.drafts.clear();
+ this.passwordRef.current = null;
+ }
+}
+
+export const AccountStep = observer(
+ ({
+ usernameSignIn,
+ emailLater,
+ theme,
+ setupToken,
+ formId,
+ renderSubmit,
+ onSetupTokenRejected,
+ onPasswordRegistered,
+ }: {
+ usernameSignIn: boolean;
+ emailLater: boolean;
+ theme: ThemeType;
+ setupToken: string | undefined;
+ formId: string;
+ renderSubmit: (state: {disabled: boolean; submitting: boolean; missingFields: Array<MissingField>}) => ReactNode;
+ onSetupTokenRejected: (message: string) => void;
+ onPasswordRegistered: (password: string) => void;
+ }) => {
+ const {i18n} = useLingui();
+ return (
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.account-step">
+ <StepHeader
+ title={i18n._(ACCOUNT_TITLE_DESCRIPTOR)}
+ body={i18n._(ACCOUNT_BODY_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.account-step.step-header"
+ />
+ {emailLater && (
+ <Note data-flx="app.setup.setup-wizard-steps.account-step.note">{i18n._(ACCOUNT_NO_EMAIL_DESCRIPTOR)}</Note>
+ )}
+ <div className={styles.accountForm} data-flx="app.self-hosted-setup-wizard-gate.account-form">
+ <AuthRegisterFormCore
+ fields={{
+ showEmail: !usernameSignIn,
+ showPassword: true,
+ showPasswordConfirmation: true,
+ showUsernameValidation: true,
+ requireUsername: true,
+ }}
+ submitLabel={i18n._(CREATE_ACCOUNT_DESCRIPTOR)}
+ redirectPath=""
+ runtimeSnapshot={RuntimeConfig.getSnapshot()}
+ offerRecoveryKit={false}
+ hideDisplayName
+ theme={theme}
+ showLegalConsent={false}
+ setupToken={setupToken}
+ onSetupTokenRejected={onSetupTokenRejected}
+ onPasswordRegistered={onPasswordRegistered}
+ formId={formId}
+ renderSubmit={renderSubmit}
+ data-flx="app.self-hosted-setup-wizard-gate.account-register-form"
+ />
+ </div>
+ </section>
+ );
+ },
+);
diff --git a/fluxer_app/src/features/app/components/setup/SetupAttachmentsStep.tsx b/fluxer_app/src/features/app/components/setup/SetupAttachmentsStep.tsx
new file mode 100644
index 000000000..3d0a5d963
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupAttachmentsStep.tsx
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
+import type {updateInstanceConfig} from '@app/features/app/components/setup/SetupWizardClient';
+import {StepError, StepHeader} from '@app/features/app/components/setup/SetupWizardSteps';
+import {RadioGroup, type RadioOption} from '@app/features/ui/radio_group/RadioGroup';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {observer} from 'mobx-react-lite';
+import {createContext, type ReactNode, type RefObject, useContext, useMemo, useState} from 'react';
+
+const ATTACHMENTS_TITLE_DESCRIPTOR = msg({
+ message: 'Should old attachments be deleted to save disk space?',
+ comment: 'Setup wizard title for automatic attachment expiry.',
+});
+const ATTACHMENTS_YES_NAME_DESCRIPTOR = msg({
+ message: 'Yes, delete old attachments',
+ comment: 'Setup wizard option that turns on automatic attachment expiry.',
+});
+const ATTACHMENTS_YES_DESC_DESCRIPTOR = msg({
+ message:
+ 'Small files are kept for about three years, and the largest ones for as little as 14 days. You can change these limits in the admin panel.',
+ comment: 'Description of automatic attachment expiry in the setup wizard.',
+});
+const ATTACHMENTS_NO_NAME_DESCRIPTOR = msg({
+ message: 'No, keep everything',
+ comment: 'Setup wizard option that keeps attachments until someone deletes them.',
+});
+const ATTACHMENTS_NO_DESC_DESCRIPTOR = msg({
+ message: 'Attachments stay until someone deletes them.',
+ comment: 'Description of keeping attachments in the setup wizard.',
+});
+
+interface AttachmentsDraft {
+ enabled: boolean;
+ setEnabled: (enabled: boolean) => void;
+}
+
+const AttachmentsDraftContext = createContext<AttachmentsDraft | null>(null);
+
+export function SetupAttachmentsDraftProvider({children}: {children: ReactNode}) {
+ const [enabled, setEnabled] = useState(false);
+ const draft = useMemo(() => ({enabled, setEnabled}), [enabled]);
+ return <AttachmentsDraftContext.Provider value={draft}>{children}</AttachmentsDraftContext.Provider>;
+}
+
+export function useSetupAttachmentsDraft(): AttachmentsDraft {
+ const draft = useContext(AttachmentsDraftContext);
+ if (draft === null) throw new Error('Setup attachment draft provider is missing');
+ return draft;
+}
+
+export const AttachmentsStep = observer(
+ ({
+ formRef,
+ error,
+ onSubmit,
+ onSave,
+ onAdvance,
+ }: {
+ formRef: RefObject<HTMLFormElement | null>;
+ error: string | null;
+ onSubmit: (submit: () => Promise<void>) => Promise<void>;
+ onSave: (patch: Parameters<typeof updateInstanceConfig>[0]) => Promise<boolean>;
+ onAdvance: () => void;
+ }) => {
+ const {i18n} = useLingui();
+ const {enabled, setEnabled} = useSetupAttachmentsDraft();
+ const saveAttachments = async () => {
+ const saved = await onSave({media: {attachment_decay: {enabled}}});
+ if (saved) onAdvance();
+ };
+ const options: ReadonlyArray<RadioOption<'yes' | 'no'>> = [
+ {value: 'yes', name: i18n._(ATTACHMENTS_YES_NAME_DESCRIPTOR), desc: i18n._(ATTACHMENTS_YES_DESC_DESCRIPTOR)},
+ {value: 'no', name: i18n._(ATTACHMENTS_NO_NAME_DESCRIPTOR), desc: i18n._(ATTACHMENTS_NO_DESC_DESCRIPTOR)},
+ ];
+ return (
+ <form
+ ref={formRef}
+ noValidate
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onSubmit(saveAttachments);
+ }}
+ className={styles.step}
+ data-flx="app.self-hosted-setup-wizard-gate.attachments-step"
+ >
+ <StepHeader
+ title={i18n._(ATTACHMENTS_TITLE_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.attachments-step.step-header"
+ />
+ <RadioGroup
+ options={options}
+ value={enabled ? 'yes' : 'no'}
+ onChange={(value) => setEnabled(value === 'yes')}
+ aria-label={i18n._(ATTACHMENTS_TITLE_DESCRIPTOR)}
+ data-flx="app.self-hosted-setup-wizard-gate.attachments-radio-group"
+ />
+ <StepError error={error} data-flx="app.setup.setup-wizard-steps.attachments-step.step-error" />
+ </form>
+ );
+ },
+);
diff --git a/fluxer_app/src/features/app/components/setup/SetupEmailSteps.tsx b/fluxer_app/src/features/app/components/setup/SetupEmailSteps.tsx
new file mode 100644
index 000000000..34904c598
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupEmailSteps.tsx
@@ -0,0 +1,439 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
+import {testSmtpConfig, type updateInstanceConfig} from '@app/features/app/components/setup/SetupWizardClient';
+import {Note, StepError, StepHeader, TextButton} from '@app/features/app/components/setup/SetupWizardSteps';
+import {Input} from '@app/features/ui/components/form/FormInput';
+import {RadioGroup, type RadioOption} from '@app/features/ui/radio_group/RadioGroup';
+import * as FormUtils from '@app/lib/forms';
+import {resolveSmtpTlsMode, type SmtpTlsMode, SmtpTlsModes} from '@fluxer/constants/src/SmtpConstants';
+import type {InstanceConfigResponse} from '@fluxer/schema/src/domains/admin/AdminSchemas';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {observer} from 'mobx-react-lite';
+import {createContext, type ReactNode, type RefObject, useCallback, useContext, useMemo, useState} from 'react';
+
+const DEFAULT_SMTP_PORT = '587';
+const MIN_SMTP_PORT = 1;
+const MAX_SMTP_PORT = 65535;
+type SmtpTlsChoice = SmtpTlsMode | 'auto';
+
+const EMAIL_SERVICE_TITLE_DESCRIPTOR = msg({
+ message: 'Connect your email service',
+ comment: 'Setup wizard title for entering SMTP details.',
+});
+const EMAIL_SERVICE_BODY_DESCRIPTOR = msg({
+ message: 'Enter the SMTP details from your email provider.',
+ comment: 'Setup wizard body for entering SMTP details. SMTP must not be translated.',
+});
+const SMTP_SERVER_LABEL_DESCRIPTOR = msg({
+ message: 'SMTP server',
+ comment: 'Label for the SMTP server address field. SMTP must not be translated.',
+});
+const SMTP_PORT_LABEL_DESCRIPTOR = msg({
+ message: 'Port',
+ comment: 'Label for the SMTP port field.',
+});
+const SMTP_PORT_ERROR_DESCRIPTOR = msg({
+ message: 'Enter a port between 1 and 65535.',
+ comment: 'Error under the SMTP port field.',
+});
+const SMTP_USERNAME_LABEL_DESCRIPTOR = msg({
+ message: 'Username',
+ comment: 'Label for the SMTP username field.',
+});
+const SMTP_PASSWORD_LABEL_DESCRIPTOR = msg({
+ message: 'Password',
+ comment: 'Label for the SMTP password field.',
+});
+const SMTP_CREDENTIALS_OPTIONAL_DESCRIPTOR = msg({
+ message:
+ 'Leave the username and password empty if your mail server accepts mail from this server without signing in.',
+ comment:
+ 'Note under the SMTP username and password fields in the setup wizard. SMTP relays on a private network often need no sign-in.',
+});
+const SMTP_TLS_LABEL_DESCRIPTOR = msg({
+ message: 'Encryption',
+ comment: 'Label for the choice of how the SMTP connection is encrypted.',
+});
+const SMTP_TLS_AUTO_DESCRIPTOR = msg({
+ message: 'Automatic, based on the port',
+ comment: 'SMTP encryption option that picks the mode from the port number.',
+});
+const SMTP_TLS_IMPLICIT_DESCRIPTOR = msg({
+ message: 'TLS, usually port 465',
+ comment: 'SMTP encryption option where the connection is encrypted from the start. TLS must not be translated.',
+});
+const SMTP_TLS_STARTTLS_DESCRIPTOR = msg({
+ message: 'STARTTLS, usually port 587',
+ comment: 'SMTP encryption option that always upgrades with STARTTLS. STARTTLS must not be translated.',
+});
+const SMTP_TLS_OPPORTUNISTIC_DESCRIPTOR = msg({
+ message: 'STARTTLS when the server offers it',
+ comment: 'SMTP encryption option that upgrades only when the mail server offers STARTTLS.',
+});
+const SMTP_TLS_NONE_DESCRIPTOR = msg({
+ message: 'None',
+ comment: 'SMTP encryption option that never encrypts the connection.',
+});
+const SMTP_FAILED_DESCRIPTOR = msg({
+ message: 'Fluxer couldn\'t connect to {host}. The server said: "{error}"',
+ comment: 'Alert when the SMTP check fails. host is the mail server address and error is its reply.',
+});
+const SMTP_FAILED_NO_REPLY_DESCRIPTOR = msg({
+ message: "Fluxer couldn't connect to {host}.",
+ comment: 'Alert when the SMTP check fails and the mail server sent no reply. host is the mail server address.',
+});
+const SMTP_SAVE_ANYWAY_DESCRIPTOR = msg({
+ message: 'Save anyway',
+ comment: 'Text button that keeps SMTP details even though the connection check failed.',
+});
+const SMTP_LATER_DESCRIPTOR = msg({
+ message: 'Set up email later',
+ comment: 'Text button that skips connecting an email service during setup.',
+});
+
+const EMAIL_SENDER_TITLE_DESCRIPTOR = msg({
+ message: 'Who should emails come from?',
+ comment: 'Setup wizard title for the sender address and name of outgoing email.',
+});
+const FROM_ADDRESS_LABEL_DESCRIPTOR = msg({
+ message: 'From address',
+ comment: 'Label for the email address outgoing email is sent from.',
+});
+const FROM_ADDRESS_ERROR_DESCRIPTOR = msg({
+ message: 'Enter an email address.',
+ comment: 'Error under the from address field in the setup wizard.',
+});
+const FROM_NAME_LABEL_DESCRIPTOR = msg({
+ message: 'From name',
+ comment: 'Label for the sender name shown on outgoing email.',
+});
+
+function smtpDraftFromConfig(config: InstanceConfigResponse, current: SmtpDraft): SmtpDraft {
+ const email = config.integrations.email;
+ return {
+ host: email.smtp.host ?? current.host,
+ port: email.smtp.port ? String(email.smtp.port) : current.port,
+ tlsMode: email.smtp.tls_mode ?? current.tlsMode,
+ username: email.smtp.username ?? current.username,
+ password: current.password,
+ fromEmail: email.from_email ?? current.fromEmail,
+ fromName: email.from_name ?? current.fromName,
+ };
+}
+
+const EMPTY_SMTP_DRAFT: SmtpDraft = {
+ host: '',
+ port: DEFAULT_SMTP_PORT,
+ tlsMode: 'auto',
+ username: '',
+ password: '',
+ fromEmail: '',
+ fromName: '',
+};
+
+interface EmailDraftState {
+ draft: SmtpDraft;
+ failure: string | null;
+ updateDraft: (patch: Partial<SmtpDraft>) => void;
+ hydrate: (config: InstanceConfigResponse) => void;
+ setFailure: (failure: string | null) => void;
+}
+
+const EmailDraftContext = createContext<EmailDraftState | null>(null);
+
+export function SetupEmailDraftProvider({children}: {children: ReactNode}) {
+ const [draft, setDraft] = useState<SmtpDraft>(EMPTY_SMTP_DRAFT);
+ const [failure, setFailure] = useState<string | null>(null);
+ const updateDraft = useCallback((patch: Partial<SmtpDraft>) => {
+ setDraft((current) => ({...current, ...patch}));
+ }, []);
+ const hydrate = useCallback((config: InstanceConfigResponse) => {
+ setDraft((current) => smtpDraftFromConfig(config, current));
+ }, []);
+ const state = useMemo(
+ () => ({draft, failure, updateDraft, hydrate, setFailure}),
+ [draft, failure, updateDraft, hydrate],
+ );
+ return <EmailDraftContext.Provider value={state}>{children}</EmailDraftContext.Provider>;
+}
+
+export function useSetupEmailDraft(): EmailDraftState {
+ const draft = useContext(EmailDraftContext);
+ if (draft === null) throw new Error('Setup email draft provider is missing');
+ return draft;
+}
+
+interface SmtpDraft {
+ host: string;
+ port: string;
+ tlsMode: SmtpTlsChoice;
+ username: string;
+ password: string;
+ fromEmail: string;
+ fromName: string;
+}
+
+export function parseSmtpPort(value: string): number | null {
+ if (!/^\d+$/.test(value.trim())) return null;
+ const parsed = Number.parseInt(value, 10);
+ return parsed >= MIN_SMTP_PORT && parsed <= MAX_SMTP_PORT ? parsed : null;
+}
+
+export const EmailServiceStep = observer(
+ ({
+ formRef,
+ error,
+ disabled,
+ onSubmit,
+ onAdvance,
+ onError,
+ onLater,
+ }: {
+ formRef: RefObject<HTMLFormElement | null>;
+ error: string | null;
+ disabled: boolean;
+ onSubmit: (submit: () => Promise<void>) => Promise<void>;
+ onAdvance: () => void;
+ onError: (error: string) => void;
+ onLater: () => void;
+ }) => {
+ const {i18n} = useLingui();
+ const {draft, failure, updateDraft, setFailure} = useSetupEmailDraft();
+ const smtpPort = parseSmtpPort(draft.port);
+ const smtpTlsMode = draft.tlsMode === 'auto' ? null : draft.tlsMode;
+ const onChange = (patch: Partial<SmtpDraft>) => {
+ updateDraft(patch);
+ setFailure(null);
+ };
+ const testSmtp = async () => {
+ if (smtpPort === null) return;
+ try {
+ const result = await testSmtpConfig({
+ host: draft.host.trim(),
+ port: smtpPort,
+ username: draft.username.trim() || null,
+ password: draft.password.trim() || null,
+ tls_mode: smtpTlsMode ?? resolveSmtpTlsMode(null, smtpPort),
+ });
+ if (result.ok) {
+ setFailure(null);
+ onAdvance();
+ return;
+ }
+ setFailure(result.error ?? '');
+ } catch (error) {
+ onError(FormUtils.extractErrorMessage(i18n, error));
+ }
+ };
+
+ const portInvalid = draft.port.trim().length > 0 && parseSmtpPort(draft.port) === null;
+ const tlsOptions: ReadonlyArray<RadioOption<SmtpTlsChoice>> = [
+ {value: 'auto', name: i18n._(SMTP_TLS_AUTO_DESCRIPTOR)},
+ {value: SmtpTlsModes.IMPLICIT, name: i18n._(SMTP_TLS_IMPLICIT_DESCRIPTOR)},
+ {value: SmtpTlsModes.STARTTLS, name: i18n._(SMTP_TLS_STARTTLS_DESCRIPTOR)},
+ {value: SmtpTlsModes.OPPORTUNISTIC, name: i18n._(SMTP_TLS_OPPORTUNISTIC_DESCRIPTOR)},
+ {value: SmtpTlsModes.NONE, name: i18n._(SMTP_TLS_NONE_DESCRIPTOR)},
+ ];
+ return (
+ <form
+ ref={formRef}
+ noValidate
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onSubmit(testSmtp);
+ }}
+ className={styles.step}
+ data-flx="app.self-hosted-setup-wizard-gate.email-service-step"
+ >
+ <StepHeader
+ title={i18n._(EMAIL_SERVICE_TITLE_DESCRIPTOR)}
+ body={i18n._(EMAIL_SERVICE_BODY_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.email-service-step.step-header"
+ />
+ <div className={styles.fieldRow} data-flx="app.self-hosted-setup-wizard-gate.smtp-server-row">
+ <Input
+ label={i18n._(SMTP_SERVER_LABEL_DESCRIPTOR)}
+ value={draft.host}
+ placeholder="smtp.example.com"
+ autoComplete="off"
+ autoCapitalize="none"
+ spellCheck={false}
+ disabled={disabled}
+ onChange={(event) => onChange({host: event.target.value})}
+ data-flx="app.self-hosted-setup-wizard-gate.smtp-host-input"
+ />
+ <Input
+ label={i18n._(SMTP_PORT_LABEL_DESCRIPTOR)}
+ value={draft.port}
+ inputMode="numeric"
+ autoComplete="off"
+ disabled={disabled}
+ error={portInvalid ? i18n._(SMTP_PORT_ERROR_DESCRIPTOR) : undefined}
+ onChange={(event) => onChange({port: event.target.value})}
+ data-flx="app.self-hosted-setup-wizard-gate.smtp-port-input"
+ />
+ </div>
+ <div
+ className={styles.fieldLabel}
+ id="setup-smtp-tls-label"
+ data-flx="app.self-hosted-setup-wizard-gate.smtp-tls-label"
+ >
+ {i18n._(SMTP_TLS_LABEL_DESCRIPTOR)}
+ </div>
+ <RadioGroup
+ options={tlsOptions}
+ value={draft.tlsMode}
+ onChange={(tlsMode) => onChange({tlsMode})}
+ disabled={disabled}
+ aria-label={i18n._(SMTP_TLS_LABEL_DESCRIPTOR)}
+ data-flx="app.self-hosted-setup-wizard-gate.smtp-tls-radio-group"
+ />
+ <Input
+ label={i18n._(SMTP_USERNAME_LABEL_DESCRIPTOR)}
+ value={draft.username}
+ autoComplete="off"
+ autoCapitalize="none"
+ spellCheck={false}
+ disabled={disabled}
+ onChange={(event) => onChange({username: event.target.value})}
+ data-flx="app.self-hosted-setup-wizard-gate.smtp-username-input"
+ />
+ <Input
+ label={i18n._(SMTP_PASSWORD_LABEL_DESCRIPTOR)}
+ type="password"
+ value={draft.password}
+ autoComplete="off"
+ disabled={disabled}
+ onChange={(event) => onChange({password: event.target.value})}
+ data-flx="app.self-hosted-setup-wizard-gate.smtp-password-input"
+ />
+ <Note data-flx="app.setup.setup-wizard-steps.email-service-step.credentials-note">
+ {i18n._(SMTP_CREDENTIALS_OPTIONAL_DESCRIPTOR)}
+ </Note>
+ {failure !== null && (
+ <div className={styles.alertBlock} data-flx="app.self-hosted-setup-wizard-gate.smtp-failure">
+ <p className={styles.alert} role="alert" data-flx="app.self-hosted-setup-wizard-gate.smtp-failure-text">
+ {failure
+ ? i18n._(SMTP_FAILED_DESCRIPTOR, {host: draft.host.trim(), error: failure})
+ : i18n._(SMTP_FAILED_NO_REPLY_DESCRIPTOR, {host: draft.host.trim()})}
+ </p>
+ <TextButton
+ onClick={() => {
+ setFailure(null);
+ onAdvance();
+ }}
+ disabled={disabled}
+ data-flx="app.setup.setup-wizard-steps.email-service-step.text-button.save-anyway"
+ >
+ {i18n._(SMTP_SAVE_ANYWAY_DESCRIPTOR)}
+ </TextButton>
+ </div>
+ )}
+ <StepError error={error} data-flx="app.setup.setup-wizard-steps.email-service-step.step-error" />
+ <TextButton
+ onClick={onLater}
+ disabled={disabled}
+ data-flx="app.setup.setup-wizard-steps.email-service-step.text-button.later"
+ >
+ {i18n._(SMTP_LATER_DESCRIPTOR)}
+ </TextButton>
+ </form>
+ );
+ },
+);
+
+function isValidEmailAddress(value: string): boolean {
+ return /^[^\s@]+@[^\s@]+$/.test(value.trim());
+}
+
+export const EmailSenderStep = observer(
+ ({
+ formRef,
+ showErrors,
+ disabled,
+ error,
+ onSubmit,
+ onSave,
+ onAdvance,
+ onShowErrors,
+ }: {
+ formRef: RefObject<HTMLFormElement | null>;
+ showErrors: boolean;
+ disabled: boolean;
+ error: string | null;
+ onSubmit: (submit: () => Promise<void>) => Promise<void>;
+ onSave: (patch: Parameters<typeof updateInstanceConfig>[0]) => Promise<boolean>;
+ onAdvance: () => void;
+ onShowErrors: (show: boolean) => void;
+ }) => {
+ const {i18n} = useLingui();
+ const {draft, updateDraft: onChange} = useSetupEmailDraft();
+ const smtpPort = parseSmtpPort(draft.port);
+ const smtpTlsMode = draft.tlsMode === 'auto' ? null : draft.tlsMode;
+ const saveSender = async () => {
+ onShowErrors(true);
+ const host = draft.host.trim();
+ if (!host || !isValidEmailAddress(draft.fromEmail) || smtpPort === null) return;
+ const saved = await onSave({
+ integrations: {
+ email: {
+ enabled: true,
+ provider: 'smtp',
+ from_email: draft.fromEmail.trim(),
+ from_name: draft.fromName.trim() || null,
+ smtp: {
+ host,
+ port: smtpPort,
+ username: draft.username.trim(),
+ ...(draft.password ? {password: draft.password} : {}),
+ tls_mode: smtpTlsMode ?? resolveSmtpTlsMode(null, smtpPort),
+ },
+ },
+ },
+ });
+ if (saved) onAdvance();
+ };
+
+ const fromInvalid = showErrors && !isValidEmailAddress(draft.fromEmail);
+ return (
+ <form
+ ref={formRef}
+ noValidate
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onSubmit(saveSender);
+ }}
+ className={styles.step}
+ data-flx="app.self-hosted-setup-wizard-gate.email-sender-step"
+ >
+ <StepHeader
+ title={i18n._(EMAIL_SENDER_TITLE_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.email-sender-step.step-header"
+ />
+ <Input
+ label={i18n._(FROM_ADDRESS_LABEL_DESCRIPTOR)}
+ type="email"
+ value={draft.fromEmail}
+ placeholder="[email protected]"
+ autoComplete="email"
+ disabled={disabled}
+ error={fromInvalid ? i18n._(FROM_ADDRESS_ERROR_DESCRIPTOR) : undefined}
+ onChange={(event) => onChange({fromEmail: event.target.value})}
+ data-flx="app.self-hosted-setup-wizard-gate.from-email-input"
+ />
+ <Input
+ label={i18n._(FROM_NAME_LABEL_DESCRIPTOR)}
+ value={draft.fromName}
+ maxLength={120}
+ autoComplete="off"
+ disabled={disabled}
+ onChange={(event) => onChange({fromName: event.target.value})}
+ data-flx="app.self-hosted-setup-wizard-gate.from-name-input"
+ />
+ <StepError error={error} data-flx="app.setup.setup-wizard-steps.email-sender-step.step-error" />
+ </form>
+ );
+ },
+);
diff --git a/fluxer_app/src/features/app/components/setup/SetupIdentityDraft.ts b/fluxer_app/src/features/app/components/setup/SetupIdentityDraft.ts
new file mode 100644
index 000000000..f33438886
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupIdentityDraft.ts
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import type {EmailDeliveryAnswer} from '@app/features/app/components/setup/SetupWizardStateMachine';
+import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
+import {
+ type AccountIdentityMode,
+ AccountIdentityModes,
+ type TagStyle,
+ TagStyles,
+} from '@fluxer/constants/src/AccountIdentityConstants';
+import {makeAutoObservable} from 'mobx';
+
+export interface SetupIdentityValues {
+ signInMethod: AccountIdentityMode;
+ tagStyle: TagStyle;
+ emailAnswer: EmailDeliveryAnswer;
+}
+
+function isIdentityMode(value: unknown): value is AccountIdentityMode {
+ return value === AccountIdentityModes.EMAIL || value === AccountIdentityModes.USERNAME;
+}
+
+function isTagStyle(value: unknown): value is TagStyle {
+ return value === TagStyles.NONE || value === TagStyles.RANDOM;
+}
+
+export function isEmailAnswer(value: unknown): value is EmailDeliveryAnswer {
+ return value === 'now' || value === 'later';
+}
+
+export class SetupIdentityDraft implements SetupIdentityValues {
+ signInMethod: AccountIdentityMode;
+ tagStyle: TagStyle;
+ emailAnswer: EmailDeliveryAnswer;
+
+ constructor(restoredDraft: Partial<Record<keyof SetupIdentityValues, unknown>> | null) {
+ this.signInMethod = isIdentityMode(restoredDraft?.signInMethod)
+ ? restoredDraft.signInMethod
+ : RuntimeConfig.accountIdentity;
+ this.tagStyle = isTagStyle(restoredDraft?.tagStyle) ? restoredDraft.tagStyle : TagStyles.NONE;
+ this.emailAnswer = isEmailAnswer(restoredDraft?.emailAnswer) ? restoredDraft.emailAnswer : 'now';
+ makeAutoObservable(this, {}, {autoBind: true});
+ }
+
+ setSignInMethod(mode: AccountIdentityMode): void {
+ this.signInMethod = mode;
+ }
+
+ setTagStyle(style: TagStyle): void {
+ this.tagStyle = style;
+ }
+
+ setEmailAnswer(answer: EmailDeliveryAnswer): void {
+ this.emailAnswer = answer;
+ }
+}
diff --git a/fluxer_app/src/features/app/components/setup/SetupIdentitySteps.tsx b/fluxer_app/src/features/app/components/setup/SetupIdentitySteps.tsx
new file mode 100644
index 000000000..9cbe7697e
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupIdentitySteps.tsx
@@ -0,0 +1,322 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
+import type {SetupIdentityDraft} from '@app/features/app/components/setup/SetupIdentityDraft';
+import {setupTokenViolation} from '@app/features/app/components/setup/SetupTokenStep';
+import {setSetupAccountIdentity} from '@app/features/app/components/setup/SetupWizardClient';
+import type {EmailDeliveryAnswer} from '@app/features/app/components/setup/SetupWizardStateMachine';
+import {Note, StepError, StepHeader} from '@app/features/app/components/setup/SetupWizardSteps';
+import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
+import {Logger} from '@app/features/platform/utils/AppLogger';
+import {failureCode} from '@app/features/platform/utils/ResponseInspection';
+import {RadioGroup, type RadioOption} from '@app/features/ui/radio_group/RadioGroup';
+import * as FormUtils from '@app/lib/forms';
+import {
+ type AccountIdentityMode,
+ AccountIdentityModes,
+ type TagStyle,
+ TagStyles,
+} from '@fluxer/constants/src/AccountIdentityConstants';
+import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes';
+import type {I18n} from '@lingui/core';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {observer} from 'mobx-react-lite';
+import type {RefObject} from 'react';
+
+const logger = new Logger('SelfHostedSetupWizardGate');
+
+const SIGN_IN_TITLE_DESCRIPTOR = msg({
+ message: 'How will people sign in?',
+ comment: 'Setup wizard title for choosing whether people sign in with a username or an email address.',
+});
+const SIGN_IN_USERNAME_NAME_DESCRIPTOR = msg({
+ message: 'With a username',
+ comment: 'Setup wizard option where people sign in with a username and a password.',
+});
+const SIGN_IN_USERNAME_DESC_DESCRIPTOR = msg({
+ message:
+ 'People choose a username and a password, and nobody needs an email address. If someone forgets their password, they use the recovery kit they saved, or an admin makes them a reset link.',
+ comment: 'Description of the username sign-in option in the setup wizard.',
+});
+const SIGN_IN_EMAIL_NAME_DESCRIPTOR = msg({
+ message: 'With an email address',
+ comment: 'Setup wizard option where people sign in with an email address.',
+});
+const SIGN_IN_EMAIL_DESC_DESCRIPTOR = msg({
+ message:
+ 'People sign up with their email address. To reset forgotten passwords by email, your instance needs an email service with SMTP details, which you can add in a few steps.',
+ comment: 'Description of the email sign-in option in the setup wizard. SMTP must not be translated.',
+});
+const SIGN_IN_FIXED_NOTE_DESCRIPTOR = msg({
+ message: "You can't change this after you create your account.",
+ comment: 'Note under a setup wizard choice that becomes permanent once the first account exists.',
+});
+
+const SHARED_USERNAMES_TITLE_DESCRIPTOR = msg({
+ message: 'Can two people have the same username?',
+ comment: 'Setup wizard title for choosing whether usernames are unique on an email sign-in instance.',
+});
+const SHARED_USERNAMES_NO_NAME_DESCRIPTOR = msg({
+ message: 'No, every username is unique',
+ comment: 'Setup wizard option where each username belongs to one person.',
+});
+const SHARED_USERNAMES_NO_DESC_DESCRIPTOR = msg({
+ message: 'Each username belongs to one person. If a name is taken, people pick another one.',
+ comment: 'Description of the unique usernames option in the setup wizard.',
+});
+const SHARED_USERNAMES_YES_NAME_DESCRIPTOR = msg({
+ message: 'Yes, with a number after it',
+ comment: 'Setup wizard option where usernames get a random number so several people can share a name.',
+});
+const SHARED_USERNAMES_YES_DESC_DESCRIPTOR = msg({
+ message: 'Fluxer adds a random number to each username, like alex#4821, so many people can use the same name.',
+ comment: 'Description of the shared usernames option in the setup wizard. Keep the example alex#4821 as it is.',
+});
+
+const EMAIL_DELIVERY_TITLE_DESCRIPTOR = msg({
+ message: 'Can your instance send email?',
+ comment: 'Setup wizard title asking whether the person has an email service ready for the instance.',
+});
+const EMAIL_DELIVERY_NOW_NAME_DESCRIPTOR = msg({
+ message: 'Yes, I have SMTP details',
+ comment: 'Setup wizard option for someone who has SMTP details for an email service. SMTP must not be translated.',
+});
+const EMAIL_DELIVERY_NOW_DESC_DESCRIPTOR = msg({
+ message: "You'll enter them right after you create your account.",
+ comment: 'Description of the option to connect an email service during setup.',
+});
+const EMAIL_DELIVERY_LATER_NAME_DESCRIPTOR = msg({
+ message: 'Not yet',
+ comment: 'Setup wizard option for someone who has no email service ready.',
+});
+const EMAIL_DELIVERY_LATER_DESC_DESCRIPTOR = msg({
+ message:
+ 'People can still sign up and sign in. Until you add an email service in the admin panel, nobody can reset a forgotten password, including you.',
+ comment: 'Description of the option to set up email later in the setup wizard.',
+});
+
+interface IdentityStepActions {
+ setupToken: string;
+ onAdvance: () => void;
+ onError: (message: string) => void;
+ onSetupTokenRejected: () => void;
+}
+
+interface IdentityStepForm extends IdentityStepActions {
+ formRef: RefObject<HTMLFormElement | null>;
+ onSubmit: (submit: () => Promise<void> | void) => Promise<void>;
+}
+
+async function saveIdentity({
+ mode,
+ style,
+ setupToken,
+ i18n,
+ onAdvance,
+ onError,
+ onSetupTokenRejected,
+}: IdentityStepActions & {mode: AccountIdentityMode; style: TagStyle; i18n: I18n}): Promise<void> {
+ try {
+ const saved = await setSetupAccountIdentity(mode, style, setupToken.trim() || undefined);
+ await RuntimeConfig.refreshDiscovery();
+ RuntimeConfig.applyAccountIdentity(saved.mode, saved.tag_style);
+ onAdvance();
+ } catch (error) {
+ if (setupTokenViolation(error)) {
+ onSetupTokenRejected();
+ return;
+ }
+ if (failureCode(error) === APIErrorCodes.ACCOUNT_IDENTITY_LOCKED) {
+ await RuntimeConfig.refreshDiscovery().catch((refreshError) => {
+ logger.warn('Could not refresh discovery after the sign-in method locked', refreshError);
+ });
+ return;
+ }
+ logger.error('Failed to save the sign-in method', error);
+ onError(FormUtils.extractErrorMessage(i18n, error));
+ }
+}
+
+export const SignInMethodStep = observer(
+ ({
+ draft,
+ disabled,
+ error,
+ onClearError,
+ formRef,
+ setupToken,
+ onSubmit,
+ onAdvance,
+ onError,
+ onSetupTokenRejected,
+ }: IdentityStepForm & {
+ draft: SetupIdentityDraft;
+ disabled: boolean;
+ error: string | null;
+ onClearError: () => void;
+ }) => {
+ const {i18n} = useLingui();
+ const mode = draft.signInMethod;
+ const onChange = (mode: AccountIdentityMode) => {
+ draft.setSignInMethod(mode);
+ onClearError();
+ };
+ const options: ReadonlyArray<RadioOption<AccountIdentityMode>> = [
+ {
+ value: AccountIdentityModes.USERNAME,
+ name: i18n._(SIGN_IN_USERNAME_NAME_DESCRIPTOR),
+ desc: i18n._(SIGN_IN_USERNAME_DESC_DESCRIPTOR),
+ },
+ {
+ value: AccountIdentityModes.EMAIL,
+ name: i18n._(SIGN_IN_EMAIL_NAME_DESCRIPTOR),
+ desc: i18n._(SIGN_IN_EMAIL_DESC_DESCRIPTOR),
+ },
+ ];
+ const submit = () => {
+ if (mode === AccountIdentityModes.USERNAME) {
+ return saveIdentity({
+ mode: AccountIdentityModes.USERNAME,
+ style: TagStyles.NONE,
+ setupToken,
+ i18n,
+ onAdvance,
+ onError,
+ onSetupTokenRejected,
+ });
+ }
+ onAdvance();
+ return;
+ };
+ return (
+ <form
+ ref={formRef}
+ noValidate
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onSubmit(submit);
+ }}
+ className={styles.step}
+ data-flx="app.self-hosted-setup-wizard-gate.sign-in-method-step"
+ >
+ <StepHeader
+ title={i18n._(SIGN_IN_TITLE_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.sign-in-method-step.step-header"
+ />
+ <RadioGroup
+ options={options}
+ value={mode}
+ onChange={onChange}
+ disabled={disabled}
+ aria-label={i18n._(SIGN_IN_TITLE_DESCRIPTOR)}
+ data-flx="app.self-hosted-setup-wizard-gate.sign-in-method-radio-group"
+ />
+ <Note data-flx="app.setup.setup-wizard-steps.sign-in-method-step.note">
+ {i18n._(SIGN_IN_FIXED_NOTE_DESCRIPTOR)}
+ </Note>
+ <StepError error={error} data-flx="app.setup.setup-wizard-steps.sign-in-method-step.step-error" />
+ </form>
+ );
+ },
+);
+
+export const SharedUsernamesStep = observer(
+ ({
+ draft,
+ disabled,
+ error,
+ formRef,
+ setupToken,
+ onSubmit,
+ onAdvance,
+ onError,
+ onSetupTokenRejected,
+ }: IdentityStepForm & {draft: SetupIdentityDraft; disabled: boolean; error: string | null}) => {
+ const {i18n} = useLingui();
+ const {tagStyle, setTagStyle: onChange} = draft;
+ const options: ReadonlyArray<RadioOption<TagStyle>> = [
+ {
+ value: TagStyles.NONE,
+ name: i18n._(SHARED_USERNAMES_NO_NAME_DESCRIPTOR),
+ desc: i18n._(SHARED_USERNAMES_NO_DESC_DESCRIPTOR),
+ },
+ {
+ value: TagStyles.RANDOM,
+ name: i18n._(SHARED_USERNAMES_YES_NAME_DESCRIPTOR),
+ desc: i18n._(SHARED_USERNAMES_YES_DESC_DESCRIPTOR),
+ },
+ ];
+ const submit = () =>
+ saveIdentity({
+ mode: AccountIdentityModes.EMAIL,
+ style: tagStyle,
+ setupToken,
+ i18n,
+ onAdvance,
+ onError,
+ onSetupTokenRejected,
+ });
+ return (
+ <form
+ ref={formRef}
+ noValidate
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onSubmit(submit);
+ }}
+ className={styles.step}
+ data-flx="app.self-hosted-setup-wizard-gate.shared-usernames-step"
+ >
+ <StepHeader
+ title={i18n._(SHARED_USERNAMES_TITLE_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.shared-usernames-step.step-header"
+ />
+ <RadioGroup
+ options={options}
+ value={tagStyle}
+ onChange={onChange}
+ disabled={disabled}
+ aria-label={i18n._(SHARED_USERNAMES_TITLE_DESCRIPTOR)}
+ data-flx="app.self-hosted-setup-wizard-gate.shared-usernames-radio-group"
+ />
+ <Note data-flx="app.setup.setup-wizard-steps.shared-usernames-step.note">
+ {i18n._(SIGN_IN_FIXED_NOTE_DESCRIPTOR)}
+ </Note>
+ <StepError error={error} data-flx="app.setup.setup-wizard-steps.shared-usernames-step.step-error" />
+ </form>
+ );
+ },
+);
+
+export const EmailDeliveryStep = observer(({draft}: {draft: SetupIdentityDraft}) => {
+ const {i18n} = useLingui();
+ const {emailAnswer: answer, setEmailAnswer: onChange} = draft;
+ const options: ReadonlyArray<RadioOption<EmailDeliveryAnswer>> = [
+ {
+ value: 'now',
+ name: i18n._(EMAIL_DELIVERY_NOW_NAME_DESCRIPTOR),
+ desc: i18n._(EMAIL_DELIVERY_NOW_DESC_DESCRIPTOR),
+ },
+ {
+ value: 'later',
+ name: i18n._(EMAIL_DELIVERY_LATER_NAME_DESCRIPTOR),
+ desc: i18n._(EMAIL_DELIVERY_LATER_DESC_DESCRIPTOR),
+ },
+ ];
+ return (
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.email-delivery-step">
+ <StepHeader
+ title={i18n._(EMAIL_DELIVERY_TITLE_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.email-delivery-step.step-header"
+ />
+ <RadioGroup
+ options={options}
+ value={answer}
+ onChange={onChange}
+ aria-label={i18n._(EMAIL_DELIVERY_TITLE_DESCRIPTOR)}
+ data-flx="app.self-hosted-setup-wizard-gate.email-delivery-radio-group"
+ />
+ </section>
+ );
+});
diff --git a/fluxer_app/src/features/app/components/setup/SetupPolicySteps.tsx b/fluxer_app/src/features/app/components/setup/SetupPolicySteps.tsx
new file mode 100644
index 000000000..df59ba473
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupPolicySteps.tsx
@@ -0,0 +1,367 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
+import {
+ Note,
+ PUSH_NO_NAME_DESCRIPTOR,
+ PUSH_YES_NAME_DESCRIPTOR,
+ REGISTRATION_APPROVAL_NAME_DESCRIPTOR,
+ REGISTRATION_CLOSED_NAME_DESCRIPTOR,
+ REGISTRATION_OPEN_NAME_DESCRIPTOR,
+ type RegistrationMode,
+ StepHeader,
+} from '@app/features/app/components/setup/SetupWizardSteps';
+import {Input} from '@app/features/ui/components/form/FormInput';
+import FocusRing from '@app/features/ui/focus_ring/FocusRing';
+import {RadioGroup, type RadioOption} from '@app/features/ui/radio_group/RadioGroup';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {observer} from 'mobx-react-lite';
+import {
+ createContext,
+ type Dispatch,
+ type ReactNode,
+ type RefObject,
+ type SetStateAction,
+ useCallback,
+ useContext,
+ useMemo,
+ useRef,
+ useState,
+} from 'react';
+
+const PUSH_RELAY_NOTICE_URL = 'https://fluxer.com/push-relay';
+const MIN_COMMUNITY_NAME_LENGTH = 1;
+const MAX_COMMUNITY_NAME_LENGTH = 100;
+
+const COMMUNITIES_TITLE_DESCRIPTOR = msg({
+ message: 'Is this instance for one community or many?',
+ comment: 'Setup wizard title for choosing between many communities and a single community.',
+});
+const COMMUNITIES_MANY_NAME_DESCRIPTOR = msg({
+ message: 'Many communities',
+ comment: 'Setup wizard option where people can create and join many communities.',
+});
+const COMMUNITIES_MANY_DESC_DESCRIPTOR = msg({
+ message: 'People can create their own communities and join as many as they like.',
+ comment: 'Description of the many communities option in the setup wizard.',
+});
+const COMMUNITIES_ONE_NAME_DESCRIPTOR = msg({
+ message: 'One community',
+ comment: 'Setup wizard option where the whole instance is one community.',
+});
+const COMMUNITIES_ONE_DESC_DESCRIPTOR = msg({
+ message:
+ 'Everyone who signs up joins one community that you own, and nobody can create others. This suits a club, a team or a company.',
+ comment: 'Description of the single community option in the setup wizard.',
+});
+const COMMUNITY_NAME_LABEL_DESCRIPTOR = msg({
+ message: 'Community name',
+ comment: 'Label for the name of the single community in the setup wizard.',
+});
+const COMMUNITY_NAME_ERROR_DESCRIPTOR = msg({
+ message: 'Enter a community name between 1 and 100 characters.',
+ comment: 'Error under the community name field in the setup wizard.',
+});
+const COMMUNITIES_NOTE_DESCRIPTOR = msg({
+ message: 'You can switch between one community and many communities later in the admin panel.',
+ comment: 'Note under the community choice in the setup wizard, shown when one community is chosen.',
+});
+
+const DMS_TITLE_DESCRIPTOR = msg({
+ message: 'Can people send each other direct messages?',
+ comment: 'Setup wizard title for choosing whether direct messages are allowed.',
+});
+const DMS_YES_DESC_DESCRIPTOR = msg({
+ message: 'People can send friend requests and direct messages.',
+ comment: 'Description of allowing direct messages in the setup wizard.',
+});
+const DMS_NO_DESC_DESCRIPTOR = msg({
+ message: 'People can only talk in communities.',
+ comment: 'Description of turning off direct messages in the setup wizard.',
+});
+const DMS_NOTE_DESCRIPTOR = msg({
+ message: 'You can turn direct messages and friend requests back on later in the admin panel.',
+ comment: 'Warning shown when direct messages are turned off in the setup wizard.',
+});
+const YES_DESCRIPTOR = msg({
+ message: 'Yes',
+ comment: 'Answer to a yes or no question in the setup wizard.',
+});
+const NO_DESCRIPTOR = msg({
+ message: 'No',
+ comment: 'Answer to a yes or no question in the setup wizard.',
+});
+
+const REGISTRATION_TITLE_DESCRIPTOR = msg({
+ message: 'Who can create an account?',
+ comment: 'Setup wizard title for the registration mode.',
+});
+const REGISTRATION_CLOSED_DESC_DESCRIPTOR = msg({
+ message: 'Nobody can sign up on their own. You make registration links in the admin panel and send them to people.',
+ comment: 'Description of the invite-only registration mode in the setup wizard.',
+});
+const REGISTRATION_APPROVAL_DESC_DESCRIPTOR = msg({
+ message: 'People can sign up, and each new account waits until an admin approves it in the admin panel.',
+ comment: 'Description of the approval registration mode in the setup wizard.',
+});
+const REGISTRATION_OPEN_DESC_DESCRIPTOR = msg({
+ message: 'Anyone who can open your instance can sign up.',
+ comment: 'Description of the open registration mode in the setup wizard.',
+});
+const REGISTRATION_OPEN_NOTE_DESCRIPTOR = msg({
+ message: 'Spam accounts can sign up too. You can turn on a captcha in the admin panel.',
+ comment: 'Note shown when open registration is chosen in the setup wizard.',
+});
+
+const PUSH_TITLE_DESCRIPTOR = msg({
+ message: 'Send notifications to the Fluxer mobile apps?',
+ comment: 'Setup wizard title for the push relay consent.',
+});
+const PUSH_BODY_DESCRIPTOR = msg({
+ message:
+ 'The Fluxer apps for iOS and Android get notifications through a push relay that Fluxer runs, which passes them to Apple and Google. To use it, you accept the push relay privacy notice.',
+ comment: 'Setup wizard body explaining the push relay.',
+});
+const PUSH_NOTICE_LINK_DESCRIPTOR = msg({
+ message: 'Read the push relay privacy notice',
+ comment: 'Link to the push relay privacy notice in the setup wizard.',
+});
+const PUSH_NO_DESC_DESCRIPTOR = msg({
+ message:
+ "People using the Fluxer mobile apps won't get notifications from your instance. You can turn this on later in the admin panel.",
+ comment: 'Description of leaving the push relay off in the setup wizard.',
+});
+
+export interface FinishDraft {
+ registrationMode: RegistrationMode;
+ singleCommunityEnabled: boolean;
+ singleCommunityName: string;
+ directMessagesDisabled: boolean;
+ pushRelayConsentAccepted: boolean;
+}
+
+interface PolicyDraftState {
+ draft: FinishDraft;
+ setDraft: Dispatch<SetStateAction<FinishDraft>>;
+ updateDraft: (patch: Partial<FinishDraft>) => void;
+}
+
+const PolicyDraftContext = createContext<PolicyDraftState | null>(null);
+
+export function SetupPolicyDraftProvider({children}: {children: ReactNode}) {
+ const [draft, setDraft] = useState<FinishDraft>({
+ registrationMode: 'closed',
+ singleCommunityEnabled: false,
+ singleCommunityName: '',
+ directMessagesDisabled: false,
+ pushRelayConsentAccepted: false,
+ });
+ const updateDraft = useCallback((patch: Partial<FinishDraft>) => {
+ setDraft((current) => ({...current, ...patch}));
+ }, []);
+ const value = useMemo(() => ({draft, setDraft, updateDraft}), [draft, updateDraft]);
+ return <PolicyDraftContext.Provider value={value}>{children}</PolicyDraftContext.Provider>;
+}
+
+export function useSetupPolicyDraft(): PolicyDraftState {
+ const state = useContext(PolicyDraftContext);
+ if (state === null) throw new Error('Setup policy draft provider is missing');
+ return state;
+}
+
+function isValidCommunityName(value: string): boolean {
+ const length = value.trim().length;
+ return length >= MIN_COMMUNITY_NAME_LENGTH && length <= MAX_COMMUNITY_NAME_LENGTH;
+}
+
+export const CommunitiesStep = observer(
+ ({
+ formRef,
+ showErrors,
+ onShowErrors,
+ onSubmit,
+ onAdvance,
+ }: {
+ formRef: RefObject<HTMLFormElement | null>;
+ showErrors: boolean;
+ onShowErrors: (show: boolean) => void;
+ onSubmit: (submit: () => void) => Promise<void>;
+ onAdvance: () => void;
+ }) => {
+ const {i18n} = useLingui();
+ const {draft, updateDraft} = useSetupPolicyDraft();
+ const singleCommunity = draft.singleCommunityEnabled;
+ const communityName = draft.singleCommunityName;
+ const nameInputRef = useRef<HTMLInputElement | null>(null);
+ const continueWithCommunity = () => {
+ onShowErrors(true);
+ if (!draft.singleCommunityEnabled || isValidCommunityName(draft.singleCommunityName)) {
+ onAdvance();
+ } else {
+ nameInputRef.current?.focus();
+ }
+ };
+ const options: ReadonlyArray<RadioOption<'many' | 'one'>> = [
+ {
+ value: 'many',
+ name: i18n._(COMMUNITIES_MANY_NAME_DESCRIPTOR),
+ desc: i18n._(COMMUNITIES_MANY_DESC_DESCRIPTOR),
+ },
+ {value: 'one', name: i18n._(COMMUNITIES_ONE_NAME_DESCRIPTOR), desc: i18n._(COMMUNITIES_ONE_DESC_DESCRIPTOR)},
+ ];
+ return (
+ <form
+ ref={formRef}
+ noValidate
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onSubmit(continueWithCommunity);
+ }}
+ className={styles.step}
+ data-flx="app.self-hosted-setup-wizard-gate.communities-step"
+ >
+ <StepHeader
+ title={i18n._(COMMUNITIES_TITLE_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.communities-step.step-header"
+ />
+ <RadioGroup
+ options={options}
+ value={singleCommunity ? 'one' : 'many'}
+ onChange={(value) => updateDraft({singleCommunityEnabled: value === 'one'})}
+ aria-label={i18n._(COMMUNITIES_TITLE_DESCRIPTOR)}
+ data-flx="app.self-hosted-setup-wizard-gate.communities-radio-group"
+ />
+ {singleCommunity && (
+ <Input
+ ref={nameInputRef}
+ label={i18n._(COMMUNITY_NAME_LABEL_DESCRIPTOR)}
+ value={communityName}
+ maxLength={MAX_COMMUNITY_NAME_LENGTH}
+ autoComplete="off"
+ error={
+ showErrors && !isValidCommunityName(communityName) ? i18n._(COMMUNITY_NAME_ERROR_DESCRIPTOR) : undefined
+ }
+ onChange={(event) => updateDraft({singleCommunityName: event.target.value})}
+ data-flx="app.self-hosted-setup-wizard-gate.community-name-input"
+ />
+ )}
+ {singleCommunity && (
+ <Note data-flx="app.setup.setup-wizard-steps.communities-step.note">
+ {i18n._(COMMUNITIES_NOTE_DESCRIPTOR)}
+ </Note>
+ )}
+ </form>
+ );
+ },
+);
+
+export const DirectMessagesStep = observer(() => {
+ const {i18n} = useLingui();
+ const {
+ draft: {directMessagesDisabled: disabled},
+ updateDraft,
+ } = useSetupPolicyDraft();
+ const options: ReadonlyArray<RadioOption<'yes' | 'no'>> = [
+ {value: 'yes', name: i18n._(YES_DESCRIPTOR), desc: i18n._(DMS_YES_DESC_DESCRIPTOR)},
+ {value: 'no', name: i18n._(NO_DESCRIPTOR), desc: i18n._(DMS_NO_DESC_DESCRIPTOR)},
+ ];
+ return (
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.direct-messages-step">
+ <StepHeader
+ title={i18n._(DMS_TITLE_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.direct-messages-step.step-header"
+ />
+ <RadioGroup
+ options={options}
+ value={disabled ? 'no' : 'yes'}
+ onChange={(value) => updateDraft({directMessagesDisabled: value === 'no'})}
+ aria-label={i18n._(DMS_TITLE_DESCRIPTOR)}
+ data-flx="app.self-hosted-setup-wizard-gate.direct-messages-radio-group"
+ />
+ {disabled && (
+ <Note data-flx="app.setup.setup-wizard-steps.direct-messages-step.note">{i18n._(DMS_NOTE_DESCRIPTOR)}</Note>
+ )}
+ </section>
+ );
+});
+
+export const RegistrationStep = observer(() => {
+ const {i18n} = useLingui();
+ const {
+ draft: {registrationMode: mode},
+ updateDraft,
+ } = useSetupPolicyDraft();
+ const options: ReadonlyArray<RadioOption<RegistrationMode>> = [
+ {
+ value: 'closed',
+ name: i18n._(REGISTRATION_CLOSED_NAME_DESCRIPTOR),
+ desc: i18n._(REGISTRATION_CLOSED_DESC_DESCRIPTOR),
+ },
+ {
+ value: 'approval',
+ name: i18n._(REGISTRATION_APPROVAL_NAME_DESCRIPTOR),
+ desc: i18n._(REGISTRATION_APPROVAL_DESC_DESCRIPTOR),
+ },
+ {value: 'open', name: i18n._(REGISTRATION_OPEN_NAME_DESCRIPTOR), desc: i18n._(REGISTRATION_OPEN_DESC_DESCRIPTOR)},
+ ];
+ return (
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.registration-step">
+ <StepHeader
+ title={i18n._(REGISTRATION_TITLE_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.registration-step.step-header"
+ />
+ <RadioGroup
+ options={options}
+ value={mode}
+ onChange={(registrationMode) => updateDraft({registrationMode})}
+ aria-label={i18n._(REGISTRATION_TITLE_DESCRIPTOR)}
+ data-flx="app.self-hosted-setup-wizard-gate.registration-radio-group"
+ />
+ {mode === 'open' && (
+ <Note data-flx="app.setup.setup-wizard-steps.registration-step.note">
+ {i18n._(REGISTRATION_OPEN_NOTE_DESCRIPTOR)}
+ </Note>
+ )}
+ </section>
+ );
+});
+
+export const PushRelayStep = observer(() => {
+ const {i18n} = useLingui();
+ const {
+ draft: {pushRelayConsentAccepted: accepted},
+ updateDraft,
+ } = useSetupPolicyDraft();
+ const options: ReadonlyArray<RadioOption<'yes' | 'no'>> = [
+ {value: 'yes', name: i18n._(PUSH_YES_NAME_DESCRIPTOR)},
+ {value: 'no', name: i18n._(PUSH_NO_NAME_DESCRIPTOR), desc: i18n._(PUSH_NO_DESC_DESCRIPTOR)},
+ ];
+ return (
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.push-relay-step">
+ <StepHeader
+ title={i18n._(PUSH_TITLE_DESCRIPTOR)}
+ body={i18n._(PUSH_BODY_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.push-relay-step.step-header"
+ />
+ <FocusRing data-flx="app.self-hosted-setup-wizard-gate.push-relay-notice-focus-ring">
+ <a
+ className={styles.link}
+ href={PUSH_RELAY_NOTICE_URL}
+ target="_blank"
+ rel="noreferrer"
+ data-flx="app.self-hosted-setup-wizard-gate.push-relay-notice-link"
+ >
+ {i18n._(PUSH_NOTICE_LINK_DESCRIPTOR)}
+ </a>
+ </FocusRing>
+ <RadioGroup
+ options={options}
+ value={accepted ? 'yes' : 'no'}
+ onChange={(value) => updateDraft({pushRelayConsentAccepted: value === 'yes'})}
+ aria-label={i18n._(PUSH_TITLE_DESCRIPTOR)}
+ data-flx="app.self-hosted-setup-wizard-gate.push-relay-radio-group"
+ />
+ </section>
+ );
+});
diff --git a/fluxer_app/src/features/app/components/setup/SetupRecoveryKitStep.tsx b/fluxer_app/src/features/app/components/setup/SetupRecoveryKitStep.tsx
new file mode 100644
index 000000000..86f11ba14
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupRecoveryKitStep.tsx
@@ -0,0 +1,147 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
+import {Note, StepHeader} from '@app/features/app/components/setup/SetupWizardSteps';
+import {Logger} from '@app/features/platform/utils/AppLogger';
+import {Button} from '@app/features/ui/button/Button';
+import * as RecoveryKitCommands from '@app/features/user/commands/RecoveryKitCommands';
+import {confirmNewRecoveryKit} from '@app/features/user/components/modals/tabs/account_security_tab/RecoveryKitSettings';
+import Users from '@app/features/user/state/Users';
+import * as FormUtils from '@app/lib/forms';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {CheckCircleIcon} from '@phosphor-icons/react';
+import {makeAutoObservable} from 'mobx';
+import {observer} from 'mobx-react-lite';
+import {type RefObject, useCallback} from 'react';
+
+const logger = new Logger('SelfHostedSetupWizardGate');
+
+const RECOVERY_KIT_TITLE_DESCRIPTOR = msg({
+ message: 'Save your recovery kit',
+ comment: 'Setup wizard title asking the administrator to save a recovery kit.',
+});
+const RECOVERY_KIT_BODY_DESCRIPTOR = msg({
+ message:
+ "This instance doesn't use email, and you're the only administrator. If you forget your password, your recovery kit is the only way back into your account.",
+ comment: 'Setup wizard body explaining why the administrator needs a recovery kit.',
+});
+const RECOVERY_KIT_CREATE_DESCRIPTOR = msg({
+ message: 'Create recovery kit',
+ comment: 'Button that creates a recovery kit in the setup wizard.',
+});
+const RECOVERY_KIT_RECREATE_DESCRIPTOR = msg({
+ message: 'Create a new kit',
+ comment: 'Button that replaces the recovery kit in the setup wizard.',
+});
+const RECOVERY_KIT_HELP_DESCRIPTOR = msg({
+ message: 'Keep a copy somewhere other than this computer, like a password manager.',
+ comment: 'Advice on where to keep the recovery kit, in the setup wizard.',
+});
+const RECOVERY_KIT_SAVED_DESCRIPTOR = msg({
+ message: 'You saved a recovery kit.',
+ comment: 'Status in the setup wizard once the administrator has a recovery kit.',
+});
+
+export class SetupRecoveryKitDraft {
+ creation: 'idle' | 'pending' = 'idle';
+ stored = false;
+
+ constructor() {
+ makeAutoObservable(this, {}, {autoBind: true});
+ }
+
+ beginCreation(): void {
+ this.creation = 'pending';
+ this.stored = false;
+ }
+
+ acknowledge(): void {
+ this.stored = true;
+ }
+
+ finishCreation(): void {
+ this.creation = 'idle';
+ }
+}
+
+export const RecoveryKitStep = observer(
+ ({
+ draft,
+ currentUserId,
+ hasRecoveryKit,
+ adminPasswordRef,
+ }: {
+ draft: SetupRecoveryKitDraft;
+ currentUserId: string | null;
+ hasRecoveryKit: boolean;
+ adminPasswordRef: RefObject<string | null>;
+ }) => {
+ const {i18n} = useLingui();
+ const createRecoveryKit = useCallback(async () => {
+ draft.beginCreation();
+ const onDone = () => draft.acknowledge();
+ try {
+ const password = adminPasswordRef.current;
+ if (password && currentUserId) {
+ await RecoveryKitCommands.createRecoveryKitWithPasswordAndOpen({
+ userId: currentUserId,
+ password,
+ username: Users.getCurrentUser()?.username,
+ onDone,
+ });
+ } else {
+ await RecoveryKitCommands.createAndShowRecoveryKit(onDone);
+ }
+ } catch (error) {
+ logger.error('Failed to create the administrator recovery kit', error);
+ FormUtils.pushApiErrorModal(i18n, error);
+ } finally {
+ draft.finishCreation();
+ }
+ }, [currentUserId, i18n, draft, adminPasswordRef]);
+
+ const handleCreateRecoveryKit = useCallback(() => {
+ if (!hasRecoveryKit) {
+ void createRecoveryKit();
+ return;
+ }
+ confirmNewRecoveryKit(i18n, createRecoveryKit);
+ }, [hasRecoveryKit, i18n, createRecoveryKit]);
+
+ const {stored, creation} = draft;
+ return (
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.recovery-kit-step">
+ <StepHeader
+ title={i18n._(RECOVERY_KIT_TITLE_DESCRIPTOR)}
+ body={i18n._(RECOVERY_KIT_BODY_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.recovery-kit-step.step-header"
+ />
+ {stored && (
+ <p className={styles.success} role="status" data-flx="app.self-hosted-setup-wizard-gate.recovery-kit-saved">
+ <CheckCircleIcon
+ size={20}
+ weight="fill"
+ aria-hidden="true"
+ data-flx="app.setup.setup-wizard-steps.recovery-kit-step.check-circle-icon"
+ />
+ {i18n._(RECOVERY_KIT_SAVED_DESCRIPTOR)}
+ </p>
+ )}
+ <div className={styles.actionRow} data-flx="app.self-hosted-setup-wizard-gate.recovery-kit-actions">
+ <Button
+ variant={stored ? 'secondary' : 'primary'}
+ submitting={creation === 'pending'}
+ onClick={handleCreateRecoveryKit}
+ data-flx="app.self-hosted-setup-wizard-gate.recovery-kit-create"
+ >
+ {i18n._(stored ? RECOVERY_KIT_RECREATE_DESCRIPTOR : RECOVERY_KIT_CREATE_DESCRIPTOR)}
+ </Button>
+ </div>
+ <Note data-flx="app.setup.setup-wizard-steps.recovery-kit-step.note">
+ {i18n._(RECOVERY_KIT_HELP_DESCRIPTOR)}
+ </Note>
+ </section>
+ );
+ },
+);
diff --git a/fluxer_app/src/features/app/components/setup/SetupReviewStep.tsx b/fluxer_app/src/features/app/components/setup/SetupReviewStep.tsx
new file mode 100644
index 000000000..f006aef50
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupReviewStep.tsx
@@ -0,0 +1,242 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
+import type {BrandingAssetState} from '@app/features/app/components/setup/SetupBrandingDraft';
+import {DEFAULT_THEME_COLOR} from '@app/features/app/components/setup/SetupBrandingFields';
+import type {FinishDraft} from '@app/features/app/components/setup/SetupPolicySteps';
+import type {WizardStep} from '@app/features/app/components/setup/SetupWizardStateMachine';
+import {StepHeader, SUMMARY_DESCRIPTORS, TextButton} from '@app/features/app/components/setup/SetupWizardSteps';
+import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
+import {int2hex} from '@app/features/theme/utils/ColorUtils';
+import Users from '@app/features/user/state/Users';
+import {AccountIdentityModes, TagStyles} from '@fluxer/constants/src/AccountIdentityConstants';
+import type {InstanceConfigResponse} from '@fluxer/schema/src/domains/admin/AdminSchemas';
+import type {I18n, MessageDescriptor} from '@lingui/core';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {observer} from 'mobx-react-lite';
+import type React from 'react';
+
+const REVIEW_TITLE_DESCRIPTOR = msg({
+ message: 'Check your choices',
+ comment: 'Setup wizard title for the review screen before finishing.',
+});
+const REVIEW_BODY_DESCRIPTOR = msg({
+ message: "How people sign in can't change after setup. You can change everything else later in the admin panel.",
+ comment: 'Setup wizard body on the review screen.',
+});
+const REVIEW_CHANGE_DESCRIPTOR = msg({
+ message: 'Change',
+ comment: 'Link on the setup wizard review screen that goes back to one answer.',
+});
+const REVIEW_CHANGE_LABEL_DESCRIPTOR = msg({
+ message: 'Change {row}',
+ comment: 'Accessible label of a review link. row is the name of the answer, such as Name or Direct messages.',
+});
+const FINISH_ERROR_DESCRIPTOR = msg({
+ message: "Setup didn't finish. {error}",
+ comment: 'Alert when saving the setup fails. error is the reason from the server.',
+});
+
+interface ReviewStepProps {
+ config: Pick<InstanceConfigResponse, 'account_identity' | 'integrations'> | null;
+ finishDraft: FinishDraft;
+ productName: string;
+ themeColor: number | null;
+ assets: ReadonlyArray<BrandingAssetState>;
+ attachmentsEnabled: boolean;
+ accountUsername: string;
+ error: string | null;
+ onChange: (step: WizardStep) => void;
+ onEmailChange: () => void;
+}
+
+interface ReviewRow {
+ key: string;
+ label: string;
+ value: React.ReactNode;
+ onChange?: () => void;
+}
+
+function reviewRows(
+ {
+ config,
+ finishDraft,
+ productName,
+ themeColor,
+ assets,
+ attachmentsEnabled,
+ accountUsername,
+ onChange,
+ onEmailChange,
+ }: ReviewStepProps,
+ i18n: I18n,
+): ReadonlyArray<ReviewRow> {
+ if (!config) return [];
+ const t = (descriptor: MessageDescriptor, values?: Record<string, unknown>) => i18n._(descriptor, values);
+ const usernameMode = config.account_identity.mode === AccountIdentityModes.USERNAME;
+ const logo = assets.find((asset) => asset.kind === 'logo');
+ const logoSource = logo?.preview ?? logo?.url ?? null;
+ const emailService = config.integrations.email;
+ const signInLabel = t(SUMMARY_DESCRIPTORS.signIn);
+ let signInDescriptor = SUMMARY_DESCRIPTORS.emailAddressesUnique;
+ if (usernameMode) signInDescriptor = SUMMARY_DESCRIPTORS.usernames;
+ else if (config.account_identity.tag_style === TagStyles.RANDOM)
+ signInDescriptor = SUMMARY_DESCRIPTORS.emailAddressesShared;
+ const registrationSummary = {
+ closed: SUMMARY_DESCRIPTORS.registrationClosed,
+ approval: SUMMARY_DESCRIPTORS.registrationApproval,
+ open: SUMMARY_DESCRIPTORS.registrationOpen,
+ }[finishDraft.registrationMode];
+ const rows: Array<ReviewRow> = [
+ {
+ key: 'sign_in',
+ label: signInLabel,
+ value: t(signInDescriptor),
+ },
+ {
+ key: 'account',
+ label: t(SUMMARY_DESCRIPTORS.account),
+ value: (
+ <bdi data-flx="app.setup.self-hosted-setup-wizard-gate.review-rows.bdi">
+ {`@${Users.getCurrentUser()?.username ?? accountUsername}`}
+ </bdi>
+ ),
+ },
+ ];
+ if (!usernameMode) {
+ const label = t(SUMMARY_DESCRIPTORS.email);
+ let value: string;
+ if (RuntimeConfig.emailsEnabled) value = t(SUMMARY_DESCRIPTORS.emailAlreadySet);
+ else if (emailService.effective_enabled) {
+ value = t(SUMMARY_DESCRIPTORS.emailFrom, {
+ host: emailService.smtp.host ?? '',
+ from: emailService.from_email ?? '',
+ });
+ } else value = t(SUMMARY_DESCRIPTORS.emailLater);
+ rows.push({key: 'email', label, value, onChange: RuntimeConfig.emailsEnabled ? undefined : onEmailChange});
+ }
+ rows.push(
+ {key: 'name', label: t(SUMMARY_DESCRIPTORS.name), value: productName.trim(), onChange: () => onChange('name')},
+ {
+ key: 'look',
+ label: t(SUMMARY_DESCRIPTORS.look),
+ value: (
+ <span
+ className={styles.lookSummary}
+ data-flx="app.setup.self-hosted-setup-wizard-gate.review-rows.look-summary"
+ >
+ <span
+ className={styles.colorSwatch}
+ style={{background: int2hex(themeColor ?? DEFAULT_THEME_COLOR)}}
+ aria-hidden="true"
+ data-flx="app.setup.self-hosted-setup-wizard-gate.review-rows.color-swatch"
+ />
+ <span data-flx="app.setup.self-hosted-setup-wizard-gate.review-rows.span">
+ {themeColor === null ? t(SUMMARY_DESCRIPTORS.defaultColor) : int2hex(themeColor)}
+ </span>
+ {logoSource && (
+ <img
+ className={styles.logoThumb}
+ src={logoSource}
+ alt=""
+ data-flx="app.setup.self-hosted-setup-wizard-gate.review-rows.logo-thumb"
+ />
+ )}
+ </span>
+ ),
+ onChange: () => onChange('look'),
+ },
+ {
+ key: 'communities',
+ label: t(SUMMARY_DESCRIPTORS.communities),
+ value: finishDraft.singleCommunityEnabled
+ ? t(SUMMARY_DESCRIPTORS.singleCommunity, {name: finishDraft.singleCommunityName.trim()})
+ : t(SUMMARY_DESCRIPTORS.manyCommunities),
+ onChange: () => onChange('communities'),
+ },
+ {
+ key: 'direct_messages',
+ label: t(SUMMARY_DESCRIPTORS.directMessages),
+ value: t(finishDraft.directMessagesDisabled ? SUMMARY_DESCRIPTORS.off : SUMMARY_DESCRIPTORS.allowed),
+ onChange: () => onChange('direct_messages'),
+ },
+ {
+ key: 'registration',
+ label: t(SUMMARY_DESCRIPTORS.registration),
+ value: t(registrationSummary),
+ onChange: () => onChange('registration'),
+ },
+ {
+ key: 'push',
+ label: t(SUMMARY_DESCRIPTORS.push),
+ value: t(finishDraft.pushRelayConsentAccepted ? SUMMARY_DESCRIPTORS.pushOn : SUMMARY_DESCRIPTORS.pushOff),
+ onChange: () => onChange('push_relay'),
+ },
+ {
+ key: 'gif',
+ label: t(SUMMARY_DESCRIPTORS.gif),
+ value: t(config.integrations.gif.klipy_api_key_set ? SUMMARY_DESCRIPTORS.on : SUMMARY_DESCRIPTORS.skipped),
+ onChange: () => onChange('gif_youtube'),
+ },
+ {
+ key: 'youtube',
+ label: t(SUMMARY_DESCRIPTORS.youtube),
+ value: t(config.integrations.youtube.api_key_set ? SUMMARY_DESCRIPTORS.on : SUMMARY_DESCRIPTORS.skipped),
+ onChange: () => onChange('gif_youtube'),
+ },
+ {
+ key: 'attachments',
+ label: t(SUMMARY_DESCRIPTORS.attachments),
+ value: t(attachmentsEnabled ? SUMMARY_DESCRIPTORS.deleteOld : SUMMARY_DESCRIPTORS.keepAll),
+ onChange: () => onChange('attachments'),
+ },
+ );
+ return rows;
+}
+
+export const ReviewStep = observer((props: ReviewStepProps) => {
+ const {i18n} = useLingui();
+ const {error} = props;
+ const rows = reviewRows(props, i18n);
+ return (
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.review-step">
+ <StepHeader
+ title={i18n._(REVIEW_TITLE_DESCRIPTOR)}
+ body={i18n._(REVIEW_BODY_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.review-step.step-header"
+ />
+ <dl className={styles.summary} data-flx="app.self-hosted-setup-wizard-gate.summary">
+ {rows.map((row) => (
+ <div key={row.key} className={styles.summaryRow} data-flx="app.self-hosted-setup-wizard-gate.summary-row">
+ <dt className={styles.summaryLabel} data-flx="app.self-hosted-setup-wizard-gate.summary-label">
+ {row.label}
+ </dt>
+ <dd className={styles.summaryValue} data-flx="app.self-hosted-setup-wizard-gate.summary-value">
+ <span
+ className={styles.summaryValueText}
+ data-flx="app.setup.setup-wizard-steps.review-step.summary-value-text"
+ >
+ {row.value}
+ </span>
+ {row.onChange && (
+ <TextButton
+ onClick={row.onChange}
+ ariaLabel={i18n._(REVIEW_CHANGE_LABEL_DESCRIPTOR, {row: row.label})}
+ data-flx="app.setup.setup-wizard-steps.review-step.text-button.change"
+ >
+ {i18n._(REVIEW_CHANGE_DESCRIPTOR)}
+ </TextButton>
+ )}
+ </dd>
+ </div>
+ ))}
+ </dl>
+ {error && (
+ <p className={styles.alert} role="alert" data-flx="app.self-hosted-setup-wizard-gate.finish-error">
+ {i18n._(FINISH_ERROR_DESCRIPTOR, {error})}
+ </p>
+ )}
+ </section>
+ );
+});
diff --git a/fluxer_app/src/features/app/components/setup/SetupServicesStep.tsx b/fluxer_app/src/features/app/components/setup/SetupServicesStep.tsx
new file mode 100644
index 000000000..353982b41
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupServicesStep.tsx
@@ -0,0 +1,233 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
+import type {updateInstanceConfig} from '@app/features/app/components/setup/SetupWizardClient';
+import {StepError, StepHeader} from '@app/features/app/components/setup/SetupWizardSteps';
+import {Button} from '@app/features/ui/button/Button';
+import {Input} from '@app/features/ui/components/form/FormInput';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {CheckCircleIcon} from '@phosphor-icons/react';
+import {observer} from 'mobx-react-lite';
+import {type RefObject, useState} from 'react';
+
+const SERVICES_TITLE_DESCRIPTOR = msg({
+ message: 'GIF search and YouTube previews',
+ comment: 'Setup wizard title for the GIF search and YouTube preview API keys.',
+});
+const SERVICES_BODY_DESCRIPTOR = msg({
+ message:
+ 'Each one needs an API key from its provider. Leave them empty to skip, and add them later in the admin panel.',
+ comment: 'Setup wizard body for the optional API keys.',
+});
+const KLIPY_KEY_LABEL_DESCRIPTOR = msg({
+ message: 'Klipy API key',
+ comment: 'Label for the Klipy API key field. Klipy is a product name and must not be translated.',
+});
+const KLIPY_KEY_HELP_DESCRIPTOR = msg({
+ message: 'Turns on GIF search.',
+ comment: 'Help under the Klipy API key field in the setup wizard.',
+});
+const YOUTUBE_KEY_LABEL_DESCRIPTOR = msg({
+ message: 'YouTube Data API key',
+ comment: 'Label for the YouTube Data API key field. YouTube Data API is a product name.',
+});
+const YOUTUBE_KEY_HELP_DESCRIPTOR = msg({
+ message: 'Shows the title and thumbnail when someone posts a YouTube link.',
+ comment: 'Help under the YouTube Data API key field in the setup wizard.',
+});
+const KEY_ALREADY_SET_DESCRIPTOR = msg({
+ message: 'Already set up',
+ comment: 'Shown in place of an API key field when a key is already stored.',
+});
+const KEY_REPLACE_DESCRIPTOR = msg({
+ message: 'Replace',
+ comment: 'Button that lets the person enter a new API key in place of the stored one.',
+});
+const KEY_REPLACE_LABEL_DESCRIPTOR = msg({
+ message: 'Replace the {key}',
+ comment:
+ 'Accessible label of the button that replaces a stored API key. key is the field name, such as Klipy API key.',
+});
+
+const EMPTY_SERVICE_KEYS: ServiceKeyDraft = {
+ klipyApiKey: '',
+ youtubeApiKey: '',
+ replaceKlipy: false,
+ replaceYoutube: false,
+};
+
+export interface ServiceKeyDraft {
+ klipyApiKey: string;
+ youtubeApiKey: string;
+ replaceKlipy: boolean;
+ replaceYoutube: boolean;
+}
+
+const ServiceKeyField = ({
+ label,
+ help,
+ value,
+ stored,
+ replacing,
+ disabled,
+ onChange,
+ onReplace,
+ flx,
+}: {
+ label: string;
+ help: string;
+ value: string;
+ stored: boolean;
+ replacing: boolean;
+ disabled: boolean;
+ onChange: (value: string) => void;
+ onReplace: () => void;
+ flx: string;
+}) => {
+ const {i18n} = useLingui();
+ if (stored && !replacing) {
+ return (
+ <div className={styles.storedKey} data-flx={`app.self-hosted-setup-wizard-gate.${flx}-stored`}>
+ <div className={styles.storedKeyText} data-flx={`app.self-hosted-setup-wizard-gate.${flx}-stored-text`}>
+ <span className={styles.fieldLabel} data-flx="app.setup.setup-wizard-steps.service-key-field.field-label">
+ {label}
+ </span>
+ <span className={styles.success} data-flx="app.setup.setup-wizard-steps.service-key-field.success">
+ <CheckCircleIcon
+ size={18}
+ weight="fill"
+ aria-hidden="true"
+ data-flx="app.setup.setup-wizard-steps.service-key-field.check-circle-icon"
+ />
+ {i18n._(KEY_ALREADY_SET_DESCRIPTOR)}
+ </span>
+ </div>
+ <Button
+ variant="secondary"
+ small
+ disabled={disabled}
+ onClick={onReplace}
+ aria-label={i18n._(KEY_REPLACE_LABEL_DESCRIPTOR, {key: label})}
+ data-flx={`app.self-hosted-setup-wizard-gate.${flx}-replace`}
+ >
+ {i18n._(KEY_REPLACE_DESCRIPTOR)}
+ </Button>
+ </div>
+ );
+ }
+ return (
+ <Input
+ label={label}
+ value={value}
+ autoComplete="off"
+ autoCapitalize="none"
+ autoCorrect="off"
+ spellCheck={false}
+ className={styles.monospaceInput}
+ disabled={disabled}
+ onChange={(event) => onChange(event.target.value)}
+ footer={
+ <p className={styles.fieldHelp} data-flx="app.setup.setup-wizard-steps.service-key-field.field-help">
+ {help}
+ </p>
+ }
+ data-flx={`app.self-hosted-setup-wizard-gate.${flx}-input`}
+ />
+ );
+};
+
+export const ServicesStep = observer(
+ ({
+ draftCache,
+ formRef,
+ klipyStored,
+ youtubeStored,
+ disabled,
+ error,
+ onSubmit,
+ onSave,
+ onAdvance,
+ }: {
+ draftCache: RefObject<ServiceKeyDraft | null>;
+ formRef: RefObject<HTMLFormElement | null>;
+ klipyStored: boolean;
+ youtubeStored: boolean;
+ disabled: boolean;
+ error: string | null;
+ onSubmit: (submit: () => Promise<void>) => Promise<void>;
+ onSave: (patch: Parameters<typeof updateInstanceConfig>[0]) => Promise<boolean>;
+ onAdvance: () => void;
+ }) => {
+ const {i18n} = useLingui();
+ const [draft, setDraft] = useState(() => draftCache.current ?? EMPTY_SERVICE_KEYS);
+ const updateDraft = (next: ServiceKeyDraft) => {
+ draftCache.current = next;
+ setDraft(next);
+ };
+ const onChange = (patch: Partial<ServiceKeyDraft>) => {
+ updateDraft({...(draftCache.current ?? draft), ...patch});
+ };
+ const saveServices = async () => {
+ const klipy = draft.klipyApiKey.trim();
+ const youtube = draft.youtubeApiKey.trim();
+ if (!klipy && !youtube) {
+ onAdvance();
+ return;
+ }
+ const saved = await onSave({
+ integrations: {
+ ...(klipy ? {gif: {klipy_api_key: klipy}} : {}),
+ ...(youtube ? {youtube: {api_key: youtube}} : {}),
+ },
+ });
+ if (saved) {
+ updateDraft(EMPTY_SERVICE_KEYS);
+ onAdvance();
+ }
+ };
+ return (
+ <form
+ ref={formRef}
+ noValidate
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onSubmit(saveServices);
+ }}
+ className={styles.step}
+ data-flx="app.self-hosted-setup-wizard-gate.services-step"
+ >
+ <StepHeader
+ title={i18n._(SERVICES_TITLE_DESCRIPTOR)}
+ body={i18n._(SERVICES_BODY_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.services-step.step-header"
+ />
+ <ServiceKeyField
+ label={i18n._(KLIPY_KEY_LABEL_DESCRIPTOR)}
+ help={i18n._(KLIPY_KEY_HELP_DESCRIPTOR)}
+ value={draft.klipyApiKey}
+ stored={klipyStored}
+ replacing={draft.replaceKlipy}
+ disabled={disabled}
+ onChange={(klipyApiKey) => onChange({klipyApiKey})}
+ onReplace={() => onChange({replaceKlipy: true})}
+ flx="klipy-key"
+ data-flx="app.setup.setup-wizard-steps.services-step.service-key-field.change"
+ />
+ <ServiceKeyField
+ label={i18n._(YOUTUBE_KEY_LABEL_DESCRIPTOR)}
+ help={i18n._(YOUTUBE_KEY_HELP_DESCRIPTOR)}
+ value={draft.youtubeApiKey}
+ stored={youtubeStored}
+ replacing={draft.replaceYoutube}
+ disabled={disabled}
+ onChange={(youtubeApiKey) => onChange({youtubeApiKey})}
+ onReplace={() => onChange({replaceYoutube: true})}
+ flx="youtube-key"
+ data-flx="app.setup.setup-wizard-steps.services-step.service-key-field.change--2"
+ />
+ <StepError error={error} data-flx="app.setup.setup-wizard-steps.services-step.step-error" />
+ </form>
+ );
+ },
+);
diff --git a/fluxer_app/src/features/app/components/setup/SetupTokenStep.tsx b/fluxer_app/src/features/app/components/setup/SetupTokenStep.tsx
new file mode 100644
index 000000000..dc342fa38
--- /dev/null
+++ b/fluxer_app/src/features/app/components/setup/SetupTokenStep.tsx
@@ -0,0 +1,200 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
+import {checkSetupToken} from '@app/features/app/components/setup/SetupWizardClient';
+import {StepHeader} from '@app/features/app/components/setup/SetupWizardSteps';
+import {HttpError} from '@app/features/platform/types/EndpointError';
+import {failureRetryAfterSeconds, failureValidationErrors} from '@app/features/platform/utils/ResponseInspection';
+import {Button} from '@app/features/ui/button/Button';
+import * as TextCopyCommands from '@app/features/ui/commands/TextCopyCommands';
+import {Input} from '@app/features/ui/components/form/FormInput';
+import * as FormUtils from '@app/lib/forms';
+import {HttpStatus} from '@fluxer/constants/src/HttpConstants';
+import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes';
+import {SECONDS_PER_MINUTE} from '@fluxer/date_utils/src/DateConstants';
+import {msg} from '@lingui/core/macro';
+import {useLingui} from '@lingui/react/macro';
+import {observer} from 'mobx-react-lite';
+import {createContext, type ReactNode, type RefObject, useContext, useMemo, useState} from 'react';
+
+const MAX_SETUP_TOKEN_LENGTH = 256;
+const MIN_LOCKOUT_MINUTES = 1;
+const SETUP_TOKEN_COMMAND = 'rexctl setup token';
+
+const SETUP_TOKEN_TITLE_DESCRIPTOR = msg({
+ message: 'Enter your setup token',
+ comment: 'Setup wizard title for the screen that asks for the setup token.',
+});
+const SETUP_TOKEN_BODY_DESCRIPTOR = msg({
+ message: "The setup token shows that you're the person who installed this instance.",
+ comment: 'Setup wizard body explaining what the setup token is for.',
+});
+const SETUP_TOKEN_HELP_DESCRIPTOR = msg({
+ message:
+ 'If you installed Fluxer with rexctl, it printed the token when it finished. Run this on your server to show it again.',
+ comment:
+ 'Help on the setup token screen, followed by a terminal command. rexctl is a name that must not be translated.',
+});
+const SETUP_TOKEN_LOST_DESCRIPTOR = msg({
+ message:
+ 'If you run Fluxer without rexctl, set FLUXER_SETUP_TOKEN to a value of at least 32 characters that you choose, restart Fluxer, and enter that value here.',
+ comment:
+ 'Help on the setup token screen for someone who installed Fluxer without rexctl. FLUXER_SETUP_TOKEN and rexctl must not be translated.',
+});
+const SETUP_TOKEN_LABEL_DESCRIPTOR = msg({
+ message: 'Setup token',
+ comment: 'Label for the setup token field in the setup wizard.',
+});
+const COPY_DESCRIPTOR = msg({
+ message: 'Copy',
+ comment: 'Button on the setup token screen that copies the terminal command.',
+});
+const SETUP_TOKEN_COPY_COMMAND_DESCRIPTOR = msg({
+ message: 'Copy the command',
+ comment: 'Accessible label for the button that copies the terminal command on the setup token screen.',
+});
+
+const SETUP_TOKEN_INVALID_DESCRIPTOR = msg({
+ message: "That setup token doesn't match. Check that you copied all of it.",
+ comment: 'Error under the setup token field when the token is wrong.',
+});
+const SETUP_TOKEN_LOCKED_OUT_DESCRIPTOR = msg({
+ message:
+ '{minutes, plural, one {Too many wrong setup tokens were tried from your network. Try again in # minute.} other {Too many wrong setup tokens were tried from your network. Try again in # minutes.}}',
+ comment:
+ 'Alert on the setup token screen after too many wrong setup tokens came from the same network. minutes is how long until they can try again.',
+});
+interface SetupTokenDraft {
+ value: string;
+ setValue: (value: string) => void;
+ error: string | null;
+ setError: (error: string | null) => void;
+}
+
+const SetupTokenDraftContext = createContext<SetupTokenDraft | null>(null);
+
+export function SetupTokenDraftProvider({children}: {children: ReactNode}) {
+ const [value, setValue] = useState('');
+ const [error, setError] = useState<string | null>(null);
+ const draft = useMemo(() => ({value, setValue, error, setError}), [value, error]);
+ return <SetupTokenDraftContext.Provider value={draft}>{children}</SetupTokenDraftContext.Provider>;
+}
+
+export function useSetupTokenDraft(): SetupTokenDraft {
+ const draft = useContext(SetupTokenDraftContext);
+ if (draft === null) throw new Error('Setup token draft provider is missing');
+ return draft;
+}
+
+export const setupTokenViolation = (error: unknown) =>
+ failureValidationErrors(error)?.find((violation) => violation.path === 'setup_token');
+
+export const SetupTokenStep = observer(
+ ({
+ formRef,
+ notice,
+ onSubmit,
+ onAdvance,
+ }: {
+ formRef: RefObject<HTMLFormElement | null>;
+ notice: string | null;
+ onSubmit: (submit: () => Promise<void>) => Promise<void>;
+ onAdvance: () => void;
+ }) => {
+ const {i18n} = useLingui();
+ const {
+ value: setupToken,
+ setValue: setSetupToken,
+ error: setupTokenError,
+ setError: setSetupTokenError,
+ } = useSetupTokenDraft();
+ const submitSetupToken = async () => {
+ const token = setupToken.trim();
+ try {
+ await checkSetupToken(token);
+ setSetupTokenError(null);
+ onAdvance();
+ } catch (error) {
+ const violation = setupTokenViolation(error);
+ if (violation?.code === ValidationErrorCodes.SETUP_TOKEN_INVALID) {
+ setSetupTokenError(i18n._(SETUP_TOKEN_INVALID_DESCRIPTOR));
+ return;
+ }
+ if (error instanceof HttpError && error.status === HttpStatus.TOO_MANY_REQUESTS) {
+ const minutes = Math.max(
+ MIN_LOCKOUT_MINUTES,
+ Math.ceil((failureRetryAfterSeconds(error) ?? SECONDS_PER_MINUTE) / SECONDS_PER_MINUTE),
+ );
+ setSetupTokenError(i18n._(SETUP_TOKEN_LOCKED_OUT_DESCRIPTOR, {minutes}));
+ return;
+ }
+ setSetupTokenError(violation?.message ?? FormUtils.extractErrorMessage(i18n, error));
+ }
+ };
+
+ return (
+ <form
+ ref={formRef}
+ noValidate
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onSubmit(submitSetupToken);
+ }}
+ className={styles.step}
+ data-flx="app.self-hosted-setup-wizard-gate.setup-token-step"
+ >
+ <StepHeader
+ title={i18n._(SETUP_TOKEN_TITLE_DESCRIPTOR)}
+ body={i18n._(SETUP_TOKEN_BODY_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.setup-token-step.step-header"
+ />
+ {notice && (
+ <p className={styles.alert} role="alert" data-flx="app.self-hosted-setup-wizard-gate.setup-token-notice">
+ {notice}
+ </p>
+ )}
+ <p className={styles.body} data-flx="app.self-hosted-setup-wizard-gate.setup-token-help">
+ {i18n._(SETUP_TOKEN_HELP_DESCRIPTOR)}
+ </p>
+ <div className={styles.codeRow} data-flx="app.self-hosted-setup-wizard-gate.setup-token-command">
+ <code
+ dir="ltr"
+ className={styles.codeBlock}
+ data-flx="app.self-hosted-setup-wizard-gate.setup-token-command-text"
+ >
+ {SETUP_TOKEN_COMMAND}
+ </code>
+ <Button
+ variant="secondary"
+ small
+ aria-label={i18n._(SETUP_TOKEN_COPY_COMMAND_DESCRIPTOR)}
+ onClick={() => TextCopyCommands.copy(i18n, SETUP_TOKEN_COMMAND)}
+ data-flx="app.self-hosted-setup-wizard-gate.setup-token-copy"
+ >
+ {i18n._(COPY_DESCRIPTOR)}
+ </Button>
+ </div>
+ <p className={styles.body} data-flx="app.self-hosted-setup-wizard-gate.setup-token-lost">
+ {i18n._(SETUP_TOKEN_LOST_DESCRIPTOR)}
+ </p>
+ <Input
+ label={i18n._(SETUP_TOKEN_LABEL_DESCRIPTOR)}
+ type="text"
+ value={setupToken}
+ onChange={(event) => {
+ setSetupToken(event.target.value);
+ setSetupTokenError(null);
+ }}
+ autoComplete="off"
+ autoCapitalize="none"
+ autoCorrect="off"
+ spellCheck={false}
+ maxLength={MAX_SETUP_TOKEN_LENGTH}
+ className={styles.monospaceInput}
+ error={setupTokenError ?? undefined}
+ data-flx="app.self-hosted-setup-wizard-gate.setup-token-input"
+ />
+ </form>
+ );
+ },
+);
diff --git a/fluxer_app/src/features/app/components/setup/SetupWizardSteps.tsx b/fluxer_app/src/features/app/components/setup/SetupWizardSteps.tsx
index ee1f29cb0..19a2c77c4 100644
--- a/fluxer_app/src/features/app/components/setup/SetupWizardSteps.tsx
+++ b/fluxer_app/src/features/app/components/setup/SetupWizardSteps.tsx
@@ -2,1999 +2,386 @@
import styles from '@app/features/app/components/setup/SelfHostedSetupWizardGate.module.css';
import {SetupWelcomeGate} from '@app/features/app/components/setup/SetupWelcomeGate';
-import type {SetupBrandingAssetKind} from '@app/features/app/components/setup/SetupWizardClient';
-import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
-import {AuthRegisterFormCore} from '@app/features/auth/flow/AuthRegisterFormCore';
-import {credentialRegisterFields} from '@app/features/auth/flow/RegisterFormFields';
import {Button} from '@app/features/ui/button/Button';
-import {ColorPickerField} from '@app/features/ui/components/form/ColorPickerField';
-import {Input} from '@app/features/ui/components/form/FormInput';
-import {Switch} from '@app/features/ui/components/form/FormSwitch';
-import {Spinner} from '@app/features/ui/components/Spinner';
import FocusRing from '@app/features/ui/focus_ring/FocusRing';
-import {RadioGroup, type RadioOption} from '@app/features/ui/radio_group/RadioGroup';
-import {ThemeSelector} from '@app/features/user/components/modals/tabs/appearance_tab/theme/ThemeTabContent';
import {LanguageSelector} from '@app/features/user/components/modals/tabs/LanguageTab';
import * as LocaleUtils from '@app/features/user/utils/LocaleUtils';
import {
+ type AccountIdentityLockReason,
+ AccountIdentityLockReasons,
type AccountIdentityMode,
AccountIdentityModes,
- type TagStyle,
- TagStyles,
} from '@fluxer/constants/src/AccountIdentityConstants';
-import {resolveSmtpTlsMode, type SmtpTlsMode, SmtpTlsModes} from '@fluxer/constants/src/SmtpConstants';
-import type {ThemeType} from '@fluxer/constants/src/UserConstants';
-import type {MessageDescriptor} from '@lingui/core';
import {msg} from '@lingui/core/macro';
import {useLingui} from '@lingui/react/macro';
-import {ImageIcon, TrashIcon, UploadSimpleIcon} from '@phosphor-icons/react';
-import {AnimatePresence, motion, type Transition, useReducedMotion} from 'framer-motion';
+import {CheckCircleIcon} from '@phosphor-icons/react';
import {observer} from 'mobx-react-lite';
import type React from 'react';
-import {useCallback} from 'react';
-const PUSH_RELAY_NOTICE_URL = 'https://fluxer.com/push-relay';
-const DEFAULT_THEME_COLOR = 0x4641d9;
+const SETUP_LANGUAGE_MENU_MAX_HEIGHT = 220;
export type RegistrationMode = 'open' | 'approval' | 'closed';
-export type PremiumMode = 'mirror' | 'everyone';
-
-export interface BrandingAssetState {
- kind: SetupBrandingAssetKind;
- url: string | null;
- preview: string | null;
-}
-const WELCOME_UNAUTHED_TITLE_DESCRIPTOR = msg({
- message: 'Create the administrator account',
- comment: 'Setup wizard title prompting the operator to create the first account.',
-});
-const WELCOME_UNAUTHED_BODY_DESCRIPTOR = msg({
- message: 'This instance has no accounts yet. The first account you create automatically becomes the administrator.',
- comment: 'Setup wizard body prompting the operator to register the first account.',
-});
-const WELCOME_LANGUAGE_LABEL_DESCRIPTOR = msg({
- message: 'Language',
- comment: 'Label for the setup wizard language selector.',
+const WELCOME_HEADING_DESCRIPTOR = msg({
+ message: 'Welcome',
+ comment: 'Hidden heading of the first setup wizard screen, read by screen readers while the greeting rotates.',
});
-const SETUP_TOKEN_TITLE_DESCRIPTOR = msg({
- message: 'Enter your setup token',
- comment: 'Setup wizard title for the step that asks the operator for the setup token of a new instance.',
-});
-const SETUP_TOKEN_BODY_DESCRIPTOR = msg({
- message: 'The token proves that you run this instance. Only the person who has it can create the admin account.',
- comment: 'Setup wizard body explaining why the operator has to enter the setup token.',
-});
-const SETUP_TOKEN_LABEL_DESCRIPTOR = msg({
- message: 'Setup token',
- comment: 'Label for the setup token input in the setup wizard.',
-});
-const SETUP_TOKEN_HELP_DESCRIPTOR = msg({
+const WELCOME_BODY_DESCRIPTOR = msg({
message:
- 'The API wrote the token to its log the first time it started. If you set FLUXER_SETUP_TOKEN, use that value.',
+ "This sets up your instance, the copy of Fluxer you installed, and creates your account on it. It takes about five minutes. You can change most choices later in the admin panel, and a screen tells you when you can't.",
comment:
- 'Help text under the setup token input in the setup wizard. FLUXER_SETUP_TOKEN is an environment variable name and must not be translated.',
-});
-const THEME_TITLE_DESCRIPTOR = msg({
- message: 'Choose a theme',
- comment: 'Setup wizard title for choosing the initial account theme.',
-});
-const THEME_BODY_DESCRIPTOR = msg({
- message: 'Pick the appearance this administrator account should start with.',
- comment: 'Setup wizard body for choosing the initial account theme.',
-});
-const SIGN_IN_METHOD_TITLE_DESCRIPTOR = msg({
- message: 'Choose how people sign in',
- comment: 'Setup wizard title for choosing whether accounts use usernames or email addresses to sign in.',
-});
-const SIGN_IN_METHOD_BODY_DESCRIPTOR = msg({
- message: 'You cannot change this once the first account exists.',
- comment: 'Setup wizard body for the sign-in method step.',
-});
-const SIGN_IN_METHOD_USERNAME_NAME_DESCRIPTOR = msg({
- message: 'Usernames (recommended)',
- comment: 'Setup wizard option where people sign in with a username and password and no email is collected.',
-});
-const SIGN_IN_METHOD_USERNAME_DESC_DESCRIPTOR = msg({
- message:
- 'People sign in with a username and password. No email address is collected. Each person can save a recovery kit in case they forget their password.',
- comment: 'Description for the username sign-in option in the setup wizard.',
-});
-const SIGN_IN_METHOD_EMAIL_NAME_DESCRIPTOR = msg({
- message: 'Email',
- comment: 'Setup wizard option where people sign in with an email address and password.',
-});
-const SIGN_IN_METHOD_EMAIL_DESC_DESCRIPTOR = msg({
- message:
- 'People sign in with an email address and password. Password resets and verification need email delivery, which you can set up later.',
- comment: 'Description for the email sign-in option in the setup wizard.',
-});
-const SIGN_IN_METHOD_USERNAME_SUMMARY_DESCRIPTOR = msg({
- message: 'Usernames',
- comment: 'Summary value on the setup wizard finish step when people sign in with a username.',
-});
-const TAG_STYLE_NONE_SUMMARY_DESCRIPTOR = msg({
- message: 'No tags',
- comment: 'Setup wizard finish summary value when usernames are unique and shown without a tag.',
-});
-const TAG_STYLE_RANDOM_SUMMARY_DESCRIPTOR = msg({
- message: 'Random tags',
- comment: 'Setup wizard finish summary value when every username gets a random four digit tag.',
-});
-const TAG_STYLE_TITLE_DESCRIPTOR = msg({
- message: 'Username tags',
- comment: 'Heading above the choice of how usernames are tagged in the setup wizard.',
+ 'Body of the first setup wizard screen. An instance is one installation of Fluxer run by the person reading this.',
});
-const TAG_STYLE_NONE_NAME_DESCRIPTOR = msg({
- message: 'No tags (recommended)',
- comment: 'Setup wizard option where every username is unique and shown without a tag.',
-});
-const TAG_STYLE_NONE_EMAIL_DESC_DESCRIPTOR = msg({
- message: 'Each name belongs to one person and shows on its own, like alex.',
- comment: 'Description for the no tags option when people sign in with email. Keep the example name alex.',
-});
-const TAG_STYLE_RANDOM_NAME_DESCRIPTOR = msg({
- message: 'Random tags',
- comment: 'Setup wizard option where every username gets a random four digit tag.',
+const LANGUAGE_LABEL_DESCRIPTOR = msg({
+ message: 'Language',
+ comment: 'Label for the language selector on the first setup wizard screen.',
});
-const TAG_STYLE_RANDOM_EMAIL_DESC_DESCRIPTOR = msg({
- message: 'Names get a random tag, like alex#4821, so several people can share a name.',
- comment: 'Description for the random tags option when people sign in with email. Keep alex#4821.',
+
+const SIGN_IN_LOCKED_EMAIL_TITLE_DESCRIPTOR = msg({
+ message: 'People sign in with their email address',
+ comment: 'Setup wizard title when the instance is fixed to email sign-in.',
});
-const ADMIN_RECOVERY_KIT_TITLE_DESCRIPTOR = msg({
- message: 'Save your recovery kit',
- comment: 'Setup wizard title asking the administrator to create an account recovery kit.',
+const SIGN_IN_LOCKED_USERNAME_TITLE_DESCRIPTOR = msg({
+ message: 'People sign in with a username',
+ comment: 'Setup wizard title when the instance is fixed to username sign-in.',
});
-const ADMIN_RECOVERY_KIT_BODY_DESCRIPTOR = msg({
+const LOCK_ACCOUNTS_EXIST_DESCRIPTOR = msg({
message:
- 'Your account has no email address. If you forget your password, a recovery kit is the only way back in. Create one now and keep it somewhere safe.',
- comment: 'Setup wizard body explaining why the administrator needs a recovery kit.',
-});
-const ADMIN_RECOVERY_KIT_CREATE_DESCRIPTOR = msg({
- message: 'Create recovery kit',
- comment: 'Button in the setup wizard that creates a recovery kit for the administrator account.',
-});
-const ADMIN_RECOVERY_KIT_RECREATE_DESCRIPTOR = msg({
- message: 'Create a new kit',
- comment: 'Button in the setup wizard that replaces the administrator recovery kit with a new one.',
+ "This instance already has accounts, so how people sign in can't change anymore. To use a different sign-in method, start again with an empty database.",
+ comment: 'Setup wizard explanation of why the sign-in method is fixed: accounts already exist.',
});
-const ADMIN_RECOVERY_KIT_SAVED_DESCRIPTOR = msg({
- message: 'Your recovery kit is ready. You can continue.',
- comment: 'Status shown in the setup wizard once the administrator has a recovery kit.',
+const SIGN_IN_TO_FINISH_TITLE_DESCRIPTOR = msg({
+ message: 'Sign in to finish setup',
+ comment: 'Setup wizard title shown to someone signed out after the administrator account was created.',
});
-const ADMIN_RECOVERY_KIT_MISSING_DESCRIPTOR = msg({
- message: 'Create a recovery kit to continue.',
- comment: 'Status shown in the setup wizard while the administrator has no recovery kit.',
+const SIGN_IN_TO_FINISH_BODY_DESCRIPTOR = msg({
+ message: 'This instance already has an administrator. Sign in with that account to finish setting it up.',
+ comment: 'Setup wizard body shown to someone signed out after the administrator account was created.',
});
-const CREATE_ADMIN_ACCOUNT_DESCRIPTOR = msg({
- message: 'Create administrator account',
- comment: 'Button that opens the registration flow to create the first administrator account.',
+const LOCK_SETUP_CONFIGURED_DESCRIPTOR = msg({
+ message: "Setup was marked as finished in this instance's configuration, so how people sign in can't change anymore.",
+ comment: 'Setup wizard explanation of why the sign-in method is fixed: the configuration says setup is done.',
});
-const LOADING_TITLE_DESCRIPTOR = msg({
- message: 'Preparing setup',
- comment: 'Setup wizard title while the instance configuration loads.',
+const LOCK_EXISTING_INSTANCE_DESCRIPTOR = msg({
+ message: 'This instance was upgraded from a version of Fluxer that used email sign-in, so it stays on email.',
+ comment: 'Setup wizard explanation of why the sign-in method is fixed: the instance is older than username sign-in.',
});
-const LOADING_BODY_DESCRIPTOR = msg({
- message: 'Loading the current instance configuration.',
- comment: 'Setup wizard body while the instance configuration loads.',
+const LOCK_UNKNOWN_DESCRIPTOR = msg({
+ message: "How people sign in on this instance can't change anymore.",
+ comment: 'Setup wizard explanation when the sign-in method is fixed for a reason the app does not know.',
});
-const BRANDING_TITLE_DESCRIPTOR = msg({
- message: 'Make the instance yours',
- comment: 'Setup wizard branding step title.',
-});
-const BRANDING_BODY_DESCRIPTOR = msg({
- message: 'Set the public product name, theme color, and image assets that clients display.',
- comment: 'Setup wizard branding step body.',
-});
-const PRODUCT_NAME_LABEL_DESCRIPTOR = msg({
- message: 'Product name',
- comment: 'Label for the product name input in the setup wizard.',
-});
-const PRODUCT_NAME_PLACEHOLDER_DESCRIPTOR = msg({
- message: 'Fluxer',
- comment: 'Placeholder for the product name input in the setup wizard.',
-});
-const PRODUCT_NAME_ERROR_DESCRIPTOR = msg({
- message: 'Enter a product name between 1 and 80 characters.',
- comment: 'Validation error for the product name input in the setup wizard.',
-});
-const THEME_COLOR_LABEL_DESCRIPTOR = msg({
- message: 'Theme color',
- comment: 'Label for the theme color picker in the setup wizard.',
-});
-const BRANDING_ASSETS_LABEL_DESCRIPTOR = msg({
- message: 'Image assets',
- comment: 'Label for the branding image asset uploaders in the setup wizard.',
-});
-const UPLOAD_ASSET_DESCRIPTOR = msg({
- message: 'Upload',
- comment: 'Button that opens a file picker to upload a branding image.',
-});
-const REPLACE_ASSET_DESCRIPTOR = msg({
- message: 'Replace',
- comment: 'Button that replaces an already uploaded branding image.',
-});
-const CLEAR_ASSET_DESCRIPTOR = msg({
- message: 'Clear',
- comment: 'Button that removes an uploaded branding image.',
-});
-const ASSET_ICON_DESCRIPTOR = msg({
- message: 'Icon',
- comment: 'Label for the icon branding asset.',
-});
-const ASSET_SYMBOL_DESCRIPTOR = msg({
- message: 'Symbol',
- comment: 'Label for the symbol branding asset.',
-});
-const ASSET_LOGO_DESCRIPTOR = msg({
- message: 'Logo',
- comment: 'Label for the logo branding asset.',
-});
-const ASSET_WORDMARK_DESCRIPTOR = msg({
- message: 'Wordmark',
- comment: 'Label for the wordmark branding asset.',
-});
-const ASSET_FAVICON_DESCRIPTOR = msg({
- message: 'Favicon',
- comment: 'Label for the favicon branding asset.',
-});
-const ASSET_PREVIEW_ALT_DESCRIPTOR = msg({
- message: 'Branding asset preview',
- comment: 'Accessible label for a branding image preview in the setup wizard.',
+export const REGISTRATION_CLOSED_NAME_DESCRIPTOR = msg({
+ message: 'Only people you invite',
+ comment: 'Registration mode option where only people with a registration link can sign up.',
});
-const REGISTRATION_TITLE_DESCRIPTOR = msg({
- message: 'Who can join',
- comment: 'Setup wizard registration step title.',
-});
-const REGISTRATION_BODY_DESCRIPTOR = msg({
- message: 'Choose how new accounts are created on this instance.',
- comment: 'Setup wizard registration step body.',
-});
-const REGISTRATION_OPEN_NAME_DESCRIPTOR = msg({
- message: 'Open',
- context: 'registration-policy',
- comment: 'Registration mode option allowing anyone to register.',
-});
-const REGISTRATION_OPEN_DESC_DESCRIPTOR = msg({
- message: 'Anyone can create an account.',
- comment: 'Description for the open registration mode.',
-});
-const REGISTRATION_APPROVAL_NAME_DESCRIPTOR = msg({
- message: 'Approval required',
- comment: 'Registration mode option requiring admin approval.',
-});
-const REGISTRATION_APPROVAL_DESC_DESCRIPTOR = msg({
- message: 'Anyone can request an account, but an administrator must approve it.',
- comment: 'Description for the approval registration mode.',
-});
-const REGISTRATION_CLOSED_NAME_DESCRIPTOR = msg({
- message: 'Closed',
- comment: 'Registration mode option that disables public registration.',
-});
-const REGISTRATION_CLOSED_DESC_DESCRIPTOR = msg({
- message: 'Public registration is closed.',
- comment: 'Description for the closed registration mode.',
+export const REGISTRATION_APPROVAL_NAME_DESCRIPTOR = msg({
+ message: 'Anyone, after you approve them',
+ comment: 'Registration mode option where new accounts wait for an admin to approve them.',
});
-const COMMUNITY_TITLE_DESCRIPTOR = msg({
- message: 'Choose how your instance works',
- comment: 'Setup wizard community model step title.',
-});
-const COMMUNITY_BODY_DESCRIPTOR = msg({
- message: 'These options change how people use the instance. Some can only be chosen during setup.',
- comment: 'Setup wizard community model step body.',
-});
-const SINGLE_COMMUNITY_LABEL_DESCRIPTOR = msg({
- message: 'Single community mode',
- comment: 'Label for the single community toggle in the setup wizard.',
-});
-const SINGLE_COMMUNITY_DESC_DESCRIPTOR = msg({
- message: 'Run the instance as one community instead of many. This can only be enabled now, during setup.',
- comment: 'Description for the single community toggle in the setup wizard.',
-});
-const SINGLE_COMMUNITY_NAME_LABEL_DESCRIPTOR = msg({
- message: 'Community name',
- comment: 'Label for the single community name input in the setup wizard.',
-});
-const SINGLE_COMMUNITY_NAME_PLACEHOLDER_DESCRIPTOR = msg({
- message: 'My community',
- comment: 'Placeholder for the single community name input in the setup wizard.',
-});
-const SINGLE_COMMUNITY_NAME_ERROR_DESCRIPTOR = msg({
- message: 'Enter a community name between 1 and 100 characters.',
- comment: 'Validation error for the single community name input in the setup wizard.',
-});
-const DISABLE_DM_LABEL_DESCRIPTOR = msg({
- message: 'Disable direct messages and friend requests',
- comment: 'Label for the toggle that disables direct messages and friend requests.',
-});
-const DISABLE_DM_DESC_DESCRIPTOR = msg({
- message: 'Turn off private messaging and friends across the instance. This can be reversed only once later.',
- comment: 'Description for the toggle that disables direct messages and friend requests.',
+export const REGISTRATION_OPEN_NAME_DESCRIPTOR = msg({
+ message: 'Anyone',
+ comment: 'Registration mode option where anyone can sign up.',
});
-const MEDIA_EXPIRY_TITLE_DESCRIPTOR = msg({
- message: 'Attachment expiration',
- comment: 'Setup wizard media expiry step title.',
-});
-const MEDIA_EXPIRY_BODY_DESCRIPTOR = msg({
- message: 'Choose whether uploaded attachments should expire automatically based on size.',
- comment: 'Setup wizard media expiry step body.',
-});
-const MEDIA_EXPIRY_ENABLE_LABEL_DESCRIPTOR = msg({
- message: 'Enable attachment expiration',
- comment: 'Label for enabling attachment expiry during setup.',
-});
-const MEDIA_EXPIRY_ENABLE_DESC_DESCRIPTOR = msg({
- message: 'When attachment expiration is disabled, attachments remain available until manually removed.',
- comment: 'Description for the attachment expiry setup switch.',
-});
-const MEDIA_MIN_SIZE_LABEL_DESCRIPTOR = msg({
- message: 'Small file threshold (MB)',
- comment: 'Label for attachment decay minimum size threshold.',
-});
-const MEDIA_MAX_SIZE_LABEL_DESCRIPTOR = msg({
- message: 'Large file threshold (MB)',
- comment: 'Label for attachment decay maximum size threshold.',
-});
-const MEDIA_MAX_ELIGIBLE_SIZE_LABEL_DESCRIPTOR = msg({
- message: 'Maximum eligible size (MB)',
- comment: 'Label for attachment decay maximum eligible size.',
-});
-const MEDIA_MIN_LIFETIME_LABEL_DESCRIPTOR = msg({
- message: 'Minimum lifetime (days)',
- comment: 'Label for attachment decay minimum lifetime.',
-});
-const MEDIA_MAX_LIFETIME_LABEL_DESCRIPTOR = msg({
- message: 'Maximum lifetime (days)',
- comment: 'Label for attachment decay maximum lifetime.',
-});
-const MEDIA_CURVE_LABEL_DESCRIPTOR = msg({
- message: 'Expiration curve',
- comment: 'Label for attachment decay curve.',
-});
-const MEDIA_RENEW_THRESHOLD_LABEL_DESCRIPTOR = msg({
- message: 'Renew threshold (days)',
- comment: 'Label for attachment decay renewal threshold.',
-});
-const MEDIA_RENEW_WINDOW_LABEL_DESCRIPTOR = msg({
- message: 'Renew window (days)',
- comment: 'Label for attachment decay renewal window.',
+export const PUSH_YES_NAME_DESCRIPTOR = msg({
+ message: 'Yes, use the push relay',
+ comment: 'Setup wizard option that accepts the push relay privacy notice.',
});
-const PUSH_RELAY_TITLE_DESCRIPTOR = msg({
- message: 'Mobile push notifications',
- comment: 'Setup wizard push relay consent step title.',
-});
-const PUSH_RELAY_BODY_DESCRIPTOR = msg({
- message:
- "The official Fluxer mobile apps receive notifications through Fluxer's push relay, which hands them to Apple and Google. Self-hosted UnifiedPush and ntfy endpoints never reach the relay and need no agreement.",
- comment: 'Setup wizard push relay consent step body.',
-});
-const PUSH_RELAY_ACCEPT_LABEL_DESCRIPTOR = msg({
- message: 'Accept the push relay supplemental privacy notice',
- comment: 'Label for the push relay consent switch during setup.',
-});
-const PUSH_RELAY_ACCEPT_DESC_DESCRIPTOR = msg({
- message:
- 'Leaving this off keeps the relay unused and drops notifications to the official mobile apps. You can accept it later in the admin panel.',
- comment: 'Description for the push relay consent switch during setup.',
-});
-const PUSH_RELAY_NOTICE_LINK_DESCRIPTOR = msg({
- message: 'Read the supplemental privacy notice',
- comment: 'Link to the push relay supplemental privacy notice shown during setup.',
+export const PUSH_NO_NAME_DESCRIPTOR = msg({
+ message: 'Not now',
+ comment: 'Setup wizard option that leaves the push relay off.',
});
-const SERVICES_TITLE_DESCRIPTOR = msg({
- message: 'Optional services',
- comment: 'Setup wizard optional services step title.',
-});
-const SERVICES_BODY_DESCRIPTOR = msg({
- message: 'Enable the integrations whose credentials you have configured. Only available services are shown.',
- comment: 'Setup wizard optional services step body.',
-});
-const SERVICES_NONE_DESCRIPTOR = msg({
- message: 'No optional services are available on this instance. You can skip this step.',
- comment: 'Message shown when no optional services are available in the setup wizard.',
-});
-const SERVICE_GIF_LABEL_DESCRIPTOR = msg({
- message: 'Klipy GIFs',
- comment: 'Label for the Klipy GIF service toggle in the setup wizard.',
+const DONE_TITLE_DESCRIPTOR = msg({
+ message: '{name} is ready',
+ comment: 'Title of the last setup wizard screen. name is the instance name.',
});
-const SERVICE_GIF_DESC_DESCRIPTOR = msg({
- message: 'Let people search and send GIFs powered by Klipy.',
- comment: 'Description for the Klipy GIF service toggle in the setup wizard.',
+const DONE_OPEN_DESCRIPTOR = msg({
+ message: 'People can sign up at {origin}.',
+ comment: 'Last setup wizard screen when anyone can sign up. origin is the instance address.',
});
-const SERVICE_YOUTUBE_LABEL_DESCRIPTOR = msg({
- message: 'YouTube enrichment',
- comment: 'Label for the YouTube enrichment service toggle in the setup wizard.',
+const DONE_APPROVAL_DESCRIPTOR = msg({
+ message: 'New accounts will wait for your approval in the admin panel.',
+ comment: 'Last setup wizard screen when new accounts need approval.',
});
-const SERVICE_YOUTUBE_DESC_DESCRIPTOR = msg({
- message: 'Show rich previews for YouTube links.',
- comment: 'Description for the YouTube enrichment service toggle in the setup wizard.',
+const DONE_CLOSED_DESCRIPTOR = msg({
+ message: 'To let people in, make a registration link in the admin panel.',
+ comment: 'Last setup wizard screen when only invited people can sign up.',
});
-const SERVICE_BLUESKY_LABEL_DESCRIPTOR = msg({
- message: 'Bluesky connections',
- comment: 'Label for the Bluesky connections service toggle in the setup wizard.',
-});
-const SERVICE_BLUESKY_DESC_DESCRIPTOR = msg({
- message: 'Let people link their Bluesky account to their profile.',
- comment: 'Description for the Bluesky connections service toggle in the setup wizard.',
-});
-
-const PREMIUM_TITLE_DESCRIPTOR = msg({
- message: 'Choose the premium model',
- comment: 'Setup wizard premium model step title.',
-});
-const PREMIUM_BODY_DESCRIPTOR = msg({
- message: 'Decide how premium limits apply to people on this instance.',
- comment: 'Setup wizard premium model step body.',
-});
-const PREMIUM_MIRROR_NAME_DESCRIPTOR = msg({
- message: 'Mirror tiers',
- comment: 'Premium model option that mirrors free and premium tiers.',
-});
-const PREMIUM_MIRROR_DESC_DESCRIPTOR = msg({
+const DONE_MORE_DESCRIPTOR = msg({
message:
- 'Keep free and premium tiers. You can customize the tiers, sell premium through Stripe, or hand out gift codes later from the admin panel.',
- comment: 'Description for the mirror premium model.',
-});
-const PREMIUM_EVERYONE_NAME_DESCRIPTOR = msg({
- message: 'Everyone is premium',
- comment: 'Premium model option that gives everyone the highest limits.',
-});
-const PREMIUM_EVERYONE_DESC_DESCRIPTOR = msg({
- message: 'Give everyone on this instance the highest premium limits.',
- comment: 'Description for the everyone-is-premium model.',
-});
-
-const FINISH_TITLE_DESCRIPTOR = msg({
- message: 'Finish setup',
- comment: 'Setup wizard finish step title.',
-});
-const FINISH_BODY_DESCRIPTOR = msg({
- message: 'Review your choices below, then finish. This saves the configuration and opens the instance.',
- comment: 'Setup wizard finish step body.',
+ 'In the admin panel you can also set up a captcha, Bluesky sign-in, links to your terms and privacy policy, and more.',
+ comment: 'Last setup wizard screen, listing what else the admin panel has. Bluesky is a product name.',
});
-const SUMMARY_PRODUCT_NAME_DESCRIPTOR = msg({
- message: 'Product name',
- comment: 'Summary row label for the product name in the setup wizard.',
+const DONE_OPEN_APP_DESCRIPTOR = msg({
+ message: 'Open {name}',
+ comment: 'Button on the last setup wizard screen that opens the app. name is the instance name.',
});
-const SUMMARY_REGISTRATION_DESCRIPTOR = msg({
- message: 'Registration',
- comment: 'Summary row label for the registration mode in the setup wizard.',
+const DONE_OPEN_ADMIN_DESCRIPTOR = msg({
+ message: 'Open the admin panel',
+ comment: 'Button on the last setup wizard screen that opens the admin panel in a new tab.',
});
-const SUMMARY_SINGLE_COMMUNITY_DESCRIPTOR = msg({
- message: 'Single community',
- comment: 'Summary row label for the single community choice in the setup wizard.',
-});
-const SUMMARY_DIRECT_MESSAGES_DESCRIPTOR = msg({
- message: 'Direct messages',
- comment: 'Summary row label for the direct messages choice in the setup wizard.',
-});
-const SUMMARY_ATTACHMENT_EXPIRY_DESCRIPTOR = msg({
- message: 'Attachment expiration',
- comment: 'Summary row label for the attachment expiry choice in the setup wizard.',
-});
-const SUMMARY_PUSH_RELAY_DESCRIPTOR = msg({
- message: 'Push relay notice',
- comment: 'Summary row label for the push relay consent on the setup wizard finish step.',
-});
-const SUMMARY_PREMIUM_DESCRIPTOR = msg({
- message: 'Premium model',
- comment: 'Summary row label for the premium model in the setup wizard.',
-});
-const SUMMARY_SIGN_IN_METHOD_DESCRIPTOR = msg({
- message: 'Sign-in method',
- comment: 'Summary row label for how people sign in, on the setup wizard finish step.',
-});
-const SUMMARY_ACCEPTED_DESCRIPTOR = msg({
- message: 'Accepted',
- comment: 'Summary value when the operator accepted the push relay notice.',
-});
-const SUMMARY_NOT_ACCEPTED_DESCRIPTOR = msg({
- message: 'Not accepted',
- comment: 'Summary value when the operator left the push relay notice unaccepted.',
-});
-const SUMMARY_ON_DESCRIPTOR = msg({
- message: 'Enabled',
- comment: 'Summary value when a setup option is enabled.',
-});
-const SUMMARY_OFF_DESCRIPTOR = msg({
- message: 'Disabled',
- comment: 'Summary value when a setup option is disabled.',
-});
-
-const ASSET_DESCRIPTORS: Record<SetupBrandingAssetKind, MessageDescriptor> = {
- icon: ASSET_ICON_DESCRIPTOR,
- symbol: ASSET_SYMBOL_DESCRIPTOR,
- logo: ASSET_LOGO_DESCRIPTOR,
- wordmark: ASSET_WORDMARK_DESCRIPTOR,
- favicon: ASSET_FAVICON_DESCRIPTOR,
-};
-
-const SETUP_LANGUAGE_MENU_MAX_HEIGHT = 220;
interface StepHeaderProps {
title: string;
- body: string;
+ body?: string;
}
-const StepHeader: React.FC<StepHeaderProps> = ({title, body}) => (
+export const StepHeader = ({title, body}: StepHeaderProps) => (
<div className={styles.stepHeader} data-flx="app.self-hosted-setup-wizard-gate.step-header">
- <h2 className={styles.title} data-flx="app.self-hosted-setup-wizard-gate.title">
+ <h1
+ className={styles.title}
+ tabIndex={-1}
+ data-step-focus="true"
+ data-flx="app.self-hosted-setup-wizard-gate.title"
+ >
{title}
- </h2>
- <p className={styles.body} data-flx="app.self-hosted-setup-wizard-gate.body">
- {body}
- </p>
+ </h1>
+ {body && (
+ <p className={styles.body} data-flx="app.self-hosted-setup-wizard-gate.body">
+ {body}
+ </p>
+ )}
</div>
);
-export const WelcomeStep = observer(
- ({
- productName,
- isAuthenticated,
- initialFocusRef,
- }: {
- productName: string;
- isAuthenticated: boolean;
- initialFocusRef?: React.Ref<HTMLElement>;
- }) => {
- const {i18n} = useLingui();
- const currentLocale = LocaleUtils.getCurrentOrDetectedLocale();
- return (
- <section
- ref={initialFocusRef}
- className={styles.step}
+export const Note = ({children}: {children: React.ReactNode}) => (
+ <p className={styles.note} data-flx="app.self-hosted-setup-wizard-gate.note">
+ {children}
+ </p>
+);
+
+export const WelcomeStep = observer(() => {
+ const {i18n} = useLingui();
+ const currentLocale = LocaleUtils.getCurrentOrDetectedLocale();
+ return (
+ <section className={styles.welcomeStep} data-flx="app.self-hosted-setup-wizard-gate.welcome-step">
+ <h1
+ className={styles.visuallyHidden}
tabIndex={-1}
- data-flx="app.self-hosted-setup-wizard-gate.welcome-step"
+ data-step-focus="true"
+ data-flx="app.self-hosted-setup-wizard-gate.welcome-heading"
+ >
+ {i18n._(WELCOME_HEADING_DESCRIPTOR)}
+ </h1>
+ <div
+ aria-hidden="true"
+ className={styles.welcomeHeroWrap}
+ data-flx="app.self-hosted-setup-wizard-gate.welcome-hero-wrap"
>
<SetupWelcomeGate
localeCode={currentLocale}
- productName={productName}
- isAuthenticated={isAuthenticated}
data-flx="app.setup.setup-wizard-steps.welcome-step.setup-welcome-gate"
/>
- <div className={styles.localeBlock} data-flx="app.self-hosted-setup-wizard-gate.locale-block">
- <div className={styles.fieldLabel} data-flx="app.self-hosted-setup-wizard-gate.locale-label">
- {i18n._(WELCOME_LANGUAGE_LABEL_DESCRIPTOR)}
- </div>
- <LanguageSelector
- value={currentLocale}
- onChange={LocaleUtils.setLocalLocale}
- openMenuOnFocus={false}
- maxMenuHeight={SETUP_LANGUAGE_MENU_MAX_HEIGHT}
- menuPlacement="bottom"
- className={styles.localeSelector}
- data-flx="app.setup.setup-wizard-steps.welcome-step.locale-selector.set-local-locale"
- />
- </div>
- </section>
- );
- },
-);
-
-export const SetupTokenStep = observer(
- ({value, onChange, error}: {value: string; onChange: (value: string) => void; error: string | null}) => {
- const {i18n} = useLingui();
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.setup-token-step">
- <StepHeader
- title={i18n._(SETUP_TOKEN_TITLE_DESCRIPTOR)}
- body={i18n._(SETUP_TOKEN_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.setup-token-step.step-header"
- />
- <Input
- label={i18n._(SETUP_TOKEN_LABEL_DESCRIPTOR)}
- type="text"
- value={value}
- onChange={(event) => onChange(event.target.value)}
- autoComplete="off"
- spellCheck={false}
- maxLength={256}
- error={error ?? undefined}
- footer={
- <p className={styles.body} data-flx="app.self-hosted-setup-wizard-gate.setup-token-help">
- {i18n._(SETUP_TOKEN_HELP_DESCRIPTOR)}
- </p>
- }
- data-flx="app.self-hosted-setup-wizard-gate.setup-token-input"
- />
- </section>
- );
- },
-);
-
-export const ThemeStep = observer(
- ({theme, onThemeChange}: {theme: ThemeType; onThemeChange: (theme: ThemeType) => void}) => {
- const {i18n} = useLingui();
- const themeLabel = i18n._(THEME_TITLE_DESCRIPTOR);
- return (
- <section className={styles.centeredStep} data-flx="app.self-hosted-setup-wizard-gate.theme-step">
- <StepHeader
- title={themeLabel}
- body={i18n._(THEME_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.theme-step.step-header"
- />
- <div className={styles.themeBlock} data-flx="app.self-hosted-setup-wizard-gate.theme-block">
- <ThemeSelector
- value={theme}
- onChange={onThemeChange}
- ariaLabel={themeLabel}
- className={styles.themeButtonGroup}
- data-flx="app.setup.setup-wizard-steps.theme-step.theme-button-group.theme-change"
- />
+ </div>
+ <p className={styles.welcomeBody} data-flx="app.self-hosted-setup-wizard-gate.welcome-body">
+ {i18n._(WELCOME_BODY_DESCRIPTOR)}
+ </p>
+ <div className={styles.localeBlock} data-flx="app.self-hosted-setup-wizard-gate.locale-block">
+ <div className={styles.fieldLabel} data-flx="app.self-hosted-setup-wizard-gate.locale-label">
+ {i18n._(LANGUAGE_LABEL_DESCRIPTOR)}
</div>
- </section>
- );
- },
-);
-
-export const SignInMethodStep = observer(
- ({
- mode,
- tagStyle,
- disabled,
- error,
- onChange,
- onTagStyleChange,
- }: {
- mode: AccountIdentityMode;
- tagStyle: TagStyle;
- disabled: boolean;
- error: string | null;
- onChange: (mode: AccountIdentityMode) => void;
- onTagStyleChange: (tagStyle: TagStyle) => void;
- }) => {
- const {i18n} = useLingui();
- const options: ReadonlyArray<RadioOption<AccountIdentityMode>> = [
- {
- value: AccountIdentityModes.USERNAME,
- name: i18n._(SIGN_IN_METHOD_USERNAME_NAME_DESCRIPTOR),
- desc: i18n._(SIGN_IN_METHOD_USERNAME_DESC_DESCRIPTOR),
- },
- {
- value: AccountIdentityModes.EMAIL,
- name: i18n._(SIGN_IN_METHOD_EMAIL_NAME_DESCRIPTOR),
- desc: i18n._(SIGN_IN_METHOD_EMAIL_DESC_DESCRIPTOR),
- },
- ];
- const usernameSignIn = mode === AccountIdentityModes.USERNAME;
- const tagStyleOptions: ReadonlyArray<RadioOption<TagStyle>> = [
- {
- value: TagStyles.NONE,
- name: i18n._(TAG_STYLE_NONE_NAME_DESCRIPTOR),
- desc: i18n._(TAG_STYLE_NONE_EMAIL_DESC_DESCRIPTOR),
- },
- {
- value: TagStyles.RANDOM,
- name: i18n._(TAG_STYLE_RANDOM_NAME_DESCRIPTOR),
- desc: i18n._(TAG_STYLE_RANDOM_EMAIL_DESC_DESCRIPTOR),
- },
- ];
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.sign-in-method-step">
- <StepHeader
- title={i18n._(SIGN_IN_METHOD_TITLE_DESCRIPTOR)}
- body={i18n._(SIGN_IN_METHOD_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.sign-in-method-step.step-header"
+ <LanguageSelector
+ value={currentLocale}
+ onChange={LocaleUtils.setLocalLocale}
+ openMenuOnFocus={false}
+ maxMenuHeight={SETUP_LANGUAGE_MENU_MAX_HEIGHT}
+ menuPlacement="bottom"
+ className={styles.localeSelector}
+ data-flx="app.setup.setup-wizard-steps.welcome-step.locale-selector"
/>
- <RadioGroup
- options={options}
- value={mode}
- onChange={onChange}
- disabled={disabled}
- aria-label={i18n._(SIGN_IN_METHOD_TITLE_DESCRIPTOR)}
- data-flx="app.self-hosted-setup-wizard-gate.sign-in-method-radio-group"
- />
- {!usernameSignIn && (
- <div className={styles.usernameStyle} data-flx="app.self-hosted-setup-wizard-gate.username-style">
- <h3
- className={styles.usernameStyleTitle}
- data-flx="app.setup.setup-wizard-steps.sign-in-method-step.username-style-title"
- >
- {i18n._(TAG_STYLE_TITLE_DESCRIPTOR)}
- </h3>
- <RadioGroup
- options={tagStyleOptions}
- value={tagStyle}
- onChange={onTagStyleChange}
- disabled={disabled}
- aria-label={i18n._(TAG_STYLE_TITLE_DESCRIPTOR)}
- data-flx="app.self-hosted-setup-wizard-gate.username-style-radio-group"
- />
- </div>
- )}
- {error && (
- <p
- className={styles.submitError}
- role="alert"
- data-flx="app.self-hosted-setup-wizard-gate.sign-in-method-error"
- >
- {error}
- </p>
- )}
- </section>
- );
- },
-);
-
-export const AdminIntroStep = observer(() => {
- const {i18n} = useLingui();
- return (
- <section className={styles.centeredStep} data-flx="app.self-hosted-setup-wizard-gate.admin-intro-step">
- <StepHeader
- title={i18n._(WELCOME_UNAUTHED_TITLE_DESCRIPTOR)}
- body={i18n._(WELCOME_UNAUTHED_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.admin-intro-step.step-header"
- />
+ </div>
</section>
);
});
-export const AdminAccountStep = observer(
- ({
- theme,
- usernameSignIn,
- setupToken,
- onSetupTokenRejected,
- }: {
- theme: ThemeType;
- usernameSignIn: boolean;
- setupToken: string | undefined;
- onSetupTokenRejected: (message: string) => void;
- }) => {
- const {i18n} = useLingui();
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.admin-account-step">
- <div className={styles.accountSetupForm} data-flx="app.self-hosted-setup-wizard-gate.admin-form">
- <AuthRegisterFormCore
- fields={credentialRegisterFields(usernameSignIn)}
- submitLabel={i18n._(CREATE_ADMIN_ACCOUNT_DESCRIPTOR)}
- redirectPath=""
- runtimeSnapshot={RuntimeConfig.getSnapshot()}
- offerRecoveryKit={usernameSignIn}
- theme={theme}
- showLegalConsent={false}
- setupToken={setupToken}
- onSetupTokenRejected={onSetupTokenRejected}
- data-flx="app.self-hosted-setup-wizard-gate.admin-register-form"
- />
- </div>
- </section>
- );
- },
-);
+function lockReasonDescriptor(reason: AccountIdentityLockReason | null | undefined) {
+ switch (reason) {
+ case AccountIdentityLockReasons.ACCOUNTS_EXIST:
+ return LOCK_ACCOUNTS_EXIST_DESCRIPTOR;
+ case AccountIdentityLockReasons.SETUP_CONFIGURED:
+ return LOCK_SETUP_CONFIGURED_DESCRIPTOR;
+ case AccountIdentityLockReasons.EXISTING_INSTANCE:
+ return LOCK_EXISTING_INSTANCE_DESCRIPTOR;
+ default:
+ return LOCK_UNKNOWN_DESCRIPTOR;
+ }
+}
-export const AdminRecoveryKitStep = observer(
- ({hasRecoveryKit, creating, onCreate}: {hasRecoveryKit: boolean; creating: boolean; onCreate: () => void}) => {
+export const SignInLockedStep = observer(
+ ({mode, reason}: {mode: AccountIdentityMode; reason: AccountIdentityLockReason | null | undefined}) => {
const {i18n} = useLingui();
return (
- <section className={styles.centeredStep} data-flx="app.self-hosted-setup-wizard-gate.admin-recovery-kit-step">
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.sign-in-locked-step">
<StepHeader
- title={i18n._(ADMIN_RECOVERY_KIT_TITLE_DESCRIPTOR)}
- body={i18n._(ADMIN_RECOVERY_KIT_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.admin-recovery-kit-step.step-header"
+ title={i18n._(
+ mode === AccountIdentityModes.USERNAME
+ ? SIGN_IN_LOCKED_USERNAME_TITLE_DESCRIPTOR
+ : SIGN_IN_LOCKED_EMAIL_TITLE_DESCRIPTOR,
+ )}
+ body={i18n._(lockReasonDescriptor(reason))}
+ data-flx="app.setup.setup-wizard-steps.sign-in-locked-step.step-header"
/>
- <Button
- variant={hasRecoveryKit ? 'secondary' : 'primary'}
- submitting={creating}
- onClick={onCreate}
- data-flx="app.self-hosted-setup-wizard-gate.admin-recovery-kit-step.button.create"
- >
- {hasRecoveryKit
- ? i18n._(ADMIN_RECOVERY_KIT_RECREATE_DESCRIPTOR)
- : i18n._(ADMIN_RECOVERY_KIT_CREATE_DESCRIPTOR)}
- </Button>
- <p className={styles.body} role="status" data-flx="app.self-hosted-setup-wizard-gate.admin-recovery-kit-status">
- {hasRecoveryKit ? i18n._(ADMIN_RECOVERY_KIT_SAVED_DESCRIPTOR) : i18n._(ADMIN_RECOVERY_KIT_MISSING_DESCRIPTOR)}
- </p>
</section>
);
},
);
-export const LoadingStep = observer(() => {
+export const SignInToFinishStep = observer(() => {
const {i18n} = useLingui();
return (
- <section className={styles.centeredStep} data-flx="app.self-hosted-setup-wizard-gate.loading-step">
- <Spinner size="large" data-flx="app.self-hosted-setup-wizard-gate.loading-spinner" />
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.sign-in-to-finish-step">
<StepHeader
- title={i18n._(LOADING_TITLE_DESCRIPTOR)}
- body={i18n._(LOADING_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.loading-step.step-header"
+ title={i18n._(SIGN_IN_TO_FINISH_TITLE_DESCRIPTOR)}
+ body={i18n._(SIGN_IN_TO_FINISH_BODY_DESCRIPTOR)}
+ data-flx="app.setup.setup-wizard-steps.sign-in-to-finish-step.step-header"
/>
</section>
);
});
-interface BrandingAssetRowProps {
- asset: BrandingAssetState;
- disabled: boolean;
- onUpload: (kind: SetupBrandingAssetKind) => void;
- onClear: (kind: SetupBrandingAssetKind) => void;
-}
-
-const BrandingAssetRow = observer(({asset, disabled, onUpload, onClear}: BrandingAssetRowProps) => {
- const {i18n} = useLingui();
- const previewSrc = asset.preview ?? asset.url;
- const hasImage = Boolean(previewSrc);
- return (
- <div className={styles.assetRow} data-flx="app.self-hosted-setup-wizard-gate.asset-row">
- <div className={styles.assetPreview} data-flx="app.self-hosted-setup-wizard-gate.asset-preview">
- {previewSrc ? (
- <img
- src={previewSrc}
- alt={i18n._(ASSET_PREVIEW_ALT_DESCRIPTOR)}
- className={styles.assetImage}
- data-flx="app.self-hosted-setup-wizard-gate.asset-image"
- />
- ) : (
- <ImageIcon size={22} weight="bold" data-flx="app.self-hosted-setup-wizard-gate.asset-placeholder" />
- )}
- </div>
- <div className={styles.assetLabel} data-flx="app.self-hosted-setup-wizard-gate.asset-label">
- {i18n._(ASSET_DESCRIPTORS[asset.kind])}
- </div>
- <div className={styles.assetActions} data-flx="app.self-hosted-setup-wizard-gate.asset-actions">
- <Button
- variant="secondary"
- small
- disabled={disabled}
- leftIcon={
- <UploadSimpleIcon
- size={16}
- weight="bold"
- data-flx="app.setup.setup-wizard-steps.branding-asset-row.upload-simple-icon"
- />
- }
- onClick={() => onUpload(asset.kind)}
- data-flx="app.self-hosted-setup-wizard-gate.asset-upload-button"
- >
- {hasImage ? i18n._(REPLACE_ASSET_DESCRIPTOR) : i18n._(UPLOAD_ASSET_DESCRIPTOR)}
- </Button>
- {hasImage && (
- <Button
- variant="secondary"
- small
- square
- icon={
- <TrashIcon
- size={16}
- weight="bold"
- data-flx="app.setup.setup-wizard-steps.branding-asset-row.trash-icon"
- />
- }
- aria-label={i18n._(CLEAR_ASSET_DESCRIPTOR)}
- disabled={disabled}
- onClick={() => onClear(asset.kind)}
- data-flx="app.self-hosted-setup-wizard-gate.asset-clear-button"
- />
- )}
- </div>
- </div>
- );
-});
-
-export const BrandingStep = observer(
+export const DoneStep = observer(
({
- productName,
- productNameError,
- themeColor,
- assets,
- disabled,
- onProductNameChange,
- onThemeColorChange,
- onUploadAsset,
- onClearAsset,
+ name,
+ registrationMode,
+ origin,
+ adminUrl,
+ onOpen,
}: {
- productName: string;
- productNameError: boolean;
- themeColor: number | null;
- assets: ReadonlyArray<BrandingAssetState>;
- disabled: boolean;
- onProductNameChange: (value: string) => void;
- onThemeColorChange: (value: number | null) => void;
- onUploadAsset: (kind: SetupBrandingAssetKind) => void;
- onClearAsset: (kind: SetupBrandingAssetKind) => void;
+ name: string;
+ registrationMode: RegistrationMode;
+ origin: string;
+ adminUrl: string | null;
+ onOpen: () => void;
}) => {
const {i18n} = useLingui();
+ let registrationLine: string;
+ switch (registrationMode) {
+ case 'open':
+ registrationLine = i18n._(DONE_OPEN_DESCRIPTOR, {origin});
+ break;
+ case 'approval':
+ registrationLine = i18n._(DONE_APPROVAL_DESCRIPTOR);
+ break;
+ default:
+ registrationLine = i18n._(DONE_CLOSED_DESCRIPTOR);
+ break;
+ }
return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.branding-step">
- <StepHeader
- title={i18n._(BRANDING_TITLE_DESCRIPTOR)}
- body={i18n._(BRANDING_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.branding-step.step-header"
+ <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.done-step">
+ <CheckCircleIcon
+ size={48}
+ weight="fill"
+ className={styles.doneIcon}
+ aria-hidden="true"
+ data-flx="app.setup.setup-wizard-steps.done-step.done-icon"
/>
- <Input
- label={i18n._(PRODUCT_NAME_LABEL_DESCRIPTOR)}
- value={productName}
- onChange={(event) => onProductNameChange(event.target.value)}
- placeholder={i18n._(PRODUCT_NAME_PLACEHOLDER_DESCRIPTOR)}
- maxLength={80}
- disabled={disabled}
- error={productNameError ? i18n._(PRODUCT_NAME_ERROR_DESCRIPTOR) : undefined}
- data-step-focus="true"
- data-flx="app.self-hosted-setup-wizard-gate.product-name-input"
- />
- <ColorPickerField
- label={i18n._(THEME_COLOR_LABEL_DESCRIPTOR)}
- value={themeColor ?? DEFAULT_THEME_COLOR}
- onChange={onThemeColorChange}
- defaultValue={DEFAULT_THEME_COLOR}
- isDefaultValue={themeColor === null}
- onReset={() => onThemeColorChange(null)}
- disabled={disabled}
- data-flx="app.self-hosted-setup-wizard-gate.theme-color-field"
- />
- <div className={styles.assetSection} data-flx="app.self-hosted-setup-wizard-gate.asset-section">
- <div className={styles.fieldLabel} data-flx="app.self-hosted-setup-wizard-gate.asset-section-label">
- {i18n._(BRANDING_ASSETS_LABEL_DESCRIPTOR)}
- </div>
- {assets.map((asset) => (
- <BrandingAssetRow
- key={asset.kind}
- asset={asset}
- disabled={disabled}
- onUpload={onUploadAsset}
- onClear={onClearAsset}
- data-flx="app.setup.setup-wizard-steps.branding-step.branding-asset-row"
- />
- ))}
- </div>
- </section>
- );
- },
-);
-
-export const RegistrationStep = observer(
- ({
- mode,
- disabled,
- onChange,
- }: {
- mode: RegistrationMode;
- disabled: boolean;
- onChange: (mode: RegistrationMode) => void;
- }) => {
- const {i18n} = useLingui();
- const options: ReadonlyArray<RadioOption<RegistrationMode>> = [
- {
- value: 'open',
- name: i18n._(REGISTRATION_OPEN_NAME_DESCRIPTOR),
- desc: i18n._(REGISTRATION_OPEN_DESC_DESCRIPTOR),
- },
- {
- value: 'approval',
- name: i18n._(REGISTRATION_APPROVAL_NAME_DESCRIPTOR),
- desc: i18n._(REGISTRATION_APPROVAL_DESC_DESCRIPTOR),
- },
- {
- value: 'closed',
- name: i18n._(REGISTRATION_CLOSED_NAME_DESCRIPTOR),
- desc: i18n._(REGISTRATION_CLOSED_DESC_DESCRIPTOR),
- },
- ];
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.registration-step">
<StepHeader
- title={i18n._(REGISTRATION_TITLE_DESCRIPTOR)}
- body={i18n._(REGISTRATION_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.registration-step.step-header"
- />
- <RadioGroup
- options={options}
- value={mode}
- onChange={onChange}
- disabled={disabled}
- aria-label={i18n._(REGISTRATION_TITLE_DESCRIPTOR)}
- data-flx="app.self-hosted-setup-wizard-gate.registration-radio-group"
+ title={i18n._(DONE_TITLE_DESCRIPTOR, {name})}
+ body={registrationLine}
+ data-flx="app.setup.setup-wizard-steps.done-step.step-header"
/>
- </section>
- );
- },
-);
-
-export const CommunityStep = observer(
- ({
- singleCommunityEnabled,
- singleCommunityName,
- singleCommunityNameError,
- directMessagesDisabled,
- disabled,
- onToggleSingleCommunity,
- onSingleCommunityNameChange,
- onToggleDirectMessages,
- }: {
- singleCommunityEnabled: boolean;
- singleCommunityName: string;
- singleCommunityNameError: boolean;
- directMessagesDisabled: boolean;
- disabled: boolean;
- onToggleSingleCommunity: (value: boolean) => void;
- onSingleCommunityNameChange: (value: string) => void;
- onToggleDirectMessages: (value: boolean) => void;
- }) => {
- const {i18n} = useLingui();
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.community-step">
- <StepHeader
- title={i18n._(COMMUNITY_TITLE_DESCRIPTOR)}
- body={i18n._(COMMUNITY_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.community-step.step-header"
- />
- <Switch
- label={i18n._(SINGLE_COMMUNITY_LABEL_DESCRIPTOR)}
- description={i18n._(SINGLE_COMMUNITY_DESC_DESCRIPTOR)}
- value={singleCommunityEnabled}
- onChange={onToggleSingleCommunity}
- disabled={disabled}
- data-flx="app.self-hosted-setup-wizard-gate.single-community-switch"
- />
- {singleCommunityEnabled && (
- <Input
- label={i18n._(SINGLE_COMMUNITY_NAME_LABEL_DESCRIPTOR)}
- value={singleCommunityName}
- onChange={(event) => onSingleCommunityNameChange(event.target.value)}
- placeholder={i18n._(SINGLE_COMMUNITY_NAME_PLACEHOLDER_DESCRIPTOR)}
- maxLength={100}
- disabled={disabled}
- error={singleCommunityNameError ? i18n._(SINGLE_COMMUNITY_NAME_ERROR_DESCRIPTOR) : undefined}
- data-flx="app.self-hosted-setup-wizard-gate.single-community-name-input"
- />
- )}
- <Switch
- label={i18n._(DISABLE_DM_LABEL_DESCRIPTOR)}
- description={i18n._(DISABLE_DM_DESC_DESCRIPTOR)}
- value={directMessagesDisabled}
- onChange={onToggleDirectMessages}
- disabled={disabled}
- data-flx="app.self-hosted-setup-wizard-gate.disable-dm-switch"
- />
- </section>
- );
- },
-);
-
-export interface ServiceAvailability {
- gif: boolean;
- youtube: boolean;
- bluesky: boolean;
-}
-
-export interface ServiceSelection {
- gif: boolean;
- youtube: boolean;
- bluesky: boolean;
-}
-
-export interface MediaExpiryDraft {
- enabled: boolean;
- minSizeMb: string;
- maxSizeMb: string;
- maxEligibleSizeMb: string;
- minLifetimeDays: string;
- maxLifetimeDays: string;
- curve: string;
- renewThresholdDays: string;
- renewWindowDays: string;
-}
-
-export type IntegrationStepKind = 'gif' | 'youtube' | 'email' | 'bluesky';
-export type IntegrationSetupMode = 'later' | 'configure';
-
-export interface ServiceIntegrationDraft {
- gifMode: IntegrationSetupMode;
- klipyApiKey: string;
- youtubeMode: IntegrationSetupMode;
- youtubeApiKey: string;
- emailMode: IntegrationSetupMode;
- emailEnabled: boolean;
- emailFromEmail: string;
- emailFromName: string;
- smtpHost: string;
- smtpPort: string;
- smtpUsername: string;
- smtpPassword: string;
- smtpTlsMode: SmtpTlsModeChoice;
- blueskyMode: IntegrationSetupMode;
- blueskyEnabled: boolean;
- blueskyClientName: string;
- blueskyClientUri: string;
- blueskyLogoUri: string;
- blueskyTosUri: string;
- blueskyPolicyUri: string;
- blueskyKeyId: string;
- blueskyPrivateKey: string;
-}
-
-const INTEGRATION_LATER_NAME_DESCRIPTOR = msg({
- message: 'Set up later',
- comment: 'Option for deferring an optional setup wizard integration.',
-});
-const INTEGRATION_LATER_DESC_DESCRIPTOR = msg({
- message: 'Skip this now and configure it from the admin panel.',
- comment: 'Description for deferring an optional setup wizard integration.',
-});
-const INTEGRATION_CONFIGURE_NAME_DESCRIPTOR = msg({
- message: 'Configure now',
- comment: 'Option for configuring an optional setup wizard integration.',
-});
-const INTEGRATION_CONFIGURE_DESC_DESCRIPTOR = msg({
- message: 'Add the credentials during setup.',
- comment: 'Description for configuring an optional setup wizard integration now.',
-});
-const GIF_SETUP_TITLE_DESCRIPTOR = msg({
- message: 'GIF search',
- comment: 'Setup wizard title for GIF integration credentials.',
-});
-const GIF_SETUP_BODY_DESCRIPTOR = msg({
- message: 'Add a Klipy API key to enable GIF search at runtime.',
- comment: 'Setup wizard body for GIF integration credentials.',
-});
-const YOUTUBE_SETUP_TITLE_DESCRIPTOR = msg({
- message: 'YouTube previews',
- comment: 'Setup wizard title for YouTube integration credentials.',
-});
-const YOUTUBE_SETUP_BODY_DESCRIPTOR = msg({
- message: 'Add a YouTube Data API key to enrich YouTube links.',
- comment: 'Setup wizard body for YouTube integration credentials.',
-});
-const EMAIL_SETUP_TITLE_DESCRIPTOR = msg({
- message: 'Email delivery',
- comment: 'Setup wizard title for SMTP integration credentials.',
-});
-const EMAIL_SETUP_BODY_DESCRIPTOR = msg({
- message: 'Add SMTP credentials so the instance can send verification and notification email.',
- comment: 'Setup wizard body for SMTP integration credentials.',
-});
-const BLUESKY_SETUP_TITLE_DESCRIPTOR = msg({
- message: 'Bluesky OAuth',
- comment: 'Setup wizard title for Bluesky integration credentials.',
-});
-const BLUESKY_SETUP_BODY_DESCRIPTOR = msg({
- message: 'Add Bluesky OAuth client metadata and a signing key.',
- comment: 'Setup wizard body for Bluesky integration credentials.',
-});
-const API_KEY_LABEL_DESCRIPTOR = msg({message: 'API key', comment: 'Label for an integration API key input.'});
-const ENABLE_EMAIL_LABEL_DESCRIPTOR = msg({
- message: 'Enable email delivery',
- comment: 'Label for enabling SMTP email delivery in setup.',
-});
-const EMAIL_FROM_EMAIL_LABEL_DESCRIPTOR = msg({
- message: 'From email',
- comment: 'Label for SMTP from email input.',
-});
-const EMAIL_FROM_NAME_LABEL_DESCRIPTOR = msg({
- message: 'From name',
- comment: 'Label for SMTP from name input.',
-});
-const SMTP_HOST_LABEL_DESCRIPTOR = msg({message: 'SMTP host', comment: 'Label for SMTP host input.'});
-const SMTP_PORT_LABEL_DESCRIPTOR = msg({message: 'Port', comment: 'Label for SMTP port input.'});
-const SMTP_USERNAME_LABEL_DESCRIPTOR = msg({message: 'Username', comment: 'Label for SMTP username input.'});
-const SMTP_PASSWORD_LABEL_DESCRIPTOR = msg({message: 'Password', comment: 'Label for SMTP password input.'});
-const SMTP_TLS_MODE_LABEL_DESCRIPTOR = msg({
- message: 'Encryption',
- comment: 'Label for the choice of how the SMTP connection is encrypted.',
-});
-const SMTP_TLS_MODE_AUTO_NAME_DESCRIPTOR = msg({
- message: 'Automatic',
- comment: 'SMTP encryption option that picks the mode from the port.',
-});
-const SMTP_TLS_MODE_AUTO_DESC_DESCRIPTOR = msg({
- message: 'Implicit TLS on port 465, required STARTTLS on any other port.',
- comment: 'Description of the automatic SMTP encryption option.',
-});
-const SMTP_TLS_MODE_IMPLICIT_NAME_DESCRIPTOR = msg({
- message: 'Implicit TLS',
- comment: 'SMTP encryption option where the connection starts encrypted.',
-});
-const SMTP_TLS_MODE_IMPLICIT_DESC_DESCRIPTOR = msg({
- message: 'The connection is encrypted from the start. Usually port 465.',
- comment: 'Description of the implicit TLS SMTP encryption option.',
-});
-const SMTP_TLS_MODE_STARTTLS_NAME_DESCRIPTOR = msg({
- message: 'STARTTLS',
- comment: 'SMTP encryption option where a plain connection must upgrade with STARTTLS.',
-});
-const SMTP_TLS_MODE_STARTTLS_DESC_DESCRIPTOR = msg({
- message: 'The connection must upgrade to TLS before signing in. Usually port 587.',
- comment: 'Description of the required STARTTLS SMTP encryption option.',
-});
-const SMTP_TLS_MODE_OPPORTUNISTIC_NAME_DESCRIPTOR = msg({
- message: 'STARTTLS when offered',
- comment: 'SMTP encryption option where STARTTLS is used only if the server offers it.',
-});
-const SMTP_TLS_MODE_OPPORTUNISTIC_DESC_DESCRIPTOR = msg({
- message: 'The connection upgrades to TLS only if the server offers it.',
- comment: 'Description of the opportunistic STARTTLS SMTP encryption option.',
-});
-const SMTP_TLS_MODE_NONE_NAME_DESCRIPTOR = msg({
- message: 'None',
- comment: 'SMTP encryption option that never uses TLS.',
-});
-const SMTP_TLS_MODE_NONE_DESC_DESCRIPTOR = msg({
- message: 'The connection is never encrypted. Only for a mail server on a network you trust.',
- comment: 'Description of the SMTP encryption option that never uses TLS.',
-});
-const SMTP_TEST_DESCRIPTOR = msg({
- message: 'Test SMTP',
- comment: 'Button that validates SMTP credentials.',
-});
-const SMTP_TEST_OK_DESCRIPTOR = msg({
- message: 'SMTP connection verified.',
- comment: 'Success message after validating SMTP credentials.',
-});
-const SMTP_TEST_FAILED_DESCRIPTOR = msg({
- message: 'SMTP validation failed.',
- comment: 'Failure message after validating SMTP credentials when the server returns no error detail.',
-});
-const BLUESKY_ENABLED_LABEL_DESCRIPTOR = msg({
- message: 'Enable Bluesky OAuth',
- comment: 'Label for enabling Bluesky OAuth in setup.',
-});
-const BLUESKY_CLIENT_NAME_LABEL_DESCRIPTOR = msg({
- message: 'Client name',
- comment: 'Label for Bluesky OAuth client name input.',
-});
-const BLUESKY_CLIENT_URI_LABEL_DESCRIPTOR = msg({
- message: 'Client URL',
- comment: 'Label for Bluesky OAuth client URL input.',
-});
-const BLUESKY_LOGO_URI_LABEL_DESCRIPTOR = msg({
- message: 'Logo URL',
- comment: 'Label for Bluesky OAuth logo URL input.',
-});
-const BLUESKY_TOS_URI_LABEL_DESCRIPTOR = msg({
- message: 'Terms URL',
- comment: 'Label for Bluesky OAuth terms URL input.',
-});
-const BLUESKY_POLICY_URI_LABEL_DESCRIPTOR = msg({
- message: 'Privacy URL',
- comment: 'Label for Bluesky OAuth privacy URL input.',
-});
-const BLUESKY_KEY_ID_LABEL_DESCRIPTOR = msg({
- message: 'Signing key ID',
- comment: 'Label for Bluesky OAuth signing key ID input.',
-});
-const BLUESKY_PRIVATE_KEY_LABEL_DESCRIPTOR = msg({
- message: 'Private key',
- comment: 'Label for Bluesky OAuth private key input.',
-});
-
-export type SmtpTlsModeChoice = SmtpTlsMode | 'auto';
-
-export function toSmtpTlsMode(choice: SmtpTlsModeChoice, port: number): SmtpTlsMode {
- return choice === 'auto' ? resolveSmtpTlsMode(null, port) : choice;
-}
-
-function buildSmtpTlsModeOptions(
- i18n: ReturnType<typeof useLingui>['i18n'],
-): ReadonlyArray<RadioOption<SmtpTlsModeChoice>> {
- return [
- {
- value: 'auto',
- name: i18n._(SMTP_TLS_MODE_AUTO_NAME_DESCRIPTOR),
- desc: i18n._(SMTP_TLS_MODE_AUTO_DESC_DESCRIPTOR),
- },
- {
- value: SmtpTlsModes.IMPLICIT,
- name: i18n._(SMTP_TLS_MODE_IMPLICIT_NAME_DESCRIPTOR),
- desc: i18n._(SMTP_TLS_MODE_IMPLICIT_DESC_DESCRIPTOR),
- },
- {
- value: SmtpTlsModes.STARTTLS,
- name: i18n._(SMTP_TLS_MODE_STARTTLS_NAME_DESCRIPTOR),
- desc: i18n._(SMTP_TLS_MODE_STARTTLS_DESC_DESCRIPTOR),
- },
- {
- value: SmtpTlsModes.OPPORTUNISTIC,
- name: i18n._(SMTP_TLS_MODE_OPPORTUNISTIC_NAME_DESCRIPTOR),
- desc: i18n._(SMTP_TLS_MODE_OPPORTUNISTIC_DESC_DESCRIPTOR),
- },
- {
- value: SmtpTlsModes.NONE,
- name: i18n._(SMTP_TLS_MODE_NONE_NAME_DESCRIPTOR),
- desc: i18n._(SMTP_TLS_MODE_NONE_DESC_DESCRIPTOR),
- },
- ];
-}
-
-function buildIntegrationModeOptions(
- i18n: ReturnType<typeof useLingui>['i18n'],
-): ReadonlyArray<RadioOption<IntegrationSetupMode>> {
- return [
- {
- value: 'later',
- name: i18n._(INTEGRATION_LATER_NAME_DESCRIPTOR),
- desc: i18n._(INTEGRATION_LATER_DESC_DESCRIPTOR),
- },
- {
- value: 'configure',
- name: i18n._(INTEGRATION_CONFIGURE_NAME_DESCRIPTOR),
- desc: i18n._(INTEGRATION_CONFIGURE_DESC_DESCRIPTOR),
- },
- ];
-}
-
-function getIntegrationMode(draft: ServiceIntegrationDraft, kind: IntegrationStepKind): IntegrationSetupMode {
- switch (kind) {
- case 'gif':
- return draft.gifMode;
- case 'youtube':
- return draft.youtubeMode;
- case 'email':
- return draft.emailMode;
- case 'bluesky':
- return draft.blueskyMode;
- }
-}
-
-function getIntegrationCopy(kind: IntegrationStepKind): {title: MessageDescriptor; body: MessageDescriptor} {
- switch (kind) {
- case 'gif':
- return {title: GIF_SETUP_TITLE_DESCRIPTOR, body: GIF_SETUP_BODY_DESCRIPTOR};
- case 'youtube':
- return {title: YOUTUBE_SETUP_TITLE_DESCRIPTOR, body: YOUTUBE_SETUP_BODY_DESCRIPTOR};
- case 'email':
- return {title: EMAIL_SETUP_TITLE_DESCRIPTOR, body: EMAIL_SETUP_BODY_DESCRIPTOR};
- case 'bluesky':
- return {title: BLUESKY_SETUP_TITLE_DESCRIPTOR, body: BLUESKY_SETUP_BODY_DESCRIPTOR};
- }
-}
-
-function parseSmtpPort(value: string): number | null {
- const parsed = Number.parseInt(value, 10);
- return Number.isInteger(parsed) && parsed >= 1 && parsed <= 65535 ? parsed : null;
-}
-
-const MEDIA_EXPIRY_REVEAL_TRANSITION: Transition = {
- type: 'spring',
- stiffness: 460,
- damping: 40,
- mass: 0.7,
-};
-
-export const MediaExpiryStep = observer(
- ({
- draft,
- disabled,
- onDraftChange,
- }: {
- draft: MediaExpiryDraft;
- disabled: boolean;
- onDraftChange: (patch: Partial<MediaExpiryDraft>) => void;
- }) => {
- const {i18n} = useLingui();
- const prefersReducedMotion = useReducedMotion();
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.media-expiry-step">
- <StepHeader
- title={i18n._(MEDIA_EXPIRY_TITLE_DESCRIPTOR)}
- body={i18n._(MEDIA_EXPIRY_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.step-header"
- />
- <Switch
- label={i18n._(MEDIA_EXPIRY_ENABLE_LABEL_DESCRIPTOR)}
- description={i18n._(MEDIA_EXPIRY_ENABLE_DESC_DESCRIPTOR)}
- value={draft.enabled}
- onChange={(value) => onDraftChange({enabled: value})}
- disabled={disabled}
- data-flx="app.self-hosted-setup-wizard-gate.media-expiry-switch"
- />
- <AnimatePresence initial={false} data-flx="app.setup.setup-wizard-steps.media-expiry-step.animate-presence">
- {draft.enabled && (
- <motion.div
- key="media-expiry-fields"
- className={styles.collapsibleReveal}
- initial={{height: 0, opacity: 0}}
- animate={{height: 'auto', opacity: 1}}
- exit={{height: 0, opacity: 0}}
- transition={prefersReducedMotion ? {duration: 0} : MEDIA_EXPIRY_REVEAL_TRANSITION}
- data-flx="app.self-hosted-setup-wizard-gate.media-expiry-reveal"
+ <p className={styles.body} data-flx="app.self-hosted-setup-wizard-gate.done-more">
+ {i18n._(DONE_MORE_DESCRIPTOR)}
+ </p>
+ <div className={styles.doneActions} data-flx="app.self-hosted-setup-wizard-gate.done-actions">
+ <Button onClick={onOpen} data-flx="app.self-hosted-setup-wizard-gate.done-open">
+ {i18n._(DONE_OPEN_APP_DESCRIPTOR, {name})}
+ </Button>
+ {adminUrl && (
+ <Button
+ variant="secondary"
+ onClick={() => window.open(adminUrl, '_blank', 'noopener,noreferrer')}
+ data-flx="app.self-hosted-setup-wizard-gate.done-admin"
>
- <div
- className={styles.integrationFields}
- data-flx="app.self-hosted-setup-wizard-gate.media-expiry-fields"
- >
- <div
- className={styles.integrationGrid}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.integration-grid"
- >
- <Input
- label={i18n._(MEDIA_MIN_SIZE_LABEL_DESCRIPTOR)}
- inputMode="decimal"
- value={draft.minSizeMb}
- onChange={(event) => onDraftChange({minSizeMb: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.input.draft-change"
- />
- <Input
- label={i18n._(MEDIA_MAX_SIZE_LABEL_DESCRIPTOR)}
- inputMode="decimal"
- value={draft.maxSizeMb}
- onChange={(event) => onDraftChange({maxSizeMb: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.input.draft-change--2"
- />
- </div>
- <Input
- label={i18n._(MEDIA_MAX_ELIGIBLE_SIZE_LABEL_DESCRIPTOR)}
- inputMode="decimal"
- value={draft.maxEligibleSizeMb}
- onChange={(event) => onDraftChange({maxEligibleSizeMb: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.input.draft-change--3"
- />
- <div
- className={styles.integrationGrid}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.integration-grid--2"
- >
- <Input
- label={i18n._(MEDIA_MIN_LIFETIME_LABEL_DESCRIPTOR)}
- inputMode="numeric"
- value={draft.minLifetimeDays}
- onChange={(event) => onDraftChange({minLifetimeDays: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.input.draft-change--4"
- />
- <Input
- label={i18n._(MEDIA_MAX_LIFETIME_LABEL_DESCRIPTOR)}
- inputMode="numeric"
- value={draft.maxLifetimeDays}
- onChange={(event) => onDraftChange({maxLifetimeDays: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.input.draft-change--5"
- />
- </div>
- <div
- className={styles.integrationGrid}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.integration-grid--3"
- >
- <Input
- label={i18n._(MEDIA_CURVE_LABEL_DESCRIPTOR)}
- inputMode="decimal"
- value={draft.curve}
- onChange={(event) => onDraftChange({curve: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.input.draft-change--6"
- />
- <Input
- label={i18n._(MEDIA_RENEW_THRESHOLD_LABEL_DESCRIPTOR)}
- inputMode="numeric"
- value={draft.renewThresholdDays}
- onChange={(event) => onDraftChange({renewThresholdDays: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.input.draft-change--7"
- />
- </div>
- <Input
- label={i18n._(MEDIA_RENEW_WINDOW_LABEL_DESCRIPTOR)}
- inputMode="numeric"
- value={draft.renewWindowDays}
- onChange={(event) => onDraftChange({renewWindowDays: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.media-expiry-step.input.draft-change--8"
- />
- </div>
- </motion.div>
+ {i18n._(DONE_OPEN_ADMIN_DESCRIPTOR)}
+ </Button>
)}
- </AnimatePresence>
- </section>
- );
- },
-);
-
-export const IntegrationStep = observer(
- ({
- kind,
- draft,
- disabled,
- smtpTesting,
- smtpTestResult,
- onDraftChange,
- onTestSmtp,
- }: {
- kind: IntegrationStepKind;
- draft: ServiceIntegrationDraft;
- disabled: boolean;
- smtpTesting: boolean;
- smtpTestResult: string | null;
- onDraftChange: (patch: Partial<ServiceIntegrationDraft>) => void;
- onTestSmtp: () => void;
- }) => {
- const {i18n} = useLingui();
- const copy = getIntegrationCopy(kind);
- const mode = getIntegrationMode(draft, kind);
- const setMode = useCallback(
- (next: IntegrationSetupMode) => {
- switch (kind) {
- case 'gif':
- onDraftChange({gifMode: next});
- break;
- case 'youtube':
- onDraftChange({youtubeMode: next});
- break;
- case 'email':
- onDraftChange({emailMode: next});
- break;
- case 'bluesky':
- onDraftChange({blueskyMode: next});
- break;
- }
- },
- [kind, onDraftChange],
- );
- return (
- <section className={styles.step} data-flx={`app.self-hosted-setup-wizard-gate.integration-${kind}-step`}>
- <StepHeader
- title={i18n._(copy.title)}
- body={i18n._(copy.body)}
- data-flx="app.setup.setup-wizard-steps.integration-step.step-header"
- />
- <RadioGroup
- options={buildIntegrationModeOptions(i18n)}
- value={mode}
- onChange={setMode}
- disabled={disabled}
- aria-label={i18n._(copy.title)}
- data-flx="app.setup.setup-wizard-steps.integration-step.radio-group.set-mode"
- />
- {mode === 'configure' && (
- <div className={styles.integrationFields} data-flx="app.self-hosted-setup-wizard-gate.integration-fields">
- {kind === 'gif' && (
- <Input
- label={i18n._(API_KEY_LABEL_DESCRIPTOR)}
- value={draft.klipyApiKey}
- onChange={(event) => onDraftChange({klipyApiKey: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change"
- />
- )}
- {kind === 'youtube' && (
- <Input
- label={i18n._(API_KEY_LABEL_DESCRIPTOR)}
- value={draft.youtubeApiKey}
- onChange={(event) => onDraftChange({youtubeApiKey: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--2"
- />
- )}
- {kind === 'email' && (
- <>
- <Switch
- label={i18n._(ENABLE_EMAIL_LABEL_DESCRIPTOR)}
- value={draft.emailEnabled}
- onChange={(value) => onDraftChange({emailEnabled: value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.switch.draft-change"
- />
- <Input
- label={i18n._(EMAIL_FROM_EMAIL_LABEL_DESCRIPTOR)}
- value={draft.emailFromEmail}
- onChange={(event) => onDraftChange({emailFromEmail: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--4"
- />
- <Input
- label={i18n._(EMAIL_FROM_NAME_LABEL_DESCRIPTOR)}
- value={draft.emailFromName}
- onChange={(event) => onDraftChange({emailFromName: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--5"
- />
- <div
- className={styles.integrationGrid}
- data-flx="app.setup.setup-wizard-steps.integration-step.integration-grid"
- >
- <Input
- label={i18n._(SMTP_HOST_LABEL_DESCRIPTOR)}
- value={draft.smtpHost}
- onChange={(event) => onDraftChange({smtpHost: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--6"
- />
- <Input
- label={i18n._(SMTP_PORT_LABEL_DESCRIPTOR)}
- inputMode="numeric"
- value={draft.smtpPort}
- onChange={(event) => onDraftChange({smtpPort: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--7"
- />
- </div>
- <Input
- label={i18n._(SMTP_USERNAME_LABEL_DESCRIPTOR)}
- value={draft.smtpUsername}
- onChange={(event) => onDraftChange({smtpUsername: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--8"
- />
- <Input
- label={i18n._(SMTP_PASSWORD_LABEL_DESCRIPTOR)}
- type="password"
- value={draft.smtpPassword}
- onChange={(event) => onDraftChange({smtpPassword: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change.password--2"
- />
- <div
- className={styles.fieldLabel}
- data-flx="app.setup.setup-wizard-steps.integration-step.smtp-tls-mode-label"
- >
- {i18n._(SMTP_TLS_MODE_LABEL_DESCRIPTOR)}
- </div>
- <RadioGroup
- options={buildSmtpTlsModeOptions(i18n)}
- value={draft.smtpTlsMode}
- onChange={(value) => onDraftChange({smtpTlsMode: value})}
- disabled={disabled}
- aria-label={i18n._(SMTP_TLS_MODE_LABEL_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.integration-step.radio-group.smtp-tls-mode"
- />
- <div
- className={styles.integrationActionRow}
- data-flx="app.setup.setup-wizard-steps.integration-step.integration-action-row"
- >
- <Button
- variant="secondary"
- small
- submitting={smtpTesting}
- disabled={
- disabled ||
- !draft.smtpHost.trim() ||
- !parseSmtpPort(draft.smtpPort) ||
- !draft.smtpUsername.trim() ||
- !draft.smtpPassword.trim()
- }
- onClick={onTestSmtp}
- data-flx="app.setup.setup-wizard-steps.integration-step.button.test-smtp"
- >
- {i18n._(SMTP_TEST_DESCRIPTOR)}
- </Button>
- {smtpTestResult && (
- <span
- className={styles.integrationStatus}
- role="status"
- data-flx="app.setup.setup-wizard-steps.integration-step.integration-status"
- >
- {smtpTestResult === 'ok'
- ? i18n._(SMTP_TEST_OK_DESCRIPTOR)
- : smtpTestResult === 'failed'
- ? i18n._(SMTP_TEST_FAILED_DESCRIPTOR)
- : smtpTestResult}
- </span>
- )}
- </div>
- </>
- )}
- {kind === 'bluesky' && (
- <>
- <Switch
- label={i18n._(BLUESKY_ENABLED_LABEL_DESCRIPTOR)}
- value={draft.blueskyEnabled}
- onChange={(value) => onDraftChange({blueskyEnabled: value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.switch.draft-change--3"
- />
- <Input
- label={i18n._(BLUESKY_CLIENT_NAME_LABEL_DESCRIPTOR)}
- value={draft.blueskyClientName}
- onChange={(event) => onDraftChange({blueskyClientName: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--9"
- />
- <Input
- label={i18n._(BLUESKY_CLIENT_URI_LABEL_DESCRIPTOR)}
- value={draft.blueskyClientUri}
- onChange={(event) => onDraftChange({blueskyClientUri: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--10"
- />
- <Input
- label={i18n._(BLUESKY_LOGO_URI_LABEL_DESCRIPTOR)}
- value={draft.blueskyLogoUri}
- onChange={(event) => onDraftChange({blueskyLogoUri: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--11"
- />
- <div
- className={styles.integrationGrid}
- data-flx="app.setup.setup-wizard-steps.integration-step.integration-grid--2"
- >
- <Input
- label={i18n._(BLUESKY_TOS_URI_LABEL_DESCRIPTOR)}
- value={draft.blueskyTosUri}
- onChange={(event) => onDraftChange({blueskyTosUri: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--12"
- />
- <Input
- label={i18n._(BLUESKY_POLICY_URI_LABEL_DESCRIPTOR)}
- value={draft.blueskyPolicyUri}
- onChange={(event) => onDraftChange({blueskyPolicyUri: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--13"
- />
- </div>
- <Input
- label={i18n._(BLUESKY_KEY_ID_LABEL_DESCRIPTOR)}
- value={draft.blueskyKeyId}
- onChange={(event) => onDraftChange({blueskyKeyId: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change--14"
- />
- <Input
- label={i18n._(BLUESKY_PRIVATE_KEY_LABEL_DESCRIPTOR)}
- type="password"
- value={draft.blueskyPrivateKey}
- onChange={(event) => onDraftChange({blueskyPrivateKey: event.target.value})}
- disabled={disabled}
- data-flx="app.setup.setup-wizard-steps.integration-step.input.draft-change.password--3"
- />
- </>
- )}
- </div>
- )}
- </section>
- );
- },
-);
-
-export const PushRelayConsentStep = observer(
- ({accepted, disabled, onChange}: {accepted: boolean; disabled: boolean; onChange: (value: boolean) => void}) => {
- const {i18n} = useLingui();
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.push-relay-consent-step">
- <StepHeader
- title={i18n._(PUSH_RELAY_TITLE_DESCRIPTOR)}
- body={i18n._(PUSH_RELAY_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.push-relay-consent-step.step-header"
- />
- <Switch
- label={i18n._(PUSH_RELAY_ACCEPT_LABEL_DESCRIPTOR)}
- description={i18n._(PUSH_RELAY_ACCEPT_DESC_DESCRIPTOR)}
- value={accepted}
- onChange={onChange}
- disabled={disabled}
- data-flx="app.self-hosted-setup-wizard-gate.push-relay-consent-switch"
- />
- <FocusRing data-flx="app.setup.setup-wizard-steps.push-relay-consent-step.focus-ring">
- <a
- className={styles.noticeLink}
- href={PUSH_RELAY_NOTICE_URL}
- target="_blank"
- rel="noreferrer"
- data-flx="app.self-hosted-setup-wizard-gate.push-relay-notice-link"
- >
- {i18n._(PUSH_RELAY_NOTICE_LINK_DESCRIPTOR)}
- </a>
- </FocusRing>
- </section>
- );
- },
-);
-
-export const ServicesStep = observer(
- ({
- available,
- selection,
- disabled,
- onToggle,
- }: {
- available: ServiceAvailability;
- selection: ServiceSelection;
- disabled: boolean;
- onToggle: (service: keyof ServiceSelection, value: boolean) => void;
- }) => {
- const {i18n} = useLingui();
- const anyAvailable = available.gif || available.youtube || available.bluesky;
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.services-step">
- <StepHeader
- title={i18n._(SERVICES_TITLE_DESCRIPTOR)}
- body={i18n._(SERVICES_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.services-step.step-header"
- />
- {!anyAvailable && (
- <p className={styles.emptyNote} data-flx="app.self-hosted-setup-wizard-gate.services-empty">
- {i18n._(SERVICES_NONE_DESCRIPTOR)}
- </p>
- )}
- {available.gif && (
- <Switch
- label={i18n._(SERVICE_GIF_LABEL_DESCRIPTOR)}
- description={i18n._(SERVICE_GIF_DESC_DESCRIPTOR)}
- value={selection.gif}
- onChange={(value) => onToggle('gif', value)}
- disabled={disabled}
- data-flx="app.self-hosted-setup-wizard-gate.service-gif-switch"
- />
- )}
- {available.youtube && (
- <Switch
- label={i18n._(SERVICE_YOUTUBE_LABEL_DESCRIPTOR)}
- description={i18n._(SERVICE_YOUTUBE_DESC_DESCRIPTOR)}
- value={selection.youtube}
- onChange={(value) => onToggle('youtube', value)}
- disabled={disabled}
- data-flx="app.self-hosted-setup-wizard-gate.service-youtube-switch"
- />
- )}
- {available.bluesky && (
- <Switch
- label={i18n._(SERVICE_BLUESKY_LABEL_DESCRIPTOR)}
- description={i18n._(SERVICE_BLUESKY_DESC_DESCRIPTOR)}
- value={selection.bluesky}
- onChange={(value) => onToggle('bluesky', value)}
- disabled={disabled}
- data-flx="app.self-hosted-setup-wizard-gate.service-bluesky-switch"
- />
- )}
- </section>
- );
- },
-);
-
-export const PremiumStep = observer(
- ({mode, disabled, onChange}: {mode: PremiumMode; disabled: boolean; onChange: (mode: PremiumMode) => void}) => {
- const {i18n} = useLingui();
- const options: ReadonlyArray<RadioOption<PremiumMode>> = [
- {
- value: 'mirror',
- name: i18n._(PREMIUM_MIRROR_NAME_DESCRIPTOR),
- desc: i18n._(PREMIUM_MIRROR_DESC_DESCRIPTOR),
- },
- {
- value: 'everyone',
- name: i18n._(PREMIUM_EVERYONE_NAME_DESCRIPTOR),
- desc: i18n._(PREMIUM_EVERYONE_DESC_DESCRIPTOR),
- },
- ];
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.premium-step">
- <StepHeader
- title={i18n._(PREMIUM_TITLE_DESCRIPTOR)}
- body={i18n._(PREMIUM_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.premium-step.step-header"
- />
- <RadioGroup
- options={options}
- value={mode}
- onChange={onChange}
- disabled={disabled}
- aria-label={i18n._(PREMIUM_TITLE_DESCRIPTOR)}
- data-flx="app.self-hosted-setup-wizard-gate.premium-radio-group"
- />
+ </div>
</section>
);
},
);
-interface SummaryRowProps {
- label: string;
- value: string;
-}
-
-const SummaryRow: React.FC<SummaryRowProps> = ({label, value}) => (
- <div className={styles.summaryRow} data-flx="app.self-hosted-setup-wizard-gate.summary-row">
- <span className={styles.summaryLabel} data-flx="app.self-hosted-setup-wizard-gate.summary-label">
- {label}
- </span>
- <span className={styles.summaryValue} data-flx="app.self-hosted-setup-wizard-gate.summary-value">
- {value}
- </span>
- </div>
+export const TextButton = ({
+ children,
+ onClick,
+ disabled,
+ ariaLabel,
+}: {
+ children: React.ReactNode;
+ onClick: () => void;
+ disabled?: boolean;
+ ariaLabel?: string;
+}) => (
+ <FocusRing offset={-2} data-flx="app.self-hosted-setup-wizard-gate.text-button-focus-ring">
+ <button
+ type="button"
+ className={styles.textButton}
+ disabled={disabled}
+ aria-label={ariaLabel}
+ onClick={onClick}
+ data-flx="app.self-hosted-setup-wizard-gate.text-button"
+ >
+ {children}
+ </button>
+ </FocusRing>
);
-export const FinishStep = observer(
- ({
- productName,
- accountIdentity,
- tagStyle,
- registrationMode,
- singleCommunityEnabled,
- directMessagesDisabled,
- attachmentExpiryEnabled,
- pushRelayConsentAccepted,
- premiumMode,
- submitError,
- }: {
- productName: string;
- accountIdentity: AccountIdentityMode;
- tagStyle: TagStyle;
- registrationMode: RegistrationMode;
- singleCommunityEnabled: boolean;
- directMessagesDisabled: boolean;
- attachmentExpiryEnabled: boolean;
- pushRelayConsentAccepted: boolean;
- premiumMode: PremiumMode;
- submitError: string | null;
- }) => {
- const {i18n} = useLingui();
- const registrationLabel =
- registrationMode === 'open'
- ? i18n._(REGISTRATION_OPEN_NAME_DESCRIPTOR)
- : registrationMode === 'approval'
- ? i18n._(REGISTRATION_APPROVAL_NAME_DESCRIPTOR)
- : i18n._(REGISTRATION_CLOSED_NAME_DESCRIPTOR);
- const premiumLabel =
- premiumMode === 'mirror' ? i18n._(PREMIUM_MIRROR_NAME_DESCRIPTOR) : i18n._(PREMIUM_EVERYONE_NAME_DESCRIPTOR);
- const onLabel = i18n._(SUMMARY_ON_DESCRIPTOR);
- const offLabel = i18n._(SUMMARY_OFF_DESCRIPTOR);
- return (
- <section className={styles.step} data-flx="app.self-hosted-setup-wizard-gate.finish-step">
- <StepHeader
- title={i18n._(FINISH_TITLE_DESCRIPTOR)}
- body={i18n._(FINISH_BODY_DESCRIPTOR)}
- data-flx="app.setup.setup-wizard-steps.finish-step.step-header"
- />
- <div className={styles.summary} data-flx="app.self-hosted-setup-wizard-gate.summary">
- <SummaryRow
- label={i18n._(SUMMARY_PRODUCT_NAME_DESCRIPTOR)}
- value={productName}
- data-flx="app.setup.setup-wizard-steps.finish-step.summary-row"
- />
- <SummaryRow
- label={i18n._(SUMMARY_SIGN_IN_METHOD_DESCRIPTOR)}
- value={
- accountIdentity === AccountIdentityModes.USERNAME
- ? i18n._(SIGN_IN_METHOD_USERNAME_SUMMARY_DESCRIPTOR)
- : i18n._(SIGN_IN_METHOD_EMAIL_NAME_DESCRIPTOR)
- }
- data-flx="app.setup.setup-wizard-steps.finish-step.summary-row.sign-in-method"
- />
- {accountIdentity === AccountIdentityModes.EMAIL && (
- <SummaryRow
- label={i18n._(TAG_STYLE_TITLE_DESCRIPTOR)}
- value={i18n._(
- tagStyle === TagStyles.NONE ? TAG_STYLE_NONE_SUMMARY_DESCRIPTOR : TAG_STYLE_RANDOM_SUMMARY_DESCRIPTOR,
- )}
- data-flx="app.setup.setup-wizard-steps.finish-step.summary-row.username-style"
- />
- )}
- <SummaryRow
- label={i18n._(SUMMARY_REGISTRATION_DESCRIPTOR)}
- value={registrationLabel}
- data-flx="app.setup.setup-wizard-steps.finish-step.summary-row--2"
- />
- <SummaryRow
- label={i18n._(SUMMARY_SINGLE_COMMUNITY_DESCRIPTOR)}
- value={singleCommunityEnabled ? onLabel : offLabel}
- data-flx="app.setup.setup-wizard-steps.finish-step.summary-row--3"
- />
- <SummaryRow
- label={i18n._(SUMMARY_DIRECT_MESSAGES_DESCRIPTOR)}
- value={directMessagesDisabled ? offLabel : onLabel}
- data-flx="app.setup.setup-wizard-steps.finish-step.summary-row--4"
- />
- <SummaryRow
- label={i18n._(SUMMARY_ATTACHMENT_EXPIRY_DESCRIPTOR)}
- value={attachmentExpiryEnabled ? onLabel : offLabel}
- data-flx="app.setup.setup-wizard-steps.finish-step.summary-row--5"
- />
- <SummaryRow
- label={i18n._(SUMMARY_PUSH_RELAY_DESCRIPTOR)}
- value={
- pushRelayConsentAccepted ? i18n._(SUMMARY_ACCEPTED_DESCRIPTOR) : i18n._(SUMMARY_NOT_ACCEPTED_DESCRIPTOR)
- }
- data-flx="app.setup.setup-wizard-steps.finish-step.summary-row--6"
- />
- <SummaryRow
- label={i18n._(SUMMARY_PREMIUM_DESCRIPTOR)}
- value={premiumLabel}
- data-flx="app.setup.setup-wizard-steps.finish-step.summary-row--7"
- />
- </div>
- {submitError && (
- <p className={styles.submitError} role="alert" data-flx="app.self-hosted-setup-wizard-gate.submit-error">
- {submitError}
- </p>
- )}
- </section>
- );
- },
-);
+export const StepError = ({error}: {error: string | null}) =>
+ error ? (
+ <p className={styles.alert} role="alert" data-flx="app.self-hosted-setup-wizard-gate.step-error">
+ {error}
+ </p>
+ ) : null;
+
+export const SUMMARY_DESCRIPTORS = {
+ signIn: msg({message: 'Sign-in', comment: 'Review row label for how people sign in.'}),
+ account: msg({message: 'Your account', comment: 'Review row label for the administrator account.'}),
+ email: msg({message: 'Email', comment: 'Review row label for the email service.'}),
+ name: msg({message: 'Name', comment: 'Review row label for the instance name.'}),
+ look: msg({message: 'Look', comment: 'Review row label for the theme color and images.'}),
+ communities: msg({message: 'Communities', comment: 'Review row label for one community or many.'}),
+ directMessages: msg({message: 'Direct messages', comment: 'Review row label for direct messages.'}),
+ registration: msg({message: 'Who can create an account', comment: 'Review row label for the registration mode.'}),
+ push: msg({message: 'Phone notifications', comment: 'Review row label for the push relay.'}),
+ gif: msg({message: 'GIF search', comment: 'Review row label for GIF search.'}),
+ youtube: msg({message: 'YouTube previews', comment: 'Review row label for YouTube link previews.'}),
+ attachments: msg({message: 'Old attachments', comment: 'Review row label for automatic attachment expiry.'}),
+ usernames: msg({message: 'Usernames', comment: 'Review value when people sign in with a username.'}),
+ emailAddressesUnique: msg({
+ message: 'Email addresses, every username is unique',
+ comment: 'Review value for email sign-in where each username belongs to one person.',
+ }),
+ emailAddressesShared: msg({
+ message: 'Email addresses, usernames get a number',
+ comment: 'Review value for email sign-in where usernames get a random number.',
+ }),
+ emailLater: msg({message: 'Set up later', comment: 'Review value when the email service will be added later.'}),
+ emailAlreadySet: msg({message: 'Already set up', comment: 'Review value when an email service was already set up.'}),
+ emailFrom: msg({
+ message: '{host}, sending as {from}',
+ comment: 'Review value for the email service. host is the SMTP server and from is the sender address.',
+ }),
+ singleCommunity: msg({
+ message: 'One community, {name}',
+ comment: 'Review value for single community mode. name is the community name.',
+ }),
+ manyCommunities: msg({message: 'Many communities', comment: 'Review value when people can create communities.'}),
+ allowed: msg({message: 'Allowed', comment: 'Review value when a feature is allowed.'}),
+ off: msg({message: 'Off', comment: 'Review value when a feature is turned off.'}),
+ on: msg({message: 'On', comment: 'Review value when a feature is turned on.'}),
+ skipped: msg({message: 'Not set up', comment: 'Review value when an optional API key was left empty.'}),
+ deleteOld: msg({message: 'Delete old attachments', comment: 'Review value when old attachments are deleted.'}),
+ keepAll: msg({message: 'Keep everything', comment: 'Review value when attachments are kept.'}),
+ defaultColor: msg({message: 'Default color', comment: 'Review value when the theme color is the default.'}),
+ registrationClosed: REGISTRATION_CLOSED_NAME_DESCRIPTOR,
+ registrationApproval: REGISTRATION_APPROVAL_NAME_DESCRIPTOR,
+ registrationOpen: REGISTRATION_OPEN_NAME_DESCRIPTOR,
+ pushOn: PUSH_YES_NAME_DESCRIPTOR,
+ pushOff: PUSH_NO_NAME_DESCRIPTOR,
+};