@scalio-cloud/ui 0.100.1 → 0.102.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 CHANGED
@@ -381,6 +381,29 @@ const GROUPS = [
381
381
  </SettingsLayout>
382
382
  ```
383
383
 
384
+ ## Whole sign-in page: LoginPage (React, from 0.101.0)
385
+
386
+ The complete sign-in page of every app (review GC2, BL-868; decision Markus 2026-11-29: no app-specific texts or
387
+ parts). Steps: sign-in (Microsoft, e-mail/password, passkey, demo accounts), second factor, «Zugang angefragt» after
388
+ the first Microsoft sign-in, first-run setup. The password policy of the instance decides what shows ("on", "emergency",
389
+ "off"). Texts come from `labels.login` (de/en, `{app}` = `appName`). The app passes its API client and auth functions:
390
+
391
+ ```jsx
392
+ import { LoginPage, ThemeProvider, useTheme } from "@scalio-cloud/ui/react";
393
+ import { ConfirmProvider, useConfirm } from "@scalio-cloud/ui/shadcn/confirm";
394
+
395
+ <LoginPage api={api} apiBase={API} appName="Pulse" lang={lang} onLangChange={setLang} legalUrl={legalUrl}
396
+ brand={{ ...BRAND, claim: t("…"), features: ["Intune", "Patching", "Microsoft 365"] }}
397
+ auth={{ user, login, loginMfa, loginPasskey, loginScalio, setup }} // login -> {ok, error, mfaToken}
398
+ passkeys={passkeysSupported()} onSignedIn={() => navigate(takeAfterLogin(), { replace: true })}
399
+ forgotPassword={{ href: "/forgot-password" }} // optional (BL-869)
400
+ endpoints={{ microsoftStatus: "/auth/entra/status" }} /> // optional, defaults in LOGIN_ENDPOINTS
401
+ ```
402
+
403
+ `ThemeProvider storeKey="pulse_theme"` keeps light/dark/system in the browser (nothing stored = system, so the form
404
+ side follows the device). `ConfirmProvider labels={{ cancel, confirm }}` + `useConfirm()` replaces `window.confirm`
405
+ (needs `@radix-ui/react-alert-dialog`).
406
+
384
407
  ## Sign-in page and profile (React)
385
408
 
386
409
  All sign-in pages use the same frame and order: Microsoft first, then "oder mit E-Mail", the password field with
@@ -677,6 +700,12 @@ list. Test IDs: `agents-panel`, `agents-code-create`, `agents-code-value`, `agen
677
700
  `agent-role-<id>-<role>`, `agent-worker-state-<id>-<worker>`, `agent-worker-restart|stop|start-<id>-<worker>`,
678
701
  `agent-block-<id>`, `agent-remove-<id>`, `agents-tasks`.
679
702
 
703
+ Since 0.102.0 «Agent hinzufügen» shows every offered role as a checkbox, also a single one, and none is preselected;
704
+ without a role the dialog says the agent fetches no tasks (`agents-code-norole`; BL-770, Markus 2026-12-01). The update
705
+ reasons `data_folder_unsafe` and `data_folder_uncheckable` are shown in words with the link «Anleitung zur Reparatur»
706
+ (`agent-update-help-<id>`) to the manual; `dataFolderHelpUrl` replaces the default address (docs.scalionexus.com,
707
+ section «Datenordner unsicher»; BL-775). Other reasons stay raw.
708
+
680
709
  Since 0.84.0 a saved agent setting stays in its field with the badge «gesendet, wird übernommen»
681
710
  (`agent-setting-sent-<id>-<name>`) until the agent reports it in its next heartbeat; before, the field fell back to the
682
711
  old value right after «Speichern» (Markus 2026-11-15). The script editor of `AgentScriptsPanel` is at least 60 % of the window high
@@ -887,10 +916,11 @@ import { AlertDialog, AlertDialogContent } from "@scalio-cloud/ui/shadcn/alert-d
887
916
  import { cn } from "@scalio-cloud/ui/shadcn/utils";
888
917
  ```
889
918
 
890
- Components: `alert-dialog`, `badge`, `button`, `checkbox`, `dialog` (`closeLabel` for the hidden close text),
919
+ Components: `alert-dialog`, `badge`, `button`, `checkbox`, `command` (cmdk; `CommandDialog` with `title`,
920
+ `description` and `closeLabel` for the hidden texts, from 0.101.0), `dialog` (`closeLabel` for the hidden close text),
891
921
  `dropdown-menu`, `input`, `label`, `popover`, `progress`, `select`, `sonner` (`Toaster theme`, no next-themes),
892
922
  `switch`, `table`, `tabs`, `textarea`, `utils` (`cn`). Always needed: `clsx`, `tailwind-merge`; per component the
893
- `@radix-ui/react-*` package, `class-variance-authority` (button, badge), `lucide-react` (icons), `sonner`. Tailwind
923
+ `@radix-ui/react-*` package, `cmdk` (command), `class-variance-authority` (button, badge), `lucide-react` (icons), `sonner`. Tailwind
894
924
  must scan the files: add `"./node_modules/@scalio-cloud/ui/shadcn/*.mjs"` to `content` in `tailwind.config.js`.
895
925
  An app keeps a component in `src/components/ui` only when no other app uses it.
896
926
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.100.1",
3
+ "version": "0.102.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,
@@ -62,6 +62,7 @@
62
62
  "@radix-ui/react-tabs": "^1.1.0",
63
63
  "class-variance-authority": "^0.7.0",
64
64
  "clsx": "^2.1.0",
65
+ "cmdk": "^1.1.0",
65
66
  "lucide-react": ">=0.400.0",
66
67
  "react": ">=18",
67
68
  "react-dom": ">=18",
@@ -109,6 +110,9 @@
109
110
  "clsx": {
110
111
  "optional": true
111
112
  },
113
+ "cmdk": {
114
+ "optional": true
115
+ },
112
116
  "lucide-react": {
113
117
  "optional": true
114
118
  },
@@ -148,6 +152,7 @@
148
152
  "@radix-ui/react-tabs": "1.2.1",
149
153
  "class-variance-authority": "0.7.1",
150
154
  "clsx": "2.1.1",
155
+ "cmdk": "1.1.1",
151
156
  "jsdom": "31.0.0",
152
157
  "lucide-react": "1.72.0",
153
158
  "react": "19.3.1",
package/react/agents.js CHANGED
@@ -31,6 +31,7 @@ const LABELS = {
31
31
  noErrors: "Keine Fehler.",
32
32
  updShort: "Updates",
33
33
  codeRoles: "Rollen für den neuen Agent",
34
+ noRoleHint: "Ohne Rolle holt der Agent keine Aufträge. Sie können die Rolle auch später setzen.",
34
35
  codeNote: "Notiz (z. B. Servername)",
35
36
  codeTitle: "Registrierungscode",
36
37
  codeOnce: "Der Code wird nur jetzt angezeigt. Er gilt 24 Stunden und nur für einen Server.",
@@ -120,6 +121,9 @@ const LABELS = {
120
121
  updStates: { installing: "Wird aktualisiert auf {version}", verifying: "Prüft Version {version}", installed: "Aktualisiert auf {version}",
121
122
  rolled_back: "Zurückgerollt auf {from} ({reason})", rollback_failed: "Rollback fehlgeschlagen ({reason})", failed: "Update fehlgeschlagen ({reason})",
122
123
  refused: "Update abgelehnt ({reason})" },
124
+ updReasons: { data_folder_unsafe: "Datenordner C:\\ProgramData\\Scalio hat unsichere Berechtigungen",
125
+ data_folder_uncheckable: "Datenordner C:\\ProgramData\\Scalio nicht prüfbar" },
126
+ repairGuide: "Anleitung zur Reparatur",
123
127
  },
124
128
  en: {
125
129
  title: "Scalio Agent",
@@ -133,6 +137,7 @@ const LABELS = {
133
137
  noErrors: "No errors.",
134
138
  updShort: "Updates",
135
139
  codeRoles: "Roles of the new agent",
140
+ noRoleHint: "Without a role the agent fetches no tasks. You can also set the role later.",
136
141
  codeNote: "Note (e.g. server name)",
137
142
  codeTitle: "Enrollment code",
138
143
  codeOnce: "The code is shown only now. It is valid for 24 hours and for one server.",
@@ -222,6 +227,9 @@ const LABELS = {
222
227
  updStates: { installing: "Updating to {version}", verifying: "Checking version {version}", installed: "Updated to {version}",
223
228
  rolled_back: "Rolled back to {from} ({reason})", rollback_failed: "Rollback failed ({reason})", failed: "Update failed ({reason})",
224
229
  refused: "Update refused ({reason})" },
230
+ updReasons: { data_folder_unsafe: "data folder C:\\ProgramData\\Scalio has unsafe permissions",
231
+ data_folder_uncheckable: "data folder C:\\ProgramData\\Scalio not checkable" },
232
+ repairGuide: "Repair guide",
225
233
  },
226
234
  };
227
235
 
@@ -230,6 +238,11 @@ const UPDATE_TONE = { installing: "running", verifying: "running", installed: "o
230
238
  const RETRY_STATES = ["rolled_back", "rollback_failed", "failed", "refused"];
231
239
  const TASK_TONE = { queued: "neutral", claimed: "running", finished: "ok", error: "error" };
232
240
 
241
+ // public manual section for an unsafe or uncheckable data folder (BL-775); apps may pass dataFolderHelpUrl
242
+ const DATA_FOLDER_HELP = { de: "https://docs.scalionexus.com/de/admin/scalio-agent/#datenordner-unsicher",
243
+ en: "https://docs.scalionexus.com/admin/scalio-agent/#data-folder-unsafe" };
244
+ const DATA_FOLDER_REASONS = ["data_folder_unsafe", "data_folder_uncheckable"];
245
+
233
246
  function labels(lang, overrides) {
234
247
  return Object.assign({}, LABELS[lang === "en" ? "en" : "de"], overrides || {});
235
248
  }
@@ -480,9 +493,9 @@ function AgentsPanel(props) {
480
493
  }, [load, props.refreshMs]);
481
494
 
482
495
  const offered = (data && data.roles) || [];
483
- // several roles offered: none preselected, the admin picks (no Active Directory by default);
484
- // a single offered role has no checkbox, so it is the only possible choice
485
- const selectedRoles = codeRoles || (offered.length === 1 ? [offered[0].name] : []);
496
+ // offered roles are never preselected, also a single one (BL-770): the admin ticks them;
497
+ // an agent without a role fetches no tasks, the dialog says so
498
+ const selectedRoles = codeRoles || [];
486
499
 
487
500
  const run = async (fn, okText) => {
488
501
  setBusy(true);
@@ -551,12 +564,14 @@ function AgentsPanel(props) {
551
564
  h("p", { className: "scalio-settings-text", style: { margin: 0 } }, L.addHint),
552
565
  props.downloadUrl ? h("a", { className: "scalio-btn", href: props.downloadUrl, style: { justifySelf: "start" } },
553
566
  h(Icons.Download, { className: "scalio-icon" }), L.download) : null,
554
- offered.length > 1 ? h("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.75rem" } },
567
+ offered.length > 0 ? h("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.75rem" } },
555
568
  h("span", { className: "scalio-settings-text" }, `${L.codeRoles}:`),
556
569
  offered.map((r) => h("label", { key: r.name, className: "scalio-settings-check" },
557
570
  h("input", { type: "checkbox", checked: selectedRoles.includes(r.name), disabled: busy || !!shown, "data-testid": `agents-code-role-${r.name}`,
558
571
  onChange: () => setCodeRoles(selectedRoles.includes(r.name) ? selectedRoles.filter((x) => x !== r.name) : selectedRoles.concat([r.name])) }),
559
572
  h("span", null, r.label || r.name)))) : null,
573
+ offered.length > 0 && !shown && selectedRoles.length === 0
574
+ ? h("p", { className: "scalio-settings-text", style: { margin: 0 }, "data-testid": "agents-code-norole" }, L.noRoleHint) : null,
560
575
  shown ? null : h("div", { style: { display: "flex", gap: "0.5rem", flexWrap: "wrap" } },
561
576
  h("input", { className: "scalio-input", placeholder: L.codeNote, "aria-label": L.codeNote, value: note, maxLength: 200, disabled: busy,
562
577
  style: { flex: "1 1 14rem" }, "data-testid": "agents-code-note", onChange: (e) => setNote(e.target.value) }),
@@ -619,8 +634,13 @@ function AgentsPanel(props) {
619
634
  const running = String(a.version || "").split("+")[0];
620
635
  const bundled = upd && upd.available && upd.available.version === u.version && upd.available.build;
621
636
  const shown = u.state === "installed" && running.startsWith(u.version || "\u0000") ? running : (bundled || u.version);
622
- const text = fill((L.updStates || {})[u.state] || u.state, { version: shown, from: String(u.from_version || a.version || "").split("+")[0], reason: u.reason || "–" });
637
+ const text = fill((L.updStates || {})[u.state] || u.state, { version: shown, from: String(u.from_version || a.version || "").split("+")[0], reason: (L.updReasons || {})[u.reason] || u.reason || "–" });
623
638
  out.push(h("div", { key: "s" }, h(StatusBadge, { tone: UPDATE_TONE[u.state] || "neutral", testId: `agent-update-state-${a.id}` }, text)));
639
+ if (DATA_FOLDER_REASONS.includes(u.reason)) {
640
+ out.push(h("div", { key: "help", className: "scalio-settings-text" },
641
+ h("a", { href: props.dataFolderHelpUrl || DATA_FOLDER_HELP[props.lang === "en" ? "en" : "de"], target: "_blank", rel: "noopener noreferrer",
642
+ "data-testid": `agent-update-help-${a.id}` }, L.repairGuide)));
643
+ }
624
644
  }
625
645
  if (a.scripts) {
626
646
  out.push(h("div", { key: "sc", className: "scalio-settings-text", "data-testid": `agent-scripts-${a.id}` },
package/react/index.js CHANGED
@@ -406,4 +406,4 @@ module.exports = {
406
406
  };
407
407
  Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./limited_mode"), require("./access_limit"), 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"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./agent_scripts"), require("./ai"), require("./markdown"), require("./tenancy"), require("./legal"), require("./suite_context"));
408
408
  // After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
409
- Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./clientErrors"));
409
+ Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./login"), require("./theme"), require("./clientErrors"));
package/react/labels.js CHANGED
@@ -61,6 +61,43 @@ const LABELS = {
61
61
  email: "E-Mail",
62
62
  password: "Passwort",
63
63
  forgotPassword: "Passwort vergessen?",
64
+ // LoginPage (react/login.js, GC2): the whole sign-in page, same in every app; {app} = app name
65
+ login: {
66
+ access: "Zugang",
67
+ title: "Anmeldung zum Leitstand",
68
+ subtitle: "Geben Sie Ihre Zugangsdaten ein, um fortzufahren.",
69
+ email: "E-Mail",
70
+ password: "Passwort",
71
+ forgotPassword: "Passwort vergessen?",
72
+ submit: "Anmelden",
73
+ or: "oder",
74
+ passkey: "Mit Passkey anmelden",
75
+ passwordOff: "Diese Installation nutzt nur die Anmeldung mit Microsoft.",
76
+ emergency: "Als Notfall-Administrator anmelden",
77
+ failed: "Die Anmeldung ist fehlgeschlagen.",
78
+ pendingTitle: "Zugang angefragt",
79
+ pendingText: "Ihr Konto wurde angelegt. Ein Administrator muss es freigeben, bevor Sie {app} nutzen können. Bitte versuchen Sie es später noch einmal.",
80
+ backToSignIn: "Zurück zur Anmeldung",
81
+ mfaEyebrow: "Anmeldung mit zweitem Faktor",
82
+ mfaTitle: "Code eingeben",
83
+ mfaText: "Öffnen Sie Ihre Authenticator-App und geben Sie den 6-stelligen Code ein. Ein Backup-Code geht auch.",
84
+ code: "Code",
85
+ confirm: "Bestätigen",
86
+ back: "Zurück",
87
+ sso: {
88
+ expired: "Die Anmeldung hat zu lange gedauert. Bitte versuchen Sie es erneut.",
89
+ cancelled: "Die Anmeldung mit Microsoft wurde abgebrochen.",
90
+ personal: "Bitte verwenden Sie Ihr Geschäftskonto, kein privates Microsoft-Konto.",
91
+ tenant_not_allowed: "Ihre Organisation ist für diese Installation nicht freigeschaltet.",
92
+ no_account: "Für diese Microsoft-Identität gibt es kein Konto. Bitten Sie einen Administrator, Sie einzuladen.",
93
+ locked: "Ihr Konto ist gesperrt. Wenden Sie sich an einen Administrator.",
94
+ suspended: "Ihre Organisation ist gesperrt. Wenden Sie sich an Ihren Anbieter.",
95
+ no_role: "Sie haben in Entra ID keine Rolle für Scalio {app}. Bitten Sie Ihre IT, Ihnen eine zuzuweisen.",
96
+ failed: "Die Anmeldung mit Microsoft ist fehlgeschlagen. Bitte versuchen Sie es erneut.",
97
+ setup_needs_microsoft: "Für die Einrichtung braucht es ein Microsoft-Geschäftskonto.",
98
+ setup_done: "Die Einrichtung ist schon abgeschlossen. Bitte melden Sie sich an.",
99
+ },
100
+ },
64
101
  backToSignIn: "Zurück zur Anmeldung",
65
102
  profile: "Profil",
66
103
  save: "Speichern",
@@ -672,6 +709,43 @@ const LABELS = {
672
709
  email: "Email",
673
710
  password: "Password",
674
711
  forgotPassword: "Forgot password?",
712
+ // LoginPage (react/login.js, GC2); {app} = app name
713
+ login: {
714
+ access: "Access",
715
+ title: "Sign in to the Control Room",
716
+ subtitle: "Enter your credentials to continue.",
717
+ email: "Email",
718
+ password: "Password",
719
+ forgotPassword: "Forgot password?",
720
+ submit: "Sign in",
721
+ or: "or",
722
+ passkey: "Sign in with a passkey",
723
+ passwordOff: "This installation uses sign-in with Microsoft only.",
724
+ emergency: "Sign in as emergency administrator",
725
+ failed: "The sign-in failed.",
726
+ pendingTitle: "Access requested",
727
+ pendingText: "Your account has been created. An administrator has to approve it before you can use {app}. Please try again later.",
728
+ backToSignIn: "Back to sign in",
729
+ mfaEyebrow: "Two-factor sign-in",
730
+ mfaTitle: "Enter code",
731
+ mfaText: "Open your authenticator app and enter the 6-digit code. A backup code also works.",
732
+ code: "Code",
733
+ confirm: "Confirm",
734
+ back: "Back",
735
+ sso: {
736
+ expired: "The sign-in took too long. Please try again.",
737
+ cancelled: "The sign-in with Microsoft was cancelled.",
738
+ personal: "Please use your work account, not a personal Microsoft account.",
739
+ tenant_not_allowed: "Your organisation is not enabled for this installation.",
740
+ no_account: "There is no account for this Microsoft identity. Ask an administrator to invite you.",
741
+ locked: "Your account is locked. Ask an administrator.",
742
+ suspended: "Your organization is suspended. Contact your provider.",
743
+ no_role: "You have no Scalio {app} role in Entra ID. Ask your IT to assign you one.",
744
+ failed: "The sign-in with Microsoft failed. Please try again.",
745
+ setup_needs_microsoft: "The setup needs a Microsoft work account.",
746
+ setup_done: "The setup is already completed. Please sign in.",
747
+ },
748
+ },
675
749
  backToSignIn: "Back to sign in",
676
750
  profile: "Profile",
677
751
  save: "Save",
package/react/login.js ADDED
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ // LoginPage: the whole sign-in page of every Scalio app (review GC2, BL-868, decision Markus 2026-11-29: no
3
+ // app-specific texts or parts). Before 0.101.0 every app kept its own copy of this page (about 240 lines).
4
+ //
5
+ // Steps on one page: sign-in (Microsoft through Scalio ID, e-mail and password, passkey, demo accounts),
6
+ // second factor, «access requested» after the first Microsoft sign-in, and the first-run setup (FirstAdminSetup).
7
+ // The password policy of the instance decides what shows: "on" (form), "emergency" (form behind a button), "off"
8
+ // (Microsoft only). «Forgot password?» shows when the app passes `forgotPassword` (BL-869).
9
+ //
10
+ // The app passes its API client and its auth functions; the page never talks to the network on its own:
11
+ // api axios-like client: api.get(path) and api.post(path, body) resolve to { data }
12
+ // apiBase base address for full-page redirects (Microsoft sign-in), e.g. "/api"
13
+ // auth { user, login(email, password) -> {ok, error, mfaToken}, loginMfa(token, code) -> {ok, status, error},
14
+ // loginPasskey() -> {ok, error}, loginScalio(handoff) -> {ok, status}, setup(name, email, password, code) }
15
+ // errorText optional (code) => text for an error code the shared texts do not know
16
+ // endpoints optional, for apps whose routes differ (defaults below)
17
+ // brand { mark, name, beta, color, claim, features } appName: "Pulse" (used in two texts)
18
+ // lang, onLangChange, legalUrl, passkeys (bool), onSignedIn (called when `auth.user` is set; the app navigates)
19
+ // forgotPassword optional { href } or { onClick } for the link under the password field
20
+ const React = require("react");
21
+ const h = React.createElement;
22
+ const { labelsFor } = require("./labels");
23
+ const { AuthLayout, AuthHeader, AuthDivider, AuthMessage, DemoAccounts, MicrosoftButton } = require("./auth");
24
+ const { FirstAdminSetup } = require("./setup");
25
+
26
+ const ENDPOINTS = {
27
+ setupStatus: "/auth/setup-status",
28
+ loginPolicy: "/auth/login-policy",
29
+ demo: "/auth/demo",
30
+ microsoftStatus: "/auth/scalio/status",
31
+ microsoftLogin: "/auth/scalio/login",
32
+ setupMicrosoft: "/auth/setup/microsoft",
33
+ };
34
+
35
+ const FIELD = "mt-1 w-full h-10 px-3 bg-background border border-input rounded-sm text-sm focus:outline-none focus:ring-1 focus:ring-ring focus:border-ring transition-colors";
36
+ const LABEL = "text-[11px] font-bold uppercase tracking-widest text-muted-foreground";
37
+ const PRIMARY = "w-full h-11 flex items-center justify-center gap-2 bg-primary text-primary-foreground rounded-sm text-sm font-bold uppercase tracking-wider hover:bg-primary/90 transition-colors disabled:opacity-60";
38
+ const SECONDARY = "w-full h-11 flex items-center justify-center gap-2 border border-input bg-background rounded-sm text-sm font-bold uppercase tracking-wider hover:bg-secondary transition-colors disabled:opacity-60";
39
+ const QUIET = "w-full h-9 text-xs font-bold uppercase tracking-wider text-muted-foreground hover:text-foreground";
40
+
41
+ function fill(text, appName) {
42
+ return String(text || "").replace(/\{app\}/g, appName || "");
43
+ }
44
+
45
+ // Reads ?sso_error, ?sso=1, ?pending=1 and the #scalio handoff once and removes them from the address.
46
+ function readArrival(loc) {
47
+ const l = loc || (typeof window !== "undefined" ? window.location : null);
48
+ if (!l) return {};
49
+ const params = new URLSearchParams(l.search || "");
50
+ const handoff = new URLSearchParams(String(l.hash || "").slice(1)).get("scalio");
51
+ const out = {
52
+ handoff: handoff || "",
53
+ ssoError: params.get("sso_error") || params.get("error") || "",
54
+ silent: params.get("sso") === "1",
55
+ pending: params.get("pending") === "1",
56
+ };
57
+ if ((out.handoff || out.ssoError || out.silent || out.pending) && typeof window !== "undefined" && window.history) {
58
+ window.history.replaceState(null, "", l.pathname);
59
+ }
60
+ return out;
61
+ }
62
+
63
+ function LoginPage(props) {
64
+ const { api, apiBase = "/api", auth, brand, appName, lang = "de", onLangChange, legalUrl, passkeys, onSignedIn,
65
+ forgotPassword, testIds } = props;
66
+ const L = labelsFor(lang).login;
67
+ const ep = Object.assign({}, ENDPOINTS, props.endpoints || {});
68
+ const ids = Object.assign({ language: "login-language-btn" }, testIds || {});
69
+ const go = (url) => { if (typeof window !== "undefined") window.location.assign(url); };
70
+ const assign = props.assign || go;
71
+
72
+ const [mode, setMode] = React.useState("login");
73
+ const [email, setEmail] = React.useState("");
74
+ const [password, setPassword] = React.useState("");
75
+ const [error, setError] = React.useState("");
76
+ const [loading, setLoading] = React.useState(false);
77
+ const [mfaToken, setMfaToken] = React.useState("");
78
+ const [code, setCode] = React.useState("");
79
+ const [microsoft, setMicrosoft] = React.useState(false);
80
+ const [redirecting, setRedirecting] = React.useState(false);
81
+ const [pending, setPending] = React.useState(false);
82
+ const [setupMicrosoft, setSetupMicrosoft] = React.useState(false);
83
+ const [codeFromPortal, setCodeFromPortal] = React.useState(false);
84
+ const [policy, setPolicy] = React.useState("on");
85
+ const [showEmergency, setShowEmergency] = React.useState(false);
86
+ const [demoAccounts, setDemoAccounts] = React.useState([]);
87
+
88
+ // errorText(code): optional, text for a code of the app's own (Rosetta); else the shared texts.
89
+ const ssoText = (key) => (L.sso[key] ? fill(L.sso[key], appName) : (props.errorText && props.errorText(key)) || fill(L.sso.failed, appName));
90
+
91
+ React.useEffect(() => {
92
+ api.get(ep.setupStatus).then((r) => {
93
+ const d = (r && r.data) || {};
94
+ // camelCase (most apps) or snake_case (Foundry) answer
95
+ if (!(d.needsSetup || d.needs_setup)) return;
96
+ setMode("setup");
97
+ setSetupMicrosoft(!!d.microsoft);
98
+ setCodeFromPortal((d.codeFrom || d.code_from) === "portal");
99
+ }).catch(() => {});
100
+ api.get(ep.loginPolicy).then((r) => setPolicy((r && r.data && r.data.password) || "on")).catch(() => {});
101
+ api.get(ep.demo).then((r) => {
102
+ const d = (r && r.data) || {};
103
+ setDemoAccounts(d.demo ? d.accounts || [] : []);
104
+ }).catch(() => {});
105
+ const arrival = readArrival(props.location);
106
+ if (arrival.pending) setPending(true);
107
+ if (arrival.handoff) {
108
+ setLoading(true);
109
+ Promise.resolve(auth.loginScalio(arrival.handoff)).then((res) => {
110
+ setLoading(false);
111
+ if (!res || !res.ok) setError(ssoText(res && res.status === 401 ? "expired" : "failed"));
112
+ });
113
+ }
114
+ if (arrival.ssoError) setError(ssoText(arrival.ssoError));
115
+ api.get(ep.microsoftStatus).then((r) => {
116
+ const d = (r && r.data) || {};
117
+ if (!(d.enabled || d.configured)) return;
118
+ setMicrosoft(true);
119
+ // Coming from the product switcher of another Scalio app: try a silent sign-in once.
120
+ if (arrival.silent && !arrival.ssoError && !arrival.handoff) {
121
+ setRedirecting(true);
122
+ assign(`${apiBase}${ep.microsoftLogin.replace(/^\/api/, "")}?silent=1`);
123
+ }
124
+ }).catch(() => {});
125
+ // Runs once on arrival.
126
+ // eslint-disable-next-line react-hooks/exhaustive-deps
127
+ }, []);
128
+
129
+ React.useEffect(() => {
130
+ if (auth.user && onSignedIn) onSignedIn(auth.user);
131
+ }, [auth.user, onSignedIn]);
132
+
133
+ if (auth.user) return null;
134
+
135
+ const submit = async (e) => {
136
+ e.preventDefault();
137
+ setError("");
138
+ setLoading(true);
139
+ const res = (await auth.login(email, password)) || {};
140
+ setLoading(false);
141
+ if (res.mfaToken) { setMfaToken(res.mfaToken); setPassword(""); }
142
+ else if (!res.ok) setError(res.error || L.failed);
143
+ };
144
+ const submitCode = async (e) => {
145
+ e.preventDefault();
146
+ setError("");
147
+ setLoading(true);
148
+ const res = (await auth.loginMfa(mfaToken, code)) || {};
149
+ setLoading(false);
150
+ if (!res.ok) {
151
+ if (res.status === 401 && /expired|again/i.test(res.error || "")) setMfaToken("");
152
+ setError(res.error || L.failed);
153
+ setCode("");
154
+ }
155
+ };
156
+ const setupWithMicrosoft = async (setupCode) => {
157
+ setError("");
158
+ const { data } = await api.post(ep.setupMicrosoft, { setup_code: setupCode });
159
+ setRedirecting(true);
160
+ assign(`${apiBase}${String(data.url).replace(/^\/api/, "")}`);
161
+ };
162
+ const passkey = async () => {
163
+ setError("");
164
+ setLoading(true);
165
+ const res = (await auth.loginPasskey()) || {};
166
+ setLoading(false);
167
+ if (!res.ok && res.error) setError(res.error);
168
+ };
169
+
170
+ const label = (htmlFor, text) => h("label", { className: LABEL, htmlFor }, text);
171
+ const spinner = loading ? h("span", { className: "w-4 h-4 animate-spin rounded-full border-2 border-current border-t-transparent", "aria-hidden": "true" }) : null;
172
+
173
+ let body;
174
+ if (pending) {
175
+ body = h("div", { className: "space-y-4", "data-testid": "login-pending" },
176
+ h(AuthHeader, { eyebrow: L.access, title: L.pendingTitle, subtitle: fill(L.pendingText, appName) }),
177
+ h("button", { type: "button", "data-testid": "login-pending-back", onClick: () => setPending(false), className: QUIET }, L.backToSignIn));
178
+ } else if (mfaToken) {
179
+ body = h("form", { onSubmit: submitCode, className: "space-y-4", "data-testid": "mfa-form" },
180
+ h(AuthHeader, { eyebrow: L.mfaEyebrow, title: L.mfaTitle, subtitle: L.mfaText }),
181
+ h("div", null, label("mfa-code", L.code),
182
+ h("input", { id: "mfa-code", "data-testid": "mfa-code-input", value: code, onChange: (e) => setCode(e.target.value), required: true,
183
+ autoFocus: true, autoComplete: "one-time-code", maxLength: 16, className: `${FIELD} font-mono tracking-widest` })),
184
+ h(AuthMessage, { kind: "error", testId: "login-error" }, error),
185
+ h("button", { "data-testid": "mfa-submit-btn", type: "submit", disabled: loading || !code.trim(), className: PRIMARY }, spinner, L.confirm),
186
+ h("button", { type: "button", "data-testid": "mfa-back-btn", className: QUIET,
187
+ onClick: () => { setMfaToken(""); setCode(""); setError(""); } }, L.back));
188
+ } else if (mode === "setup") {
189
+ body = h(FirstAdminSetup, { microsoft: setupMicrosoft, codeFrom: codeFromPortal ? "portal" : "log", lang, error,
190
+ onSubmit: ({ setupCode, name, email: mail, password: pw }) => auth.setup(name, mail, pw, setupCode),
191
+ onMicrosoft: setupWithMicrosoft });
192
+ } else {
193
+ const form = policy === "on" || (policy === "emergency" && showEmergency);
194
+ body = h(React.Fragment, null,
195
+ h(AuthHeader, { eyebrow: L.access, title: L.title, subtitle: L.subtitle }),
196
+ microsoft && h("div", { className: "mb-4 space-y-4" },
197
+ h(MicrosoftButton, { href: `${apiBase}${ep.microsoftLogin.replace(/^\/api/, "")}`, onClick: () => setRedirecting(true),
198
+ busy: redirecting, disabled: loading, lang }),
199
+ form && h(AuthDivider, { lang })),
200
+ policy === "off" && h("p", { className: "text-xs text-muted-foreground", "data-testid": "login-password-off" }, L.passwordOff),
201
+ !form && policy !== "off" && h(AuthMessage, { kind: "error", testId: "login-error" }, error),
202
+ policy === "emergency" && !showEmergency && h("button", { type: "button", "data-testid": "login-emergency-btn",
203
+ onClick: () => setShowEmergency(true), className: QUIET }, L.emergency),
204
+ form && h(React.Fragment, null,
205
+ h(DemoAccounts, { accounts: demoAccounts, lang, className: "mb-4",
206
+ onPick: (a) => { setEmail(a.email); setPassword(a.password); setError(""); } }),
207
+ h("form", { onSubmit: submit, className: "space-y-4", "data-testid": "login-form" },
208
+ h("div", null, label("login-email", L.email),
209
+ h("input", { id: "login-email", "data-testid": "login-email-input", type: "email", value: email,
210
+ onChange: (e) => setEmail(e.target.value), required: true, autoComplete: "username", className: FIELD })),
211
+ h("div", null, label("login-password", L.password),
212
+ h("input", { id: "login-password", "data-testid": "login-password-input", type: "password", value: password,
213
+ onChange: (e) => setPassword(e.target.value), required: true, autoComplete: "current-password", className: FIELD }),
214
+ forgotPassword && h("a", { href: forgotPassword.href || "#", "data-testid": "login-forgot-link",
215
+ onClick: forgotPassword.onClick ? (e) => { e.preventDefault(); forgotPassword.onClick(); } : undefined,
216
+ className: "mt-2 inline-block text-xs font-medium text-primary hover:underline" }, L.forgotPassword)),
217
+ h(AuthMessage, { kind: "error", testId: "login-error" }, error),
218
+ h("button", { "data-testid": "login-submit-button", type: "submit", disabled: loading, className: PRIMARY }, spinner, L.submit),
219
+ passkeys && h(React.Fragment, null,
220
+ h(AuthDivider, { label: L.or }),
221
+ h("button", { type: "button", "data-testid": "passkey-login-btn", disabled: loading, onClick: passkey, className: SECONDARY },
222
+ L.passkey)))));
223
+ }
224
+
225
+ return h(AuthLayout, { legalUrl, brand, lang, onLangChange, testIds: ids }, body);
226
+ }
227
+
228
+ module.exports = { LoginPage, LOGIN_ENDPOINTS: ENDPOINTS, readArrival };
package/react/theme.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ // ThemeProvider / useTheme: light, dark or like the system, kept in this browser (review GC3, BL-868). Before 0.101.0
3
+ // every app kept the same ThemeContext.jsx; only the storage key differed. Nothing stored = "system", so the
4
+ // sign-in page is light in light mode and dark in dark mode (decision Markus 2026-11-29).
5
+ // <ThemeProvider storeKey="pulse_theme">…</ThemeProvider>; const { theme, setTheme } = useTheme();
6
+ const React = require("react");
7
+ const h = React.createElement;
8
+ const { applyTheme, normalizeTheme } = require("./profile");
9
+
10
+ const ThemeContext = React.createContext({ theme: "system", setTheme: () => {} });
11
+
12
+ function readTheme(storeKey) {
13
+ try {
14
+ return normalizeTheme(localStorage.getItem(storeKey));
15
+ } catch (e) {
16
+ return "system";
17
+ }
18
+ }
19
+
20
+ function ThemeProvider({ storeKey = "theme", children }) {
21
+ const [theme, setTheme] = React.useState(() => readTheme(storeKey));
22
+ React.useEffect(() => {
23
+ try {
24
+ localStorage.setItem(storeKey, theme);
25
+ } catch (e) {
26
+ // keep the choice for this visit only
27
+ }
28
+ return applyTheme(theme);
29
+ }, [theme, storeKey]);
30
+ const value = React.useMemo(() => ({ theme, setTheme: (t) => setTheme(normalizeTheme(t)) }), [theme]);
31
+ return h(ThemeContext.Provider, { value }, children);
32
+ }
33
+
34
+ const useTheme = () => React.useContext(ThemeContext);
35
+
36
+ module.exports = { ThemeProvider, useTheme };
@@ -0,0 +1,107 @@
1
+ // shadcn/ui component shared by the Scalio apps (review GC7, Grundregel 8). Import it as
2
+ // "@scalio-cloud/ui/shadcn/command"; the app installs the peer dependencies it uses (README).
3
+ import * as React from "react";
4
+ import { Command as CommandPrimitive } from "cmdk";
5
+ import { Search } from "lucide-react";
6
+ import { cn } from "./utils.mjs";
7
+ import { Dialog, DialogContent, DialogTitle, DialogDescription } from "./dialog.mjs";
8
+ const Command = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
9
+ CommandPrimitive,
10
+ {
11
+ ref,
12
+ className: cn(
13
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
14
+ className
15
+ ),
16
+ ...props
17
+ }
18
+ ));
19
+ Command.displayName = CommandPrimitive.displayName;
20
+ const CommandDialog = ({
21
+ children,
22
+ title = "Command palette",
23
+ description = "Search pages and run actions",
24
+ closeLabel,
25
+ ...props
26
+ }) => {
27
+ return /* @__PURE__ */ React.createElement(Dialog, { ...props }, /* @__PURE__ */ React.createElement(DialogContent, { className: "overflow-hidden p-0", closeLabel }, /* @__PURE__ */ React.createElement(DialogTitle, { className: "sr-only" }, title), /* @__PURE__ */ React.createElement(DialogDescription, { className: "sr-only" }, description), /* @__PURE__ */ React.createElement(
28
+ Command,
29
+ {
30
+ className: "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"
31
+ },
32
+ children
33
+ )));
34
+ };
35
+ const CommandInput = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "" }, /* @__PURE__ */ React.createElement(Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }), /* @__PURE__ */ React.createElement(
36
+ CommandPrimitive.Input,
37
+ {
38
+ ref,
39
+ className: cn(
40
+ "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
41
+ className
42
+ ),
43
+ ...props
44
+ }
45
+ )));
46
+ CommandInput.displayName = CommandPrimitive.Input.displayName;
47
+ const CommandList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
48
+ CommandPrimitive.List,
49
+ {
50
+ ref,
51
+ className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
52
+ ...props
53
+ }
54
+ ));
55
+ CommandList.displayName = CommandPrimitive.List.displayName;
56
+ const CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ React.createElement(CommandPrimitive.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
57
+ CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
58
+ const CommandGroup = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
59
+ CommandPrimitive.Group,
60
+ {
61
+ ref,
62
+ className: cn(
63
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
64
+ className
65
+ ),
66
+ ...props
67
+ }
68
+ ));
69
+ CommandGroup.displayName = CommandPrimitive.Group.displayName;
70
+ const CommandSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(CommandPrimitive.Separator, { ref, className: cn("-mx-1 h-px bg-border", className), ...props }));
71
+ CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
72
+ const CommandItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
73
+ CommandPrimitive.Item,
74
+ {
75
+ ref,
76
+ className: cn(
77
+ "relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
78
+ className
79
+ ),
80
+ ...props
81
+ }
82
+ ));
83
+ CommandItem.displayName = CommandPrimitive.Item.displayName;
84
+ const CommandShortcut = ({
85
+ className,
86
+ ...props
87
+ }) => {
88
+ return /* @__PURE__ */ React.createElement(
89
+ "span",
90
+ {
91
+ className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className),
92
+ ...props
93
+ }
94
+ );
95
+ };
96
+ CommandShortcut.displayName = "CommandShortcut";
97
+ export {
98
+ Command,
99
+ CommandDialog,
100
+ CommandInput,
101
+ CommandList,
102
+ CommandEmpty,
103
+ CommandGroup,
104
+ CommandItem,
105
+ CommandShortcut,
106
+ CommandSeparator
107
+ };
@@ -0,0 +1,43 @@
1
+ // ConfirmProvider / useConfirm: a confirmation dialog instead of window.confirm (UISPEC "Page templates"), shared by
2
+ // the Scalio apps (review GC3, BL-868; before 0.101.0 the same ConfirmContext.jsx in seven apps).
3
+ // <ConfirmProvider labels={{ cancel: t("Cancel"), confirm: t("Confirm") }}>…</ConfirmProvider>
4
+ // const confirm = useConfirm(); if (!(await confirm({ title, text, action, danger: true }))) return;
5
+ // Needs @radix-ui/react-alert-dialog like "@scalio-cloud/ui/shadcn/alert-dialog".
6
+ import * as React from "react";
7
+ import {
8
+ AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription,
9
+ AlertDialogFooter, AlertDialogHeader, AlertDialogTitle,
10
+ } from "./alert-dialog.mjs";
11
+ const h = React.createElement;
12
+ const ConfirmContext = React.createContext(null);
13
+ const DEFAULT_LABELS = { cancel: "Abbrechen", confirm: "Bestätigen" };
14
+ function ConfirmProvider({ children, labels }) {
15
+ const words = Object.assign({}, DEFAULT_LABELS, labels || {});
16
+ const [state, setState] = React.useState(null);
17
+ const resolver = React.useRef(null);
18
+ const confirm = React.useCallback((opts) => {
19
+ setState(opts || {});
20
+ return new Promise((resolve) => {
21
+ resolver.current = resolve;
22
+ });
23
+ }, []);
24
+ const close = (answer) => {
25
+ if (resolver.current) resolver.current(answer);
26
+ resolver.current = null;
27
+ setState(null);
28
+ };
29
+ return h(ConfirmContext.Provider, { value: confirm }, children,
30
+ h(AlertDialog, { open: !!state, onOpenChange: (open) => !open && close(false) },
31
+ h(AlertDialogContent, { className: "rounded-sm", "data-testid": "confirm-dialog" },
32
+ h(AlertDialogHeader, null,
33
+ h(AlertDialogTitle, { className: "font-display" }, state && state.title),
34
+ state && state.text ? h(AlertDialogDescription, null, state.text) : null),
35
+ h(AlertDialogFooter, null,
36
+ h(AlertDialogCancel, { className: "rounded-sm", "data-testid": "confirm-cancel" }, words.cancel),
37
+ h(AlertDialogAction, {
38
+ className: state && state.danger ? "rounded-sm bg-destructive text-destructive-foreground hover:bg-destructive/90" : "rounded-sm",
39
+ onClick: () => close(true), "data-testid": "confirm-ok",
40
+ }, (state && state.action) || words.confirm)))));
41
+ }
42
+ const useConfirm = () => React.useContext(ConfirmContext);
43
+ export { ConfirmProvider, useConfirm };