@scalio-cloud/ui 0.47.0 → 0.48.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
@@ -419,6 +419,22 @@ inside its own `<form>`, not with a modifier, not while Weiter is blocked). Each
419
419
  field, else on Weiter; Tab stays inside the wizard; Escape closes it (when it may be closed). An app with its own
420
420
  step dialog uses `enterMeansNext(event.target)` for the same Enter rule.
421
421
 
422
+ ## Dialogs instead of browser popups (React, from 0.48.0)
423
+
424
+ No `alert`, `confirm` or `prompt` in the apps (scalio-docs ADR 0096). Use the promise dialogs; they mount
425
+ themselves, no provider needed, keyboard as ADR 0095 (focus on OK or the field, Enter confirms, Escape cancels):
426
+
427
+ ```js
428
+ import { askConfirm, askText, showMessage } from "@scalio-cloud/ui/react";
429
+ if (!(await askConfirm({ title: "Benutzer löschen", text: "Das lässt sich nicht rückgängig machen.", confirmLabel: "Löschen", danger: true }))) return;
430
+ const name = await askText({ title: "Umbenennen", label: "Neuer Name", value: old, required: true }); // null on Abbrechen
431
+ await showMessage({ title: "Gespeichert", text: "Alles da." });
432
+ ```
433
+
434
+ Test IDs: `confirm-dialog`, `confirm-dialog-ok`, `confirm-dialog-cancel`, `confirm-dialog-input`. `SaasUpdatesPanel` asks
435
+ with `askConfirm` and then shows `UpdateProgress` (`saas-update-progress`): it polls `/version.json` (props
436
+ `versionUrl`, `checkVersion`, `pollMs` 5 s, `timeoutMs` 20 min) and reloads the page once the new version runs.
437
+
422
438
  ## Two-factor card and license panel (React)
423
439
 
424
440
  The same backend routes in every app, so the apps pass only their axios instance and a few helpers.
package/nav.css CHANGED
@@ -834,3 +834,23 @@
834
834
  /* Einstellungen -> Sicherung (BackupPanel, ADR 0069 W5) */
835
835
  .scalio-notice > ul, .scalio-notice-body > ul { margin: 0; padding-left: 1.25rem; }
836
836
  ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; list-style: disc; }
