@scalio-cloud/ui 0.42.0 → 0.43.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/README.md +8 -0
- package/auth.css +6 -0
- package/package.json +1 -1
- package/react/index.js +1 -1
- package/react/labels.js +42 -0
- package/react/setup.js +102 -0
package/README.md
CHANGED
|
@@ -163,6 +163,14 @@ app passes its own routes as `client`: `status()` (`{connected, organization, az
|
|
|
163
163
|
`link()` (`{url}`), `script()` (`{script}`), `redeem(code)` and optionally `check()`. An app with a tenant list
|
|
164
164
|
creates its default tenant itself in these calls. `onChange(status)` runs after every action.
|
|
165
165
|
|
|
166
|
+
`<FirstAdminSetup microsoft={...} codeFrom="portal" onSubmit={...} onMicrosoft={...} lang={lang} />` is the first-run
|
|
167
|
+
form «Ersten Administrator anlegen» inside `AuthLayout`, with the same texts in every app (Citadel, Beacon and Pulse
|
|
168
|
+
are the reference). «Mit Microsoft anmelden» is always there: greyed with a hint while the instance has no Scalio ID
|
|
169
|
+
(`microsoft` false), else it calls `onMicrosoft(setupCode)` (the app posts `/auth/setup/microsoft` and redirects).
|
|
170
|
+
`onSubmit({setupCode, name, email, password})` may return `{ok: false, error}` or throw; `error` shows an error from
|
|
171
|
+
outside (e.g. `?sso_error`). Test ids as before: `setup-code-input`, `setup-name-input`, `login-email-input`,
|
|
172
|
+
`login-password-input`, `setup-confirm-input`, `login-submit-button`, `setup-microsoft-btn`.
|
|
173
|
+
|
|
166
174
|
`link` is the router's `NavLink` (it gets `to`, `end`, a `className` function and `onClick`); without it the
|
|
167
175
|
sidebar renders plain links and marks the item for `activePath`. Item test ids default to `nav-<path>`
|
|
168
176
|
(`nav-overview` for `/`), or set `testId`. Page blocks: `KpiTile` (tone `error` = red number),
|
package/auth.css
CHANGED
|
@@ -89,6 +89,12 @@
|
|
|
89
89
|
.scalio-auth-ms:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 1px; }
|
|
90
90
|
.scalio-auth-ms-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
|
|
91
91
|
.scalio-auth-hint { margin-top: 0.25rem; font-size: 11px; color: hsl(var(--muted-foreground)); }
|
|
92
|
+
/* First-run setup (FirstAdminSetup) */
|
|
93
|
+
.scalio-setup { display: flex; flex-direction: column; gap: 1rem; }
|
|
94
|
+
.scalio-setup-field { display: flex; flex-direction: column; gap: 0.25rem; }
|
|
95
|
+
.scalio-setup-field .scalio-field-label { margin-top: 0; }
|
|
96
|
+
.scalio-setup-field .scalio-auth-hint { margin-top: 0; }
|
|
97
|
+
.scalio-setup-submit { margin-top: 0.25rem; width: 100%; height: 2.75rem; font-size: 0.875rem; }
|
|
92
98
|
|
|
93
99
|
.scalio-auth-msg { border: 1px solid; border-radius: 2px; padding: 0.5rem 0.75rem; font-size: 0.875rem; }
|
|
94
100
|
.scalio-auth-msg-error { color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / 0.35); background: hsl(var(--destructive) / 0.08); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "Scalio Control Room design tokens, Tailwind preset, self-hosted fonts, the shared app header, sign-in layout, sidebar and page blocks",
|
|
5
5
|
"license": "SEE LICENSE IN README.md",
|
|
6
6
|
"private": false,
|
package/react/index.js
CHANGED
|
@@ -380,4 +380,4 @@ module.exports = {
|
|
|
380
380
|
};
|
|
381
381
|
Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"));
|
|
382
382
|
// After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
|
|
383
|
-
Object.assign(module.exports, require("./auth"), require("./session"));
|
|
383
|
+
Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"));
|
package/react/labels.js
CHANGED
|
@@ -31,6 +31,27 @@ const LABELS = {
|
|
|
31
31
|
microsoft: "Mit Microsoft anmelden",
|
|
32
32
|
redirecting: "Weiterleitung …",
|
|
33
33
|
orEmail: "oder mit E-Mail",
|
|
34
|
+
// First-run setup «Ersten Administrator anlegen» (FirstAdminSetup), same text in every app
|
|
35
|
+
setup: {
|
|
36
|
+
eyebrow: "Ersteinrichtung",
|
|
37
|
+
title: "Ersten Administrator anlegen",
|
|
38
|
+
subtitle: "Es gibt noch kein Konto. Dieses Konto erhält volle Admin-Rechte.",
|
|
39
|
+
code: "Einrichtungscode",
|
|
40
|
+
codeFromPortal: "Den Einrichtungscode finden Sie im Kundenportal bei Ihrer Instanz.",
|
|
41
|
+
codeFromLog: "Das Backend schreibt ihn bei jedem Start in sein Log (docker logs), oder es ist der Wert von SETUP_CODE.",
|
|
42
|
+
microsoftHint: "Sie werden der erste Administrator. Danach können sich nur Personen Ihrer Microsoft-Organisation anmelden.",
|
|
43
|
+
microsoftOff: "Die Anmeldung mit Microsoft ist auf dieser Instanz noch nicht eingerichtet (Scalio ID).",
|
|
44
|
+
orLocal: "oder lokalen Administrator anlegen",
|
|
45
|
+
name: "Name",
|
|
46
|
+
email: "E-Mail",
|
|
47
|
+
password: "Passwort",
|
|
48
|
+
minLength: "Mindestens {n} Zeichen.",
|
|
49
|
+
confirm: "Passwort bestätigen",
|
|
50
|
+
submit: "Administrator anlegen",
|
|
51
|
+
creating: "Wird angelegt …",
|
|
52
|
+
mismatch: "Die Passwörter stimmen nicht überein.",
|
|
53
|
+
failed: "Das Anlegen ist fehlgeschlagen.",
|
|
54
|
+
},
|
|
34
55
|
email: "E-Mail",
|
|
35
56
|
password: "Passwort",
|
|
36
57
|
forgotPassword: "Passwort vergessen?",
|
|
@@ -572,6 +593,26 @@ const LABELS = {
|
|
|
572
593
|
microsoft: "Sign in with Microsoft",
|
|
573
594
|
redirecting: "Redirecting …",
|
|
574
595
|
orEmail: "or with email",
|
|
596
|
+
setup: {
|
|
597
|
+
eyebrow: "First-run setup",
|
|
598
|
+
title: "Create the first administrator",
|
|
599
|
+
subtitle: "No account exists yet. This account gets full admin rights.",
|
|
600
|
+
code: "Setup code",
|
|
601
|
+
codeFromPortal: "You find the setup code in the customer portal at your instance.",
|
|
602
|
+
codeFromLog: "The backend writes it to its log at every start (docker logs), or it is the value of SETUP_CODE.",
|
|
603
|
+
microsoftHint: "You become the first administrator. Only people of your Microsoft organisation can sign in afterwards.",
|
|
604
|
+
microsoftOff: "Sign-in with Microsoft is not set up on this instance yet (Scalio ID).",
|
|
605
|
+
orLocal: "or create a local administrator",
|
|
606
|
+
name: "Name",
|
|
607
|
+
email: "Email",
|
|
608
|
+
password: "Password",
|
|
609
|
+
minLength: "At least {n} characters.",
|
|
610
|
+
confirm: "Confirm password",
|
|
611
|
+
submit: "Create administrator",
|
|
612
|
+
creating: "Creating …",
|
|
613
|
+
mismatch: "The passwords do not match.",
|
|
614
|
+
failed: "The setup failed.",
|
|
615
|
+
},
|
|
575
616
|
email: "Email",
|
|
576
617
|
password: "Password",
|
|
577
618
|
forgotPassword: "Forgot password?",
|
|
@@ -1094,6 +1135,7 @@ function labelsFor(lang, overrides) {
|
|
|
1094
1135
|
passwordPolicy: Object.assign({}, base.passwordPolicy, o.passwordPolicy),
|
|
1095
1136
|
profile_: Object.assign({}, base.profile_, o.profile_),
|
|
1096
1137
|
wizard: Object.assign({}, base.wizard, o.wizard),
|
|
1138
|
+
setup: Object.assign({}, base.setup, o.setup),
|
|
1097
1139
|
backup: Object.assign({}, base.backup, o.backup),
|
|
1098
1140
|
});
|
|
1099
1141
|
}
|
package/react/setup.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// First-run setup «Ersten Administrator anlegen», the same form in every app (texts of Citadel, Beacon and Pulse,
|
|
3
|
+
// Markus 2026-11-06). Inside AuthLayout, in place of the sign-in form while the backend reports needsSetup.
|
|
4
|
+
// Order: header, setup code, «Mit Microsoft anmelden» (always shown; greyed with a hint while the instance has no
|
|
5
|
+
// Scalio ID), divider, local administrator (name, e-mail, password, confirm), submit.
|
|
6
|
+
// The app passes:
|
|
7
|
+
// microsoft true when sign-in with Microsoft is set up (setup-status «microsoft»)
|
|
8
|
+
// codeFrom "portal" (SaaS: code in the customer portal) or "log"
|
|
9
|
+
// onSubmit(form) {setupCode, name, email, password}; may return {ok:false, error} or throw
|
|
10
|
+
// onMicrosoft(code) starts the Microsoft sign-in (the app posts /auth/setup/microsoft and redirects)
|
|
11
|
+
// error an error from outside, e.g. ?sso_error after Microsoft
|
|
12
|
+
const React = require("react");
|
|
13
|
+
const h = React.createElement;
|
|
14
|
+
const { labelsFor } = require("./labels");
|
|
15
|
+
const { AuthHeader, AuthDivider, AuthMessage, MicrosoftButton } = require("./auth");
|
|
16
|
+
|
|
17
|
+
function errorText(err) {
|
|
18
|
+
const d = err && err.response && err.response.data && err.response.data.detail;
|
|
19
|
+
if (typeof d === "string") return d;
|
|
20
|
+
if (d && typeof d.message === "string") return d.message;
|
|
21
|
+
return (err && err.message) || String(err);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function Field({ id, label, hint, testId, ...input }) {
|
|
25
|
+
return h(
|
|
26
|
+
"div",
|
|
27
|
+
{ className: "scalio-setup-field" },
|
|
28
|
+
h("label", { className: "scalio-field-label", htmlFor: id }, label),
|
|
29
|
+
h("input", { id, className: "scalio-input", "data-testid": testId, ...input }),
|
|
30
|
+
hint ? h("p", { className: "scalio-auth-hint" }, hint) : null
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function FirstAdminSetup({ microsoft, codeFrom, onSubmit, onMicrosoft, error, lang, labels, minLength = 12 }) {
|
|
35
|
+
const L = labelsFor(lang, labels).setup;
|
|
36
|
+
const [code, setCode] = React.useState("");
|
|
37
|
+
const [name, setName] = React.useState("");
|
|
38
|
+
const [email, setEmail] = React.useState("");
|
|
39
|
+
const [password, setPassword] = React.useState("");
|
|
40
|
+
const [confirm, setConfirm] = React.useState("");
|
|
41
|
+
const [busy, setBusy] = React.useState("");
|
|
42
|
+
const [own, setOwn] = React.useState("");
|
|
43
|
+
|
|
44
|
+
const submit = async (e) => {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
setOwn("");
|
|
47
|
+
if (password !== confirm) {
|
|
48
|
+
setOwn(L.mismatch);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
setBusy("form");
|
|
52
|
+
try {
|
|
53
|
+
const res = await onSubmit({ setupCode: code.trim(), name: name.trim(), email: email.trim(), password });
|
|
54
|
+
if (res && res.ok === false) setOwn(res.error || L.failed);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
setOwn(errorText(err));
|
|
57
|
+
} finally {
|
|
58
|
+
setBusy("");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const viaMicrosoft = async () => {
|
|
62
|
+
setOwn("");
|
|
63
|
+
setBusy("microsoft");
|
|
64
|
+
try {
|
|
65
|
+
await onMicrosoft(code.trim());
|
|
66
|
+
} catch (err) {
|
|
67
|
+
setOwn(errorText(err));
|
|
68
|
+
setBusy("");
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return h(
|
|
73
|
+
"form",
|
|
74
|
+
{ className: "scalio-setup", onSubmit: submit, "data-testid": "login-form" },
|
|
75
|
+
h(AuthHeader, { eyebrow: L.eyebrow, title: L.title, subtitle: L.subtitle, testId: "setup-header" }),
|
|
76
|
+
h(Field, { id: "setup-code", label: L.code, testId: "setup-code-input", value: code, required: true, autoComplete: "off",
|
|
77
|
+
onChange: (e) => setCode(e.target.value), style: { fontFamily: "'JetBrains Mono', monospace", letterSpacing: "0.1em" },
|
|
78
|
+
hint: codeFrom === "portal" ? L.codeFromPortal : L.codeFromLog }),
|
|
79
|
+
h(MicrosoftButton, {
|
|
80
|
+
onClick: microsoft ? viaMicrosoft : undefined,
|
|
81
|
+
busy: busy === "microsoft",
|
|
82
|
+
disabled: !microsoft || !!busy || !code.trim(),
|
|
83
|
+
hint: microsoft ? L.microsoftHint : L.microsoftOff,
|
|
84
|
+
lang, labels, testId: "setup-microsoft-btn",
|
|
85
|
+
}),
|
|
86
|
+
h(AuthDivider, { label: L.orLocal, testId: "setup-divider" }),
|
|
87
|
+
h(Field, { id: "setup-name", label: L.name, testId: "setup-name-input", value: name, required: true, autoComplete: "name",
|
|
88
|
+
onChange: (e) => setName(e.target.value) }),
|
|
89
|
+
h(Field, { id: "login-email", label: L.email, testId: "login-email-input", type: "email", value: email, required: true,
|
|
90
|
+
autoComplete: "username", onChange: (e) => setEmail(e.target.value) }),
|
|
91
|
+
h(Field, { id: "login-password", label: L.password, testId: "login-password-input", type: "password", value: password,
|
|
92
|
+
required: true, minLength, autoComplete: "new-password", onChange: (e) => setPassword(e.target.value),
|
|
93
|
+
hint: L.minLength.replace("{n}", String(minLength)) }),
|
|
94
|
+
h(Field, { id: "setup-confirm", label: L.confirm, testId: "setup-confirm-input", type: "password", value: confirm,
|
|
95
|
+
required: true, autoComplete: "new-password", onChange: (e) => setConfirm(e.target.value) }),
|
|
96
|
+
h(AuthMessage, { kind: "error", testId: "login-error" }, own || error || null),
|
|
97
|
+
h("button", { type: "submit", className: "scalio-btn-primary scalio-setup-submit", disabled: !!busy,
|
|
98
|
+
"data-testid": "login-submit-button" }, busy === "form" ? L.creating : L.submit)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = { FirstAdminSetup };
|