@scalio-cloud/ui 0.76.0 → 0.78.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/package.json +1 -1
- package/react/agents.js +62 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.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/agents.js
CHANGED
|
@@ -103,6 +103,9 @@ const LABELS = {
|
|
|
103
103
|
setNothing: "Keine Änderung.",
|
|
104
104
|
setSentAt: "Zuletzt gesendet: {at}",
|
|
105
105
|
setGate: "Schreibrecht",
|
|
106
|
+
setShared: "Gemeinsam",
|
|
107
|
+
setTitle: "Einstellungen · {name}",
|
|
108
|
+
setClose: "Schliessen",
|
|
106
109
|
updStates: { installing: "Wird aktualisiert auf {version}", verifying: "Prüft Version {version}", installed: "Aktualisiert auf {version}",
|
|
107
110
|
rolled_back: "Zurückgerollt auf {from} ({reason})", rollback_failed: "Rollback fehlgeschlagen ({reason})", failed: "Update fehlgeschlagen ({reason})",
|
|
108
111
|
refused: "Update abgelehnt ({reason})" },
|
|
@@ -195,6 +198,9 @@ const LABELS = {
|
|
|
195
198
|
setNothing: "No change.",
|
|
196
199
|
setSentAt: "Last sent: {at}",
|
|
197
200
|
setGate: "write permission",
|
|
201
|
+
setShared: "Shared",
|
|
202
|
+
setTitle: "Settings · {name}",
|
|
203
|
+
setClose: "Close",
|
|
198
204
|
updStates: { installing: "Updating to {version}", verifying: "Checking version {version}", installed: "Updated to {version}",
|
|
199
205
|
rolled_back: "Rolled back to {from} ({reason})", rollback_failed: "Rollback failed ({reason})", failed: "Update failed ({reason})",
|
|
200
206
|
refused: "Update refused ({reason})" },
|
|
@@ -272,8 +278,10 @@ function AgentSettings(props) {
|
|
|
272
278
|
const s = a.settings;
|
|
273
279
|
const [edit, setEdit] = React.useState({});
|
|
274
280
|
const [secrets, setSecrets] = React.useState({});
|
|
281
|
+
const [tab, setTab] = React.useState(null);
|
|
275
282
|
if (!s) return h("p", { className: "scalio-settings-text", "data-testid": `agent-settings-none-${a.id}` }, L.setNone);
|
|
276
283
|
const values = s.values || {};
|
|
284
|
+
const suggestions = (props.suggest && props.suggest(a)) || {};
|
|
277
285
|
const label = (d) => (d.label && (d.label[lang === "en" ? "en" : "de"] || d.label.de)) || d.name;
|
|
278
286
|
const hasGate = (s.catalog || []).some((d) => d.gate);
|
|
279
287
|
const current = (d) => (values[d.name] && values[d.name].source === "app" ? shownValue(d, values[d.name]) : "");
|
|
@@ -329,8 +337,13 @@ function AgentSettings(props) {
|
|
|
329
337
|
return h("select", Object.assign({}, common, { value: valueOf(d), onChange: (e) => set(d, e.target.value) }),
|
|
330
338
|
h("option", { value: "" }, L.setNotSet), opts.map(([k, t]) => h("option", { key: k, value: k }, t)));
|
|
331
339
|
}
|
|
332
|
-
|
|
333
|
-
|
|
340
|
+
const offer = d.kind === "text" ? (suggestions[d.name] || []).filter((x) => typeof x === "string" && x) : [];
|
|
341
|
+
const listId = offer.length ? `${tid}-choices` : undefined;
|
|
342
|
+
return [
|
|
343
|
+
h("input", Object.assign({}, common, { key: "i", type: d.kind === "number" ? "number" : "text", min: d.kind === "number" ? 1 : undefined,
|
|
344
|
+
maxLength: d.kind === "text" ? 1024 : undefined, list: listId, value: valueOf(d), onChange: (e) => set(d, e.target.value) })),
|
|
345
|
+
listId ? h("datalist", { key: "l", id: listId, "data-testid": `${tid}-choices` }, offer.map((o) => h("option", { key: o, value: o }))) : null,
|
|
346
|
+
];
|
|
334
347
|
};
|
|
335
348
|
const note = (d) => {
|
|
336
349
|
const v = values[d.name] || {};
|
|
@@ -339,20 +352,57 @@ function AgentSettings(props) {
|
|
|
339
352
|
return null;
|
|
340
353
|
};
|
|
341
354
|
|
|
342
|
-
|
|
355
|
+
// One tab per worker (Hyper-V, Proxmox, ...), settings of several workers on the tab «Gemeinsam» (Markus 2026-11-14).
|
|
356
|
+
const groupOf = (d) => ((d.workers || []).length === 1 ? d.workers[0] : "shared");
|
|
357
|
+
const groups = [];
|
|
358
|
+
(s.catalog || []).forEach((d) => { const g = groupOf(d); if (!groups.includes(g)) groups.push(g); });
|
|
359
|
+
groups.sort((x, y) => (x === "shared") - (y === "shared"));
|
|
360
|
+
const current_tab = groups.includes(tab) ? tab : groups[0];
|
|
361
|
+
const groupLabel = (g) => (g === "shared" ? L.setShared : (props.roleLabel ? props.roleLabel(g) : g));
|
|
362
|
+
|
|
363
|
+
return h("div", { "data-testid": `agent-settings-${a.id}`, style: { display: "grid", gap: "0.75rem" } },
|
|
343
364
|
hasGate && !s.remote_write ? h("div", { className: "scalio-notice is-info", role: "status", "data-testid": `agent-settings-nogate-${a.id}` },
|
|
344
365
|
h("div", { className: "scalio-notice-body" }, h("div", { className: "scalio-notice-text" }, L.setNoGate))) : null,
|
|
345
|
-
|
|
346
|
-
h("
|
|
347
|
-
|
|
366
|
+
groups.length > 1 ? h("div", { className: "scalio-tabs", role: "tablist", "aria-label": L.settings },
|
|
367
|
+
groups.map((g) => h("button", { key: g, type: "button", role: "tab", id: `agent-settings-tab-${a.id}-${g}`,
|
|
368
|
+
className: g === current_tab ? "scalio-tab is-active" : "scalio-tab", "aria-selected": g === current_tab ? "true" : "false",
|
|
369
|
+
"aria-controls": `agent-settings-panel-${a.id}-${g}`, "data-testid": `agent-settings-tab-${a.id}-${g}`, onClick: () => setTab(g) },
|
|
370
|
+
groupLabel(g)))) : null,
|
|
371
|
+
groups.map((g) => h("div", { key: g, role: groups.length > 1 ? "tabpanel" : undefined, id: `agent-settings-panel-${a.id}-${g}`,
|
|
372
|
+
"aria-labelledby": groups.length > 1 ? `agent-settings-tab-${a.id}-${g}` : undefined, hidden: g !== current_tab,
|
|
373
|
+
"data-testid": `agent-settings-panel-${a.id}-${g}`, style: { display: g === current_tab ? "grid" : "none", gap: "0.5rem" } },
|
|
374
|
+
(s.catalog || []).filter((d) => groupOf(d) === g).map((d) => h("div", { key: d.name, style: { display: "grid", gridTemplateColumns: "minmax(12rem, 1fr) minmax(12rem, 2fr)", gap: "0.5rem", alignItems: "center" } },
|
|
375
|
+
h("label", { htmlFor: `agent-setting-${a.id}-${d.name}` }, label(d), d.gate ? h("span", { className: "scalio-settings-text" }, ` (${L.setGate})`) : null),
|
|
376
|
+
h("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center", flexWrap: "wrap" } }, input(d), note(d)))))),
|
|
348
377
|
h("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center", flexWrap: "wrap" } },
|
|
349
378
|
h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy || a.blocked, "data-testid": `agent-settings-save-${a.id}`, onClick: save },
|
|
350
379
|
h(Icons.Settings, { className: "scalio-icon" }), L.setSave),
|
|
351
380
|
a.settings_sent_at ? h("span", { className: "scalio-settings-text" }, fill(L.setSentAt, { at: when(a.settings_sent_at, lang) })) : null));
|
|
352
381
|
}
|
|
353
382
|
|
|
383
|
+
// The settings of one agent as a dialog (Markus 2026-11-14): closes with its button, the backdrop and Escape.
|
|
384
|
+
function SettingsDialog(props) {
|
|
385
|
+
const { agent: a, L, onClose } = props;
|
|
386
|
+
React.useEffect(() => {
|
|
387
|
+
const key = (e) => { if (e.key === "Escape") onClose(); };
|
|
388
|
+
document.addEventListener("keydown", key);
|
|
389
|
+
return () => document.removeEventListener("keydown", key);
|
|
390
|
+
}, [onClose]);
|
|
391
|
+
const title = fill(L.setTitle, { name: a.name || a.hostname || a.id });
|
|
392
|
+
return h("div", { className: "scalio-dialog-root" },
|
|
393
|
+
h("div", { className: "scalio-dialog-backdrop", onClick: onClose }),
|
|
394
|
+
h("div", { className: "scalio-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, style: { maxWidth: "52rem" },
|
|
395
|
+
"data-testid": `agent-settings-dialog-${a.id}` },
|
|
396
|
+
h("div", { className: "scalio-dialog-head" },
|
|
397
|
+
h("div", { className: "scalio-dialog-title" }, title),
|
|
398
|
+
h("button", { type: "button", className: "scalio-btn is-ghost scalio-btn-icon", onClick: onClose, "aria-label": L.setClose,
|
|
399
|
+
title: L.setClose, "data-testid": `agent-settings-close-${a.id}` }, h(Icons.X, { className: "scalio-icon" }))),
|
|
400
|
+
h("div", { className: "scalio-dialog-body" }, props.children)));
|
|
401
|
+
}
|
|
402
|
+
|
|
354
403
|
// Props: client (agentsApi), lang, labels, appUrl (address the agent connects to, default window.location.origin),
|
|
355
|
-
// downloadUrl (MSI), notify(message, tone), formatError(err), refreshMs (default 15000, 0 = off), copy(text)
|
|
404
|
+
// downloadUrl (MSI), notify(message, tone), formatError(err), refreshMs (default 15000, 0 = off), copy(text),
|
|
405
|
+
// suggest(agent) -> {SettingName: [values]} (choices the app read, e.g. switches or OUs; any other value stays possible).
|
|
356
406
|
function AgentsPanel(props) {
|
|
357
407
|
const L = labels(props.lang, props.labels);
|
|
358
408
|
const fmtErr = props.formatError || errorText;
|
|
@@ -584,8 +634,11 @@ function AgentsPanel(props) {
|
|
|
584
634
|
: h("div", { style: { overflowX: "auto" } },
|
|
585
635
|
h("table", { className: "scalio-users-table", "data-testid": "agents-table" },
|
|
586
636
|
h("thead", null, h("tr", null, [L.name, L.host, L.version, L.status, L.roles, L.workers, ""].map((t, i) => h("th", { key: i }, t)))),
|
|
587
|
-
h("tbody", null, agents.map((a) =>
|
|
588
|
-
|
|
637
|
+
h("tbody", null, agents.map((a) => agentRow(a)))))));
|
|
638
|
+
const openAgent = agents.find((a) => a.id === open);
|
|
639
|
+
if (openAgent) rows.push(h(SettingsDialog, { key: "settings-dialog", agent: openAgent, L, onClose: () => setOpen(null) },
|
|
640
|
+
h(AgentSettings, { agent: openAgent, L, lang: props.lang, busy, client: props.client, run, notify: props.notify,
|
|
641
|
+
suggest: props.suggest, roleLabel })));
|
|
589
642
|
|
|
590
643
|
// tasks
|
|
591
644
|
const nameOf = (id) => (agents.find((a) => a.id === id) || {}).name || "";
|