837
+
838
+ /* Dialogs instead of browser popups (ADR 0096): askConfirm, askText, showMessage, UpdateProgress. */
839
+ .scalio-dialog-root { z-index: 70; }
840
+ .scalio-dialog {
841
+ display: flex; flex-direction: column; gap: 0.75rem; width: calc(100vw - 2rem); max-width: 28rem; max-height: 90vh; overflow-y: auto;
842
+ padding: 1.5rem; border: 1px solid hsl(var(--border)); border-radius: 2px; background: hsl(var(--background)); color: hsl(var(--foreground));
843
+ box-shadow: 0 16px 40px rgb(0 0 0 / 0.25); font-size: 0.875rem;
844
+ }
845
+ .scalio-dialog:focus { outline: none; }
846
+ .scalio-dialog-title { margin: 0; font-family: 'Chivo', sans-serif; font-size: 1rem; font-weight: 800; }
847
+ .scalio-dialog-text { margin: 0; color: hsl(var(--muted-foreground)); white-space: pre-line; }
848
+ .scalio-dialog-field { display: flex; flex-direction: column; gap: 0.375rem; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
849
+ .scalio-dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
850
+ .scalio-btn.is-danger { border-color: hsl(var(--destructive)); background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground, 0 0% 100%)); }
851
+ .scalio-btn.is-danger:hover { background: hsl(var(--destructive) / 0.9); }
852
+ .scalio-progress-steps { display: flex; flex-direction: column; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
853
+ .scalio-progress-step { display: flex; align-items: center; gap: 0.5rem; color: hsl(var(--muted-foreground)); }
854
+ .scalio-progress-step.is-active, .scalio-progress-step.is-done { color: hsl(var(--foreground)); }
855
+ .scalio-progress-step.is-done .scalio-icon { color: #059669; }
856
+ .scalio-progress-dot { width: 0.875rem; height: 0.875rem; border: 2px solid hsl(var(--border)); border-radius: 999px; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.47.0",
3
+ "version": "0.48.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/backup.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // Einstellungen -> System -> Sicherung (ADR 0069 wartung/W5; after Nexus BackupSection and ImportSection).
3
3
  // Backend: scalio-backup `web.backup_router` (GET /api/backup/status, POST /api/backup/export, /api/backup/import/...).
4
4
  const React = require("react");
5
+ const { askConfirm } = require("./dialog");
5
6
  const h = React.createElement;
6
7
  const Icons = require("./icons");
7
8
  const { labelsFor } = require("./labels");
@@ -399,7 +400,7 @@ function BackupImport(props) {
399
400
  };
400
401
 
401
402
  const undo = async () => {
402
- if (!window.confirm(L.rollbackConfirm)) return;
403
+ if (!(await askConfirm({ text: L.rollbackConfirm, danger: true, lang: props.lang }))) return;
403
404
  setBusy(true);
404
405
  n.clear();
405
406
  try {
package/react/beacon.js CHANGED
@@ -4,6 +4,7 @@
4
4
  // Verbundene Apps); findings then go to Beacon and become tickets. Backend routes from scalio-connect
5
5
  // (`scalio_connect.peers.web.admin_router`); peersApi(api) maps them for an axios-like client.
6
6
  const React = require("react");
7
+ const { askConfirm } = require("./dialog");
7
8
  const h = React.createElement;
8
9
  const { labelsFor } = require("./labels");
9
10
 
@@ -93,7 +94,7 @@ function BeaconConnection({ client, lang, labels, onChange }) {
93
94
  h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "beacon-check",
94
95
  onClick: () => run(() => client.check(p.id), (d) => L.beaconChecked.replace("{version}", (d && d.version) || "")) }, L.supportCheck),
95
96
  h("button", { type: "button", className: "scalio-btn scalio-btn-danger", disabled: busy, "data-testid": "beacon-remove",
96
- onClick: () => (typeof window === "undefined" || window.confirm(L.beaconRemoveConfirm)) && run(() => client.remove(p.id), L.supportRemoved) },
97
+ onClick: async () => (await askConfirm({ text: L.beaconRemoveConfirm, danger: true, lang })) && run(() => client.remove(p.id), L.supportRemoved) },
97
98
  L.supportRemove))
98
99
  );
99
100
  }),
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ // Proper dialogs instead of browser popups (Markus 2026-11-07, scalio-docs ADR 0096): askConfirm replaces the
3
+ // browser's confirm, askText its prompt, showMessage its alert. Each returns a Promise, so a call site changes
4
+ // from `if (!confirm(t)) return;` to `if (!(await askConfirm({ text: t }))) return;`.
5
+ // The dialog mounts itself into document.body on first use; apps need no provider. Keyboard as ADR 0095: the focus
6
+ // starts on OK (or the text field), Enter confirms, Escape cancels, Tab stays inside.
7
+
8
+ const React = require("react");
9
+ const { labelsFor } = require("./labels");
10
+ const { trapTab } = require("./wizard");
11
+
12
+ const h = React.createElement;
13
+
14
+ const queue = [];
15
+ let notify = null; // set by the mounted host
16
+ let host = null;
17
+
18
+ function mountHost() {
19
+ if (notify || host || typeof document === "undefined") return;
20
+ const { createRoot } = require("react-dom/client");
21
+ host = document.createElement("div");
22
+ host.setAttribute("data-scalio-dialog-host", "");
23
+ document.body.appendChild(host);
24
+ createRoot(host).render(h(DialogHost));
25
+ }
26
+
27
+ function ask(kind, opts) {
28
+ return new Promise((resolve) => {
29
+ queue.push({ kind, opts: opts || {}, resolve });
30
+ mountHost();
31
+ if (notify) notify();
32
+ });
33
+ }
34
+
35
+ const askConfirm = (opts) => ask("confirm", typeof opts === "string" ? { text: opts } : opts);
36
+ const askText = (opts) => ask("text", typeof opts === "string" ? { label: opts } : opts);
37
+ const showMessage = (opts) => ask("message", typeof opts === "string" ? { text: opts } : opts);
38
+
39
+ function pageLang() {
40
+ const l = typeof document !== "undefined" && document.documentElement ? document.documentElement.lang : "";
41
+ return /^en/i.test(l || "") ? "en" : "de";
42
+ }
43
+
44
+ function DialogHost() {
45
+ const [, setN] = React.useState(0);
46
+ React.useEffect(() => {
47
+ notify = () => setN((n) => n + 1);
48
+ if (queue.length) notify();
49
+ return () => { notify = null; };
50
+ }, []);
51
+ const item = queue[0];
52
+ if (!item) return null;
53
+ const done = (value) => {
54
+ queue.shift();
55
+ item.resolve(value);
56
+ setN((n) => n + 1);
57
+ };
58
+ return h(ConfirmDialog, Object.assign({ key: queue.length + ":" + (item.opts.text || item.opts.label || "") }, item.opts, {
59
+ kind: item.kind,
60
+ onDone: done,
61
+ }));
62
+ }
63
+
64
+ function ConfirmDialog(props) {
65
+ const { kind, title, text, label, placeholder, danger, required, onDone } = props;
66
+ const L = Object.assign({}, labelsFor(props.lang || pageLang()).dialog);
67
+ const [value, setValue] = React.useState(props.value == null ? "" : String(props.value));
68
+ const panel = React.useRef(null);
69
+ const okRef = React.useRef(null);
70
+ const inputRef = React.useRef(null);
71
+ const blocked = kind === "text" && required && !value.trim();
72
+ const cancelValue = kind === "confirm" ? false : kind === "text" ? null : undefined;
73
+ const ok = () => { if (!blocked) onDone(kind === "confirm" ? true : kind === "text" ? value.trim() : undefined); };
74
+ const cancel = () => onDone(cancelValue);
75
+
76
+ React.useEffect(() => {
77
+ const before = document.activeElement;
78
+ const first = inputRef.current || okRef.current;
79
+ if (first) first.focus();
80
+ return () => { if (before && typeof before.focus === "function" && document.contains(before)) before.focus(); };
81
+ }, []);
82
+
83
+ function onKeyDown(e) {
84
+ if (e.key === "Tab") return trapTab(e, panel.current);
85
+ if (e.key === "Escape") { e.preventDefault(); cancel(); return; }
86
+ if (e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
87
+ const tag = e.target && e.target.tagName ? e.target.tagName.toLowerCase() : "";
88
+ if (tag === "button" && e.target !== okRef.current) return; // Abbrechen keeps its own Enter
89
+ e.preventDefault();
90
+ ok();
91
+ }
92
+ }
93
+
94
+ const titleId = "scalio-dialog-title";
95
+ return h(
96
+ "div",
97
+ { className: "scalio-wizard-root scalio-dialog-root", onMouseDown: (e) => { if (e.target === e.currentTarget) cancel(); } },
98
+ h(
99
+ "div",
100
+ {
101
+ ref: panel, onKeyDown, tabIndex: -1,
102
+ role: kind === "message" ? "dialog" : "alertdialog", "aria-modal": "true",
103
+ "aria-labelledby": title ? titleId : undefined, "aria-label": title ? undefined : (text || label || L.confirm),
104
+ className: "scalio-dialog", "data-testid": "confirm-dialog",
105
+ },
106
+ title ? h("h2", { id: titleId, className: "scalio-dialog-title" }, title) : null,
107
+ text ? h("p", { className: "scalio-dialog-text" }, text) : null,
108
+ kind === "text"
109
+ ? h("label", { className: "scalio-dialog-field" },
110
+ label ? h("span", null, label) : null,
111
+ h("input", {
112
+ ref: inputRef, className: "scalio-input", value, placeholder, "data-testid": "confirm-dialog-input",
113
+ "aria-label": label || L.input,
114
+ onChange: (e) => setValue(e.target.value), onInput: (e) => setValue(e.target.value),
115
+ }))
116
+ : null,
117
+ h(
118
+ "div",
119
+ { className: "scalio-dialog-actions" },
120
+ kind === "message" ? null : h("button", { type: "button", className: "scalio-btn", onClick: cancel, "data-testid": "confirm-dialog-cancel" }, props.cancelLabel || L.cancel),
121
+ h("button", {
122
+ ref: okRef, type: "button", disabled: blocked,
123
+ className: danger ? "scalio-btn is-danger" : "scalio-btn is-primary",
124
+ onClick: ok, "data-testid": "confirm-dialog-ok",
125
+ }, props.confirmLabel || L.ok)
126
+ )
127
+ )
128
+ );
129
+ }
130
+
131
+ module.exports = { askConfirm, askText, showMessage, ConfirmDialog, DialogHost };
package/react/index.js CHANGED
@@ -378,6 +378,6 @@ module.exports = {
378
378
  TEST_IDS,
379
379
  initials,
380
380
  };
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"), require("./fields"));
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"), require("./fields"), require("./dialog"));
382
382
  // After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
383
383
  Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./clientErrors"));
package/react/labels.js CHANGED
@@ -13,6 +13,7 @@ const LABELS = {
13
13
  userMenu: "Benutzermenü",
14
14
  menu: "Menü",
15
15
  version: "Version",
16
+ dialog: { ok: "OK", cancel: "Abbrechen", confirm: "Bestätigen", input: "Eingabe" },
16
17
  wizard: {
17
18
  step: "Schritt {n} von {total}",
18
19
  back: "Zurück",
@@ -576,6 +577,7 @@ const LABELS = {
576
577
  userMenu: "User menu",
577
578
  menu: "Menu",
578
579
  version: "Version",
580
+ dialog: { ok: "OK", cancel: "Cancel", confirm: "Confirm", input: "Input" },
579
581
  wizard: {
580
582
  step: "Step {n} of {total}",
581
583
  back: "Back",
package/react/license.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // licenseApi(api) maps the routes of the scalio-license backend (Citadel, Foundry, Rosetta); mapScalioLicense turns its
4
4
  // answer into the view model the panel shows. An app with another backend passes its own `client` and `map`.
5
5
  const React = require("react");
6
+ const { askConfirm } = require("./dialog");
6
7
  const h = React.createElement;
7
8
  const Icons = require("./icons");
8
9
  const { labelsFor } = require("./labels");
@@ -158,7 +159,7 @@ function LicensePanel(props) {
158
159
  };
159
160
  const remove = async () => {
160
161
  const title = fill(L.removeConfirm, { product: props.product || "Scalio" });
161
- const yes = confirm ? await confirm({ title, action: L.remove, danger: true }) : window.confirm(title);
162
+ const yes = confirm ? await confirm({ title, action: L.remove, danger: true }) : await askConfirm({ title, confirmLabel: L.remove, danger: true });
162
163
  if (yes) run(() => client.removeKey(lang), L.removed);
163
164
  };
164
165
  const addAddon = async () => {
package/react/roles.js CHANGED
@@ -6,6 +6,7 @@
6
6
  // person's role is marked. RoleSourceSettings is the role source (Scalio app or Entra app roles) with the Entra values
7
7
  // and the list of tenants whose roles count, with «Tenant hinzufügen» by admin consent (ADR 0068).
8
8
  const React = require("react");
9
+ const { askConfirm } = require("./dialog");
9
10
  const h = React.createElement;
10
11
  const Icons = require("./icons");
11
12
 
@@ -193,7 +194,7 @@ function rolesApi(api, opts) {
193
194
 
194
195
  async function ask(confirm, title, text, action, danger) {
195
196
  if (confirm) return !!(await confirm({ title, text, action, danger: danger !== false }));
196
- return typeof window !== "undefined" && window.confirm ? window.confirm(title) : true;
197
+ return askConfirm({ title, text, confirmLabel: action, danger: danger !== false });
197
198
  }
198
199
 
199
200
  function Dialog({ title, onClose, children, testId }) {
@@ -8,6 +8,8 @@ const h = React.createElement;
8
8
  const Icons = require("./icons");
9
9
  const { Notice } = require("./blocks");
10
10
  const { SettingsSection, SettingsField: Field } = require("./settings");
11
+ const { askConfirm } = require("./dialog");
12
+ const { trapTab } = require("./wizard");
11
13
 
12
14
  const LABELS = {
13
15
  de: {
@@ -32,6 +34,15 @@ const LABELS = {
32
34
  forced: "Scalio hat den Termin festgelegt.",
33
35
  now: "Jetzt aktualisieren",
34
36
  nowConfirm: "Version {version} jetzt installieren? Die Anwendung ist einige Minuten nicht erreichbar.",
37
+ nowGo: "Jetzt installieren",
38
+ progressTitle: "Update läuft",
39
+ progressText: "Version {version} wird installiert. Die Anwendung ist dabei einige Minuten nicht erreichbar. Diese Seite lädt neu, sobald die neue Version läuft.",
40
+ progressAsked: "Update angefordert",
41
+ progressInstall: "Neue Version wird installiert",
42
+ progressDone: "Version {version} läuft, die Seite wird neu geladen.",
43
+ progressSlow: "Das Update dauert länger als erwartet. Laden Sie die Seite später neu oder prüfen Sie den Stand unter Einstellungen → Updates.",
44
+ progressReload: "Seite neu laden",
45
+ progressClose: "Im Hintergrund weiterlaufen lassen",
35
46
  postpone: "Verschieben bis",
36
47
  postponeGo: "Verschieben",
37
48
  mode: "Verhalten",
@@ -76,6 +87,15 @@ const LABELS = {
76
87
  forced: "Scalio has set the date.",
77
88
  now: "Update now",
78
89
  nowConfirm: "Install version {version} now? The application is unavailable for a few minutes.",
90
+ nowGo: "Install now",
91
+ progressTitle: "Update running",
92
+ progressText: "Version {version} is being installed. The application is unavailable for a few minutes. This page reloads as soon as the new version runs.",
93
+ progressAsked: "Update requested",
94
+ progressInstall: "Installing the new version",
95
+ progressDone: "Version {version} is running, reloading the page.",
96
+ progressSlow: "The update takes longer than expected. Reload the page later or check Settings → Updates.",
97
+ progressReload: "Reload page",
98
+ progressClose: "Keep running in the background",
79
99
  postpone: "Postpone until",
80
100
  postponeGo: "Postpone",
81
101
  mode: "Behaviour",
@@ -171,6 +191,73 @@ function UpdateBanner(props) {
171
191
 
172
192
  const EMPTY_WINDOW = { days: [], start: "02:00", hours: 3, tz: "Europe/Zurich" };
173
193
 
194
+ // The running version as the instance itself reports it (/version.json of the frontend image, ADR 0074).
195
+ async function fetchVersion(url) {
196
+ const r = await fetch(`${url || "/version.json"}?t=${Date.now()}`, { cache: "no-store" });
197
+ if (!r.ok) throw new Error(`HTTP ${r.status}`);
198
+ const d = await r.json();
199
+ return (d && d.version) || "";
200
+ }
201
+
202
+ // After «Jetzt aktualisieren» (Markus 2026-11-07): a dialog that checks in the background until the new version
203
+ // runs and then reloads the page. While the instance is down the check fails; that only means «still installing».
204
+ // Props: version (target), from (version before), lang, labels, checkVersion(), pollMs, timeoutMs, reload(), onClose().
205
+ function UpdateProgress(props) {
206
+ const L = labels(props.lang, props.labels);
207
+ const [phase, setPhase] = React.useState("install"); // install | done | slow
208
+ const panel = React.useRef(null);
209
+ const reload = props.reload || (() => window.location.reload());
210
+ React.useEffect(() => {
211
+ let alive = true;
212
+ let timer = null;
213
+ const started = Date.now();
214
+ const pollMs = props.pollMs || 5000;
215
+ const timeoutMs = props.timeoutMs || 20 * 60 * 1000;
216
+ const check = props.checkVersion || (() => fetchVersion(props.versionUrl));
217
+ const norm = (v) => String(v || "").replace(/^v/, "");
218
+ const round = async () => {
219
+ let v = "";
220
+ try { v = await check(); } catch (e) { v = ""; }
221
+ if (!alive) return;
222
+ const now = norm(v);
223
+ if (now && (now === norm(props.version) || (props.from && now !== norm(props.from)))) {
224
+ setPhase("done");
225
+ timer = setTimeout(() => { if (alive) reload(); }, props.reloadDelayMs == null ? 1500 : props.reloadDelayMs);
226
+ return;
227
+ }
228
+ if (Date.now() - started >= timeoutMs) { setPhase("slow"); return; }
229
+ timer = setTimeout(round, pollMs);
230
+ };
231
+ timer = setTimeout(round, pollMs);
232
+ return () => { alive = false; clearTimeout(timer); };
233
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
234
+ React.useEffect(() => { if (panel.current) panel.current.focus(); }, []);
235
+
236
+ const step = (done, active, text) => h("li", { className: `scalio-progress-step${done ? " is-done" : ""}${active ? " is-active" : ""}` },
237
+ done ? h(Icons.Check, { className: "scalio-icon" }) : active ? h("span", { className: "scalio-spinner", "aria-hidden": "true" }) : h("span", { className: "scalio-progress-dot" }),
238
+ h("span", null, text));
239
+ return h("div", { className: "scalio-wizard-root scalio-dialog-root" },
240
+ h("div", {
241
+ ref: panel, tabIndex: -1, role: "dialog", "aria-modal": "true", "aria-labelledby": "scalio-update-progress-title",
242
+ "aria-busy": phase === "install" ? "true" : "false", className: "scalio-dialog", "data-testid": "saas-update-progress",
243
+ onKeyDown: (e) => { if (e.key === "Tab") trapTab(e, panel.current); else if (e.key === "Escape" && props.onClose) props.onClose(); },
244
+ },
245
+ h("h2", { id: "scalio-update-progress-title", className: "scalio-dialog-title" }, L.progressTitle),
246
+ h("p", { className: "scalio-dialog-text" }, fill(L.progressText, { version: props.version })),
247
+ h("ol", { className: "scalio-progress-steps", "aria-live": "polite" },
248
+ step(true, false, L.progressAsked),
249
+ step(phase !== "install", phase === "install", L.progressInstall),
250
+ phase === "done" ? step(true, false, fill(L.progressDone, { version: props.version })) : null),
251
+ phase === "slow" ? h("div", { className: "scalio-notice is-warn", role: "status" }, L.progressSlow) : null,
252
+ h("div", { className: "scalio-dialog-actions" },
253
+ props.onClose && phase !== "done"
254
+ ? h("button", { type: "button", className: "scalio-btn is-ghost", onClick: props.onClose, "data-testid": "saas-update-progress-close" }, L.progressClose)
255
+ : null,
256
+ phase === "slow"
257
+ ? h("button", { type: "button", className: "scalio-btn is-primary", onClick: reload, "data-testid": "saas-update-progress-reload" }, L.progressReload)
258
+ : null)));
259
+ }
260
+
174
261
  // Props: client (saasUpdatesApi), lang, labels, notify(message, tone), formatError(err).
175
262
  function SaasUpdatesPanel(props) {
176
263
  const L = labels(props.lang, props.labels);
@@ -180,6 +267,7 @@ function SaasUpdatesPanel(props) {
180
267
  const [error, setError] = React.useState("");
181
268
  const [until, setUntil] = React.useState("");
182
269
  const [win, setWin] = React.useState(EMPTY_WINDOW);
270
+ const [updating, setUpdating] = React.useState(null); // {version, from} while the progress dialog is open
183
271
 
184
272
  const take = (d) => {
185
273
  setSt(d);
@@ -194,15 +282,24 @@ function SaasUpdatesPanel(props) {
194
282
  const act = async (op, body) => {
195
283
  setBusy(true);
196
284
  setError("");
285
+ let ok = false;
197
286
  try {
198
287
  take(await props.client.act(op, body));
199
- if (props.notify) props.notify(L.saved, "ok");
288
+ if (props.notify && op !== "now") props.notify(L.saved, "ok");
289
+ ok = true;
200
290
  } catch (e) {
201
291
  const t = fmtErr(e);
202
292
  if (props.notify) props.notify(t, "error");
203
293
  setError(t);
204
294
  }
205
295
  setBusy(false);
296
+ return ok;
297
+ };
298
+ const updateNow = async (offer) => {
299
+ const yes = await askConfirm({ title: L.now, text: fill(L.nowConfirm, { version: offer.version }), confirmLabel: L.nowGo, lang: props.lang });
300
+ if (!yes) return;
301
+ const from = st && st.current_version;
302
+ if (await act("now")) setUpdating({ version: offer.version, from });
206
303
  };
207
304
 
208
305
  if (!st) return h(SettingsSection, { id: "updates", title: L.title, description: L.hint, testId: "saas-updates" },
@@ -228,7 +325,7 @@ function SaasUpdatesPanel(props) {
228
325
  if (!offer.forced) {
229
326
  rows.push(h("div", { key: "acts", className: "scalio-settings-section-footer" },
230
327
  h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy || offer.held, "data-testid": "saas-updates-now",
231
- onClick: () => { if (window.confirm(fill(L.nowConfirm, { version: offer.version }))) act("now"); } },
328
+ onClick: () => updateNow(offer) },
232
329
  h(Icons.Download, { className: "scalio-icon" }), L.now)));
233
330
  rows.push(h(Field, { key: "post", id: "saas-updates-until", label: L.postpone },
234
331
  h("div", { style: { display: "flex", gap: "0.5rem" } },
@@ -264,6 +361,11 @@ function SaasUpdatesPanel(props) {
264
361
  h("div", { className: "scalio-settings-text", "data-testid": "saas-updates-last" },
265
362
  fill(st.last.state === "done" ? L.lastDone : L.lastError, { version: st.last.version, at: when(st.last.at, props.lang) }))));
266
363
  if (error) rows.push(h("div", { key: "err", className: "scalio-notice is-error", role: "alert", "data-testid": "saas-updates-error" }, error));
364
+ if (updating) rows.push(h(UpdateProgress, {
365
+ key: "progress", version: updating.version, from: updating.from, lang: props.lang, labels: props.labels,
366
+ checkVersion: props.checkVersion, versionUrl: props.versionUrl, pollMs: props.pollMs, timeoutMs: props.timeoutMs,
367
+ reloadDelayMs: props.reloadDelayMs, reload: props.reload, onClose: () => setUpdating(null),
368
+ }));
267
369
  return h(SettingsSection, { id: "updates", title: L.title, description: L.hint, testId: "saas-updates" }, rows);
268
370
  }
269
371
 
@@ -271,4 +373,4 @@ function cxNotice(offer) {
271
373
  return `scalio-notice ${offer.kind === "security" ? "is-warn" : "is-info"}`;
272
374
  }
273
375
 
274
- module.exports = { UpdateBanner, SaasUpdatesPanel, saasUpdatesApi, SAAS_UPDATE_LABELS: LABELS };
376
+ module.exports = { UpdateBanner, SaasUpdatesPanel, UpdateProgress, saasUpdatesApi, SAAS_UPDATE_LABELS: LABELS };
package/react/security.js CHANGED
@@ -5,6 +5,7 @@
5
5
  // answers. Every change asks for the current password inline. No runtime dependencies: the app passes the QR
6
6
  // code renderer (`qr`) and the WebAuthn helpers from @simplewebauthn/browser.
7
7
  const React = require("react");
8
+ const { askConfirm } = require("./dialog");
8
9
  const h = React.createElement;
9
10
  const Icons = require("./icons");
10
11
  const { labelsFor } = require("./labels");
@@ -83,7 +84,7 @@ function securityApi(api, webauthn) {
83
84
 
84
85
  async function ask(confirm, title, action) {
85
86
  if (confirm) return !!(await confirm({ title, action, danger: true }));
86
- return typeof window !== "undefined" && window.confirm ? window.confirm(title) : true;
87
+ return askConfirm({ title, confirmLabel: action, danger: true });
87
88
  }
88
89
 
89
90
  function Field({ id, label, children }) {
package/react/support.js CHANGED
@@ -8,6 +8,7 @@
8
8
  // scalio_connect.support.ideas_web): ideas of this app with votes and comments, and "Idee vorschlagen" with similar
9
9
  // ideas shown while typing. The category "Wunsch" then leaves the ticket form.
10
10
  const React = require("react");
11
+ const { askConfirm } = require("./dialog");
11
12
  const h = React.createElement;
12
13
  const { labelsFor } = require("./labels");
13
14
 
@@ -553,7 +554,7 @@ function SupportConnection({ client, lang, labels, onChange }) {
553
554
  h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "support-connection-check",
554
555
  onClick: () => run(() => client.check(), L.supportChecked) }, L.supportCheck),
555
556
  h("button", { type: "button", className: "scalio-btn scalio-btn-danger", disabled: busy, "data-testid": "support-connection-remove",
556
- onClick: () => (typeof window === "undefined" || window.confirm(L.supportRemoveConfirm)) && run(() => client.disconnect(), L.supportRemoved) },
557
+ onClick: async () => (await askConfirm({ text: L.supportRemoveConfirm, danger: true, lang })) && run(() => client.disconnect(), L.supportRemoved) },
557
558
  L.supportRemove)
558
559
  )
559
560
  : h(
package/react/users.js CHANGED
@@ -5,6 +5,7 @@
5
5
  // account, the actions (start password, second factor, Microsoft link, lock, delete) and approving or merging a
6
6
  // waiting Microsoft account. MicrosoftConnection is the profile card to link one's own Microsoft account.
7
7
  const React = require("react");
8
+ const { askConfirm } = require("./dialog");
8
9
  const h = React.createElement;
9
10
  const Icons = require("./icons");
10
11
  const { labelsFor } = require("./labels");
@@ -93,7 +94,7 @@ function usersApi(api, opts) {
93
94
 
94
95
  async function ask(confirm, title, text, action, danger) {
95
96
  if (confirm) return !!(await confirm({ title, text, action, danger: danger !== false }));
96
- return typeof window !== "undefined" && window.confirm ? window.confirm(title) : true;
97
+ return askConfirm({ title, text, confirmLabel: action, danger: danger !== false });
97
98
  }
98
99
 
99
100
  function Field({ id, label, hint, children }) {
package/react/wizard.js CHANGED
@@ -299,4 +299,4 @@ function SetupWizardButton({ lang, labels, testId, className }) {
299
299
  return h("button", { type: "button", className: className || "scalio-btn", onClick: () => openSetupWizard(0), "data-testid": testId || "settings-open-wizard", title: L.openHint }, L.open);
300
300
  }
301
301
 
302
- module.exports = { SetupWizard, SetupWizardButton, useSetupWizard, setupWizardApi, normalizeWizardState, openSetupWizard, OPEN_SETUP_WIZARD, enterMeansNext };
302
+ module.exports = { SetupWizard, SetupWizardButton, useSetupWizard, setupWizardApi, normalizeWizardState, openSetupWizard, OPEN_SETUP_WIZARD, enterMeansNext, trapTab };