@micha.bigler/ui-core-micha 4.19.0 → 4.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +4 -1
- package/dist/components/SignUpContent.js +11 -3
- package/dist/i18n/authTranslations.js +6 -0
- package/dist/pages/SignUpPage.js +5 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.20.0 - UCM-AUTH-15
|
|
4
|
+
|
|
5
|
+
`SignUpContent` and `SignUpPage` accept an optional `preferredSignupMode`: when the server offers that mode it is shown
|
|
6
|
+
first and preselected, otherwise it is ignored and the server order applies (a QR link still selects the QR mode).
|
|
7
|
+
Visible change in every app: the submit button of open self-signup (`self_signup_open`) now reads "Konto anlegen" /
|
|
8
|
+
"Create account" (new key `Auth.SIGNUP_SUBMIT_OPEN`); access-code, e-mail-domain and QR signup keep "Einladung
|
|
9
|
+
anfordern" / "Request invitation".
|
|
10
|
+
|
|
3
11
|
## 4.19.0 - UCM-CHAT-8
|
|
4
12
|
|
|
5
13
|
`ChatWorkspace` starts the status, catalogue and both chat-list requests together on mount and on every scope change,
|
package/README.md
CHANGED
|
@@ -54,7 +54,10 @@ project, import or payment work. Existing pages and the dialog `OnboardingProvid
|
|
|
54
54
|
ignored until it settles. `primaryForm` names a form in the content that the primary button submits natively.
|
|
55
55
|
- `SignUpContent` — the sign-up form of `SignUpPage` (all modes, Turnstile, QR token via `registrationContextToken`).
|
|
56
56
|
`onSubmitted(email)` switches it to the confirmation instruction; remount it (new `key`) to let the person change the
|
|
57
|
-
email. `showProviders` adds Google/Microsoft above the form.
|
|
57
|
+
email. `showProviders` adds Google/Microsoft above the form. `preferredSignupMode` (also on `SignUpPage`, e.g.
|
|
58
|
+
`'self_signup_open'`) shows that mode first and selected when the server offers it; otherwise it is ignored and the
|
|
59
|
+
server order applies. Open self-signup submits with "Konto anlegen" (`Auth.SIGNUP_SUBMIT_OPEN`); the other modes
|
|
60
|
+
keep "Einladung anfordern".
|
|
58
61
|
- `SignupConfirmContent` — the password form of `SignupConfirmPage`. Pass `token` (from the emailed
|
|
59
62
|
`/signup/confirm/?token=…` link, which your app routes) and `onSuccess()`; there is no automatic sign-in, show
|
|
60
63
|
`LoginContent` next.
|
|
@@ -32,6 +32,12 @@ export function resolveSignupModes(authMethods) {
|
|
|
32
32
|
}
|
|
33
33
|
return (authMethods === null || authMethods === void 0 ? void 0 : authMethods.signup) ? ['self_signup_access_code'] : [];
|
|
34
34
|
}
|
|
35
|
+
// An app's preferred mode moves to the front only when the server offers it; the server decides which modes exist.
|
|
36
|
+
export function orderSignupModes(modes, preferredMode) {
|
|
37
|
+
return preferredMode && modes.includes(preferredMode)
|
|
38
|
+
? [preferredMode, ...modes.filter((entry) => entry !== preferredMode)]
|
|
39
|
+
: modes;
|
|
40
|
+
}
|
|
35
41
|
/**
|
|
36
42
|
* The sign-up form shared by SignUpPage and embedded flows: every configured
|
|
37
43
|
* sign-up mode, Turnstile, the QR registration context and the existing
|
|
@@ -39,6 +45,7 @@ export function resolveSignupModes(authMethods) {
|
|
|
39
45
|
*
|
|
40
46
|
* Props:
|
|
41
47
|
* - `registrationContextToken`: the QR token (SignUpPage passes `?rt`).
|
|
48
|
+
* - `preferredSignupMode`: optional available mode to show and select first.
|
|
42
49
|
* - `onModeChange(mode)`: reports the selected sign-up mode.
|
|
43
50
|
* - `onSubmitted(email)`: embedded use. Called after the request succeeded with
|
|
44
51
|
* the email only; the component then shows the confirmation instruction instead
|
|
@@ -49,10 +56,11 @@ export function resolveSignupModes(authMethods) {
|
|
|
49
56
|
* the provider callback URL.
|
|
50
57
|
* The access code, QR token and Turnstile token never leave this component.
|
|
51
58
|
*/
|
|
52
|
-
export function SignUpContent({ registrationContextToken = '', onModeChange, onSubmitted, showProviders = false, continuation, }) {
|
|
59
|
+
export function SignUpContent({ registrationContextToken = '', preferredSignupMode, onModeChange, onSubmitted, showProviders = false, continuation, }) {
|
|
53
60
|
const { t, i18n } = useTranslation();
|
|
54
61
|
const { authMethods } = useContext(AuthContext) || {};
|
|
55
|
-
const
|
|
62
|
+
const serverSignupModes = useMemo(() => resolveSignupModes(authMethods), [authMethods]);
|
|
63
|
+
const signupModes = useMemo(() => orderSignupModes(serverSignupModes, preferredSignupMode), [preferredSignupMode, serverSignupModes]);
|
|
56
64
|
const initialMode = useMemo(() => {
|
|
57
65
|
if (registrationContextToken && signupModes.includes('self_signup_qr')) {
|
|
58
66
|
return 'self_signup_qr';
|
|
@@ -151,5 +159,5 @@ export function SignUpContent({ registrationContextToken = '', onModeChange, onS
|
|
|
151
159
|
}
|
|
152
160
|
return (_jsxs(_Fragment, { children: [successKey && (_jsx(Alert, { severity: "success", sx: SIGN_UP_PAGE_ALERT_SX, children: t(successKey, { email }) })), errorKey && (_jsx(Alert, { severity: "error", sx: SIGN_UP_PAGE_ALERT_SX, children: errorKey })), providersVisible && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsx(SocialLoginButtons, { onProviderClick: handleProviderLogin, providers: socialProviders }), providerTransition && (_jsx(Alert, { severity: "info", sx: SIGN_UP_PROVIDER_ALERT_SX, children: t('Auth.PROVIDER_TRANSITION', { provider: PROVIDER_NAMES[providerTransition] || providerTransition }) })), _jsx(Divider, { sx: SIGN_UP_PROVIDER_DIVIDER_SX, children: t('Auth.LOGIN_OR') })] })), signupModes.length > 1 && (_jsx(Stack, { spacing: 1, sx: { mb: 2 }, children: signupModes.map((entry) => (_jsx(Button, { variant: mode === entry ? 'contained' : 'outlined', onClick: () => setMode(entry), disabled: submitting, fullWidth: true, children: t(MODE_LABELS[entry] || entry, entry) }, entry))) })), _jsxs(Box, { component: "form", onSubmit: handleSubmit, sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsx(TextField, { label: t('Auth.EMAIL_LABEL'), type: "email", required: true, fullWidth: true, value: email, onChange: (e) => setEmail(e.target.value), disabled: submitting }), mode === 'self_signup_access_code' && (_jsx(TextField, { label: t('Auth.ACCESS_CODE_LABEL'), type: "text", required: true, fullWidth: true, value: accessCode, onChange: (e) => setAccessCode(e.target.value), disabled: submitting })), turnstileRequired && (_jsx(TurnstileWidget, { ref: turnstileWidgetRef, siteKey: authMethods.turnstile_site_key, onToken: setTurnstileToken })), _jsx(Button, { type: "submit", variant: "contained", disabled: submitting || Boolean(providerTransition) || (turnstileRequired && !turnstileToken), children: submitting
|
|
153
161
|
? t('Auth.SIGNUP_SUBMITTING')
|
|
154
|
-
: t('Auth.SIGNUP_SUBMIT') })] })] }));
|
|
162
|
+
: t(mode === 'self_signup_open' ? 'Auth.SIGNUP_SUBMIT_OPEN' : 'Auth.SIGNUP_SUBMIT') })] })] }));
|
|
155
163
|
}
|
|
@@ -444,6 +444,12 @@ export const authTranslations = {
|
|
|
444
444
|
"en": "Request invitation",
|
|
445
445
|
"sw": "Omba mwaliko"
|
|
446
446
|
},
|
|
447
|
+
"Auth.SIGNUP_SUBMIT_OPEN": {
|
|
448
|
+
"de": "Konto anlegen",
|
|
449
|
+
"fr": "Créer un compte",
|
|
450
|
+
"en": "Create account",
|
|
451
|
+
"sw": "Fungua akaunti"
|
|
452
|
+
},
|
|
447
453
|
"Auth.SIGNUP_SUBMITTING": {
|
|
448
454
|
"de": "Sende…",
|
|
449
455
|
"fr": "Envoi…",
|
package/dist/pages/SignUpPage.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Box, Button, Typography } from '@mui/material';
|
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { NarrowPage } from '../layout/PageLayout';
|
|
7
7
|
import { AuthContext } from '../auth/AuthContext';
|
|
8
|
-
import { SIGN_UP_PAGE_ALERT_SX, SignUpContent, resolveSignupModes, } from '../components/SignUpContent';
|
|
8
|
+
import { SIGN_UP_PAGE_ALERT_SX, SignUpContent, orderSignupModes, resolveSignupModes, } from '../components/SignUpContent';
|
|
9
9
|
export { SIGN_UP_PAGE_ALERT_SX };
|
|
10
10
|
const MODE_SUBTITLES = {
|
|
11
11
|
self_signup_access_code: 'Auth.PAGE_SIGNUP_SUBTITLE_ACCESS_CODE',
|
|
@@ -15,12 +15,13 @@ const MODE_SUBTITLES = {
|
|
|
15
15
|
};
|
|
16
16
|
// The form and its sign-up logic live in SignUpContent (UCM-AUTH-14); the page
|
|
17
17
|
// keeps the route framing, the `?rt` QR token source and the login link.
|
|
18
|
-
export function SignUpPage() {
|
|
18
|
+
export function SignUpPage({ preferredSignupMode }) {
|
|
19
19
|
const navigate = useNavigate();
|
|
20
20
|
const location = useLocation();
|
|
21
21
|
const { t } = useTranslation();
|
|
22
22
|
const { authMethods } = useContext(AuthContext);
|
|
23
|
-
const
|
|
23
|
+
const serverSignupModes = useMemo(() => resolveSignupModes(authMethods), [authMethods]);
|
|
24
|
+
const signupModes = useMemo(() => orderSignupModes(serverSignupModes, preferredSignupMode), [preferredSignupMode, serverSignupModes]);
|
|
24
25
|
const query = new URLSearchParams(location.search);
|
|
25
26
|
const tokenFromUrl = query.get('rt') || '';
|
|
26
27
|
const [mode, setMode] = useState(() => (tokenFromUrl && signupModes.includes('self_signup_qr')
|
|
@@ -35,5 +36,5 @@ export function SignUpPage() {
|
|
|
35
36
|
const handleGoToLogin = () => {
|
|
36
37
|
navigate('/login');
|
|
37
38
|
};
|
|
38
|
-
return (_jsxs(NarrowPage, { title: t('Auth.LOGIN_SIGNUP_BUTTON'), subtitle: pageSubtitle, children: [_jsx("title", { children: `${t('App.NAME')} – ${t('Auth.LOGIN_SIGNUP_BUTTON')}` }), _jsx(SignUpContent, { registrationContextToken: tokenFromUrl, onModeChange: setMode }), _jsx(Box, { sx: { mt: 3 }, children: _jsxs(Typography, { variant: "body2", children: [t('Auth.SIGNUP_ALREADY_HAVE_ACCOUNT'), ' ', _jsx(Button, { onClick: handleGoToLogin, variant: "text", size: "small", children: t('Auth.SIGNUP_GO_TO_LOGIN') })] }) })] }));
|
|
39
|
+
return (_jsxs(NarrowPage, { title: t('Auth.LOGIN_SIGNUP_BUTTON'), subtitle: pageSubtitle, children: [_jsx("title", { children: `${t('App.NAME')} – ${t('Auth.LOGIN_SIGNUP_BUTTON')}` }), _jsx(SignUpContent, { registrationContextToken: tokenFromUrl, preferredSignupMode: preferredSignupMode, onModeChange: setMode }), _jsx(Box, { sx: { mt: 3 }, children: _jsxs(Typography, { variant: "body2", children: [t('Auth.SIGNUP_ALREADY_HAVE_ACCOUNT'), ' ', _jsx(Button, { onClick: handleGoToLogin, variant: "text", size: "small", children: t('Auth.SIGNUP_GO_TO_LOGIN') })] }) })] }));
|
|
39
40
|
}
|