@scalio-cloud/ui 0.74.0 → 0.76.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
@@ -620,6 +620,15 @@ Since 0.65.0 (scripts from the app U3, scalio-platform 0.40.0) every agent shows
620
620
  current}`: «aktuell» or «werden aktualisiert») and «Passwörter verschlüsselt» when it reported an encryption key
621
621
  (`sealed`). Test ID `agent-scripts-<id>`.
622
622
 
623
+ Since 0.75.0 (settings from the app, scalio-docs ADR 0122, scalio-platform 0.47.0) «Einstellungen» opens a form per
624
+ agent, built from the catalog the agent reports (`settings.catalog`: text, number, on/off, choice, secret). Only changed
625
+ values go to `PUT /agents/{id}/settings` (`client.setSettings`); an empty field deletes the app's value. A value set on
626
+ the server shows «lokal gesetzt» and cannot be changed; a write switch shows «wartet auf die Freigabe beim Kunden»
627
+ until the customer has set `RemoteWrite`, and a notice explains how. A secret is a password field, never shown, sent
628
+ only to an agent with a seal key (`sealed`). Test IDs: `agent-settings-open-<id>`, `agent-settings-<id>`,
629
+ `agent-setting-<id>-<name>`, `agent-setting-local|pending-<id>-<name>`, `agent-settings-save-<id>`,
630
+ `agent-settings-none-<id>`, `agent-settings-nogate-<id>`.
631
+
623
632
  ### Scripts des Agents (U5)
624
633
 
625
634
  Since 0.66.0 (customer customizations U5, scalio-platform 0.41.0) `AgentScriptsPanel` shows every script the app
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.74.0",
3
+ "version": "0.76.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
@@ -3,7 +3,8 @@
3
3
  // for admins. Backend: scalio-platform `agent.AgentHub.router` (GET /agent/v2/admin/agents, PATCH /agents/{id},
4
4
  // POST /agents/{id}/block|unblock, DELETE /agents/{id}, POST /agents/{id}/workers/{worker}/{restart|stop|start},
5
5
  // POST|GET /agent/v2/admin/codes, DELETE /codes/{id}, GET /agent/v2/admin/tasks; self-update U2: GET /update,
6
- // PUT /update/policy, POST /agents/{id}/update, POST /agents/{id}/update/retry).
6
+ // PUT /update/policy, POST /agents/{id}/update, POST /agents/{id}/update/retry; settings ADR 0122:
7
+ // PUT /agents/{id}/settings).
7
8
  // Shows every agent of this instance with its roles and worker states, creates one-time enrollment codes (the
8
9
  // code is shown once) and lists the last tasks without their data.
9
10
  const React = require("react");
@@ -85,6 +86,23 @@ const LABELS = {
85
86
  scriptsOld: "werden aktualisiert",
86
87
  sealed: "Passwörter verschlüsselt",
87
88
  customAllowed: "eigene Scripts erlaubt",
89
+ settings: "Einstellungen",
90
+ setNone: "Dieser Agent meldet noch keine Einstellungen. Eine neuere Version des Agents kann sie aus der App übernehmen.",
91
+ setNoGate: "Schalter mit Schreibrechten (z. B. Ein/Aus, neue Desktops, GPOs) wirken erst, wenn ein Administrator auf dem Server die Freigabe gesetzt hat: Häkchen «Schreibrechte aus der App erlauben» bei der Installation oder RemoteWrite = 1 in HKLM\\SOFTWARE\\Scalio\\Agent.",
92
+ setLocal: "lokal gesetzt, gilt vor der App",
93
+ setPending: "wartet auf die Freigabe beim Kunden",
94
+ setFromApp: "aus der App",
95
+ setNotSet: "nicht gesetzt",
96
+ setOn: "Ein",
97
+ setOff: "Aus",
98
+ setSecretSet: "gesetzt (verdeckt)",
99
+ setSecretNew: "Neuen Wert eingeben",
100
+ setSecretClear: "Entfernen",
101
+ setNoSeal: "Dieser Agent kann noch keine verschlüsselten Secrets annehmen.",
102
+ setSave: "Einstellungen senden",
103
+ setNothing: "Keine Änderung.",
104
+ setSentAt: "Zuletzt gesendet: {at}",
105
+ setGate: "Schreibrecht",
88
106
  updStates: { installing: "Wird aktualisiert auf {version}", verifying: "Prüft Version {version}", installed: "Aktualisiert auf {version}",
89
107
  rolled_back: "Zurückgerollt auf {from} ({reason})", rollback_failed: "Rollback fehlgeschlagen ({reason})", failed: "Update fehlgeschlagen ({reason})",
90
108
  refused: "Update abgelehnt ({reason})" },
@@ -160,6 +178,23 @@ const LABELS = {
160
178
  scriptsOld: "being updated",
161
179
  sealed: "passwords encrypted",
162
180
  customAllowed: "own scripts allowed",
181
+ settings: "Settings",
182
+ setNone: "This agent does not report settings yet. A newer version of the agent can take them from the app.",
183
+ setNoGate: "Switches that allow writing (e.g. power, new desktops, GPOs) only take effect once an administrator has allowed it on the server: the checkbox «Allow write permissions from the app» at install, or RemoteWrite = 1 in HKLM\\SOFTWARE\\Scalio\\Agent.",
184
+ setLocal: "set locally, wins over the app",
185
+ setPending: "waits for the customer's approval",
186
+ setFromApp: "from the app",
187
+ setNotSet: "not set",
188
+ setOn: "On",
189
+ setOff: "Off",
190
+ setSecretSet: "set (hidden)",
191
+ setSecretNew: "Enter a new value",
192
+ setSecretClear: "Remove",
193
+ setNoSeal: "This agent cannot accept encrypted secrets yet.",
194
+ setSave: "Send settings",
195
+ setNothing: "No change.",
196
+ setSentAt: "Last sent: {at}",
197
+ setGate: "write permission",
163
198
  updStates: { installing: "Updating to {version}", verifying: "Checking version {version}", installed: "Updated to {version}",
164
199
  rolled_back: "Rolled back to {from} ({reason})", rollback_failed: "Rollback failed ({reason})", failed: "Update failed ({reason})",
165
200
  refused: "Update refused ({reason})" },
@@ -209,6 +244,7 @@ function agentsApi(api, base) {
209
244
  setPolicy: (policy) => api.put(`${b}/update/policy`, policy).then((r) => r.data),
210
245
  updateNow: (id) => api.post(`${b}/agents/${id}/update`, {}).then((r) => r.data),
211
246
  retryUpdate: (id) => api.post(`${b}/agents/${id}/update/retry`, {}).then((r) => r.data),
247
+ setSettings: (id, body) => api.put(`${b}/agents/${id}/settings`, body).then((r) => r.data),
212
248
  };
213
249
  }
214
250
 
@@ -222,6 +258,99 @@ function statusOf(agent) {
222
258
  return agent.online ? "online" : "offline";
223
259
  }
224
260
 
261
+ // The current value of a setting as the form shows it ("" = not set); a secret never has one.
262
+ function shownValue(def, v) {
263
+ if (!v || v.value == null) return "";
264
+ if (def.kind === "bool") return v.value === "1" ? "1" : v.value === "0" ? "0" : "";
265
+ return String(v.value);
266
+ }
267
+
268
+ // Settings of one agent from the app (ADR 0122): built from the catalog the agent reports, only the changed values
269
+ // are sent. A local value wins and cannot be changed here; a write switch waits for the local opt-in RemoteWrite.
270
+ function AgentSettings(props) {
271
+ const { agent: a, L, lang, busy } = props;
272
+ const s = a.settings;
273
+ const [edit, setEdit] = React.useState({});
274
+ const [secrets, setSecrets] = React.useState({});
275
+ if (!s) return h("p", { className: "scalio-settings-text", "data-testid": `agent-settings-none-${a.id}` }, L.setNone);
276
+ const values = s.values || {};
277
+ const label = (d) => (d.label && (d.label[lang === "en" ? "en" : "de"] || d.label.de)) || d.name;
278
+ const hasGate = (s.catalog || []).some((d) => d.gate);
279
+ const current = (d) => (values[d.name] && values[d.name].source === "app" ? shownValue(d, values[d.name]) : "");
280
+ const valueOf = (d) => (Object.prototype.hasOwnProperty.call(edit, d.name) ? edit[d.name] : (values[d.name] && values[d.name].source === "local" ? shownValue(d, values[d.name]) : current(d)));
281
+ const set = (d, v) => setEdit(Object.assign({}, edit, { [d.name]: v }));
282
+
283
+ const change = () => {
284
+ const out = {};
285
+ const sec = {};
286
+ (s.catalog || []).forEach((d) => {
287
+ if (d.kind === "secret") {
288
+ if (secrets[d.name] === null) sec[d.name] = null;
289
+ else if (secrets[d.name]) sec[d.name] = secrets[d.name];
290
+ return;
291
+ }
292
+ if (!Object.prototype.hasOwnProperty.call(edit, d.name)) return;
293
+ const v = edit[d.name];
294
+ if (v === current(d)) return;
295
+ if (v === "") out[d.name] = null;
296
+ else if (d.kind === "bool") out[d.name] = v === "1";
297
+ else if (d.kind === "number") out[d.name] = Number(v);
298
+ else out[d.name] = v;
299
+ });
300
+ const body = {};
301
+ if (Object.keys(out).length) body.values = out;
302
+ if (Object.keys(sec).length) body.secrets = sec;
303
+ return body;
304
+ };
305
+ const save = async () => {
306
+ const body = change();
307
+ if (!body.values && !body.secrets) { if (props.notify) props.notify(L.setNothing, "info"); return; }
308
+ const res = await props.run(() => props.client.setSettings(a.id, body), L.sent);
309
+ if (res) { setEdit({}); setSecrets({}); }
310
+ };
311
+
312
+ const input = (d) => {
313
+ const v = values[d.name] || {};
314
+ const local = v.source === "local";
315
+ const tid = `agent-setting-${a.id}-${d.name}`;
316
+ const common = { id: tid, className: "scalio-input", disabled: busy || local || a.blocked, "data-testid": tid, "aria-label": label(d) };
317
+ if (d.kind === "secret") {
318
+ if (!a.sealed) return h("span", { className: "scalio-settings-text", "data-testid": tid }, v.set ? L.setSecretSet : L.setNotSet, " · ", L.setNoSeal);
319
+ return h("span", { style: { display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center" } },
320
+ h("input", Object.assign({}, common, { type: "password", autoComplete: "new-password", placeholder: v.set ? L.setSecretSet : L.setSecretNew,
321
+ value: secrets[d.name] || "", onChange: (e) => setSecrets(Object.assign({}, secrets, { [d.name]: e.target.value })) })),
322
+ v.set && v.source === "app" ? h("label", { className: "scalio-settings-check" },
323
+ h("input", { type: "checkbox", checked: secrets[d.name] === null, disabled: busy, "data-testid": `${tid}-clear`,
324
+ onChange: () => setSecrets(Object.assign({}, secrets, { [d.name]: secrets[d.name] === null ? "" : null })) }),
325
+ h("span", null, L.setSecretClear)) : null);
326
+ }
327
+ if (d.kind === "bool" || d.kind === "choice") {
328
+ const opts = d.kind === "bool" ? [["1", L.setOn], ["0", L.setOff]] : (d.options || []).map((o) => [o, o]);
329
+ return h("select", Object.assign({}, common, { value: valueOf(d), onChange: (e) => set(d, e.target.value) }),
330
+ h("option", { value: "" }, L.setNotSet), opts.map(([k, t]) => h("option", { key: k, value: k }, t)));
331
+ }
332
+ return h("input", Object.assign({}, common, { type: d.kind === "number" ? "number" : "text", min: d.kind === "number" ? 1 : undefined,
333
+ maxLength: d.kind === "text" ? 1024 : undefined, value: valueOf(d), onChange: (e) => set(d, e.target.value) }));
334
+ };
335
+ const note = (d) => {
336
+ const v = values[d.name] || {};
337
+ if (v.source === "local") return h(StatusBadge, { tone: "neutral", testId: `agent-setting-local-${a.id}-${d.name}` }, L.setLocal);
338
+ if (v.pending) return h(StatusBadge, { tone: "warn", testId: `agent-setting-pending-${a.id}-${d.name}` }, L.setPending);
339
+ return null;
340
+ };
341
+
342
+ return h("div", { "data-testid": `agent-settings-${a.id}`, style: { display: "grid", gap: "0.5rem" } },
343
+ hasGate && !s.remote_write ? h("div", { className: "scalio-notice is-info", role: "status", "data-testid": `agent-settings-nogate-${a.id}` },
344
+ h("div", { className: "scalio-notice-body" }, h("div", { className: "scalio-notice-text" }, L.setNoGate))) : null,
345
+ (s.catalog || []).map((d) => h("div", { key: d.name, style: { display: "grid", gridTemplateColumns: "minmax(12rem, 1fr) minmax(12rem, 2fr)", gap: "0.5rem", alignItems: "center" } },
346
+ h("label", { htmlFor: `agent-setting-${a.id}-${d.name}` }, label(d), d.gate ? h("span", { className: "scalio-settings-text" }, ` (${L.setGate})`) : null),
347
+ h("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center", flexWrap: "wrap" } }, input(d), note(d)))),
348
+ h("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center", flexWrap: "wrap" } },
349
+ h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy || a.blocked, "data-testid": `agent-settings-save-${a.id}`, onClick: save },
350
+ h(Icons.Settings, { className: "scalio-icon" }), L.setSave),
351
+ a.settings_sent_at ? h("span", { className: "scalio-settings-text" }, fill(L.setSentAt, { at: when(a.settings_sent_at, lang) })) : null));
352
+ }
353
+
225
354
  // Props: client (agentsApi), lang, labels, appUrl (address the agent connects to, default window.location.origin),
226
355
  // downloadUrl (MSI), notify(message, tone), formatError(err), refreshMs (default 15000, 0 = off), copy(text).
227
356
  function AgentsPanel(props) {
@@ -237,6 +366,7 @@ function AgentsPanel(props) {
237
366
  const [shown, setShown] = React.useState(null); // {code, expires_at} right after «Code erzeugen»
238
367
  const [upd, setUpd] = React.useState(null); // GET /update; stays null with an older backend
239
368
  const [policy, setPolicy] = React.useState(null); // the rule being edited
369
+ const [open, setOpen] = React.useState(null); // agent whose settings are open
240
370
 
241
371
  const load = React.useCallback(async () => {
242
372
  try {
@@ -438,6 +568,8 @@ function AgentsPanel(props) {
438
568
  ] : null);
439
569
  })),
440
570
  h("td", null,
571
+ h("button", { type: "button", className: "scalio-btn is-ghost", "aria-expanded": open === a.id, "data-testid": `agent-settings-open-${a.id}`,
572
+ onClick: () => setOpen(open === a.id ? null : a.id) }, h(Icons.Settings, { className: "scalio-icon" }), L.settings),
441
573
  h("button", { type: "button", className: "scalio-btn is-ghost", disabled: busy, "data-testid": `agent-block-${a.id}`,
442
574
  onClick: () => a.blocked
443
575
  ? run(() => props.client.block(a.id, false), L.saved)
@@ -452,7 +584,8 @@ function AgentsPanel(props) {
452
584
  : h("div", { style: { overflowX: "auto" } },
453
585
  h("table", { className: "scalio-users-table", "data-testid": "agents-table" },
454
586
  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)))),
455
- h("tbody", null, agents.map(agentRow))))));
587
+ h("tbody", null, agents.map((a) => [agentRow(a), open === a.id ? h("tr", { key: `${a.id}-settings` },
588
+ h("td", { colSpan: 7 }, h(AgentSettings, { agent: a, L, lang: props.lang, busy, client: props.client, run, notify: props.notify }))) : null]))))));
456
589
 
457
590
  // tasks
458
591
  const nameOf = (id) => (agents.find((a) => a.id === id) || {}).name || "";
package/react/mail.js CHANGED
@@ -26,7 +26,8 @@ const LABELS = {
26
26
  identity: "Die App konnte ihre eigene Identität im Tenant nicht lesen. Prüfen Sie die Tenant-Verbindung oder führen Sie das Skript aus.",
27
27
  },
28
28
  rightsCheck: "Status prüfen",
29
- rightsState: { ok: "Senderecht vorhanden", missing: "Senderecht fehlt", unknown: "Senderecht nicht prüfbar, die Testmail zeigt es" },
29
+ rightsState: { ok: "Senderecht vorhanden", missing: "Senderecht fehlt" },
30
+ rightsUnknown: "Senden Sie eine Testmail, um das Senderecht zu bestätigen.",
30
31
  rightsScriptAlso: "Lieber selbst ausführen? Skript anzeigen",
31
32
  testFirst: "Speichern Sie zuerst Weg und Postfach.",
32
33
  transportHint: "Über welchen Server die App Mails schickt. Passwort und Client-Secret werden verschlüsselt gespeichert und nie angezeigt.",
@@ -118,7 +119,8 @@ const LABELS = {
118
119
  identity: "The app could not read its own identity in the tenant. Check the tenant connection or run the script.",
119
120
  },
120
121
  rightsCheck: "Check status",
121
- rightsState: { ok: "Send right in place", missing: "Send right missing", unknown: "Send right can not be checked, the test mail shows it" },
122
+ rightsState: { ok: "Send right in place", missing: "Send right missing" },
123
+ rightsUnknown: "Send a test mail to confirm the send right.",
122
124
  rightsScriptAlso: "Rather run it yourself? Show script",
123
125
  testFirst: "Save the way and the mailbox first.",
124
126
  transportHint: "Which server the app sends mail through. Password and client secret are stored encrypted and never shown.",
@@ -364,6 +366,16 @@ function MailTransport(props) {
364
366
  }
365
367
  setBusy(false);
366
368
  };
369
+ // After a test mail the status is read again (the backend may note Microsoft's answer). A test mail that went out
370
+ // through Microsoft 365 shows the right is there, also when the app can not ask Exchange (state «unknown»).
371
+ const confirmRights = (delivered) => {
372
+ if (!form || !form.send_rights || !client.rightsStatus) return Promise.resolve();
373
+ const viaM365 = form.provider === "graph" || form.provider === "tenant";
374
+ return client.rightsStatus().then((r) => {
375
+ if (!r || !r.mode) return;
376
+ setRightsInfo(delivered && viaM365 && r.state === "unknown" ? Object.assign({}, r, { state: "ok", detail: "" }) : r);
377
+ }).catch(() => undefined);
378
+ };
367
379
  const test = async () => {
368
380
  setTesting(true);
369
381
  setTestMsg(null);
@@ -374,10 +386,12 @@ function MailTransport(props) {
374
386
  if (props.notify) props.notify(text, "success");
375
387
  else setTestMsg({ tone: "ok", text });
376
388
  loadOutbox();
389
+ confirmRights(true);
377
390
  } catch (err) {
378
391
  const text = (props.formatError || errorText)(err);
379
392
  if (props.notify) props.notify(text, "error");
380
393
  else setTestMsg({ tone: "error", text });
394
+ confirmRights(false);
381
395
  }
382
396
  setTesting(false);
383
397
  };
@@ -530,18 +544,25 @@ function MailTransport(props) {
530
544
  // The button «Senderecht setzen» is there in every app (like Foundry); greyed out with the reason where the app's
531
545
  // own connection may not set it (scalio-platform 0.45.0 `reason`). Not for an own app registration (provider graph).
532
546
  const offReason = rightsInfo && rightsInfo.mode === "script" && L.grantOff[rightsInfo.reason] ? rightsInfo.reason : "";
533
- const showGrant = auto || (!!offReason && !!client.grantRights);
547
+ const rightsOk = !!(rightsInfo && rightsInfo.state === "ok");
548
+ // Nothing to do once the right is there: no greyed-out «Senderecht setzen» next to «Senderecht vorhanden».
549
+ const showGrant = auto || (!rightsOk && !!offReason && !!client.grantRights);
550
+ const rightsKnown = !!(rightsInfo && (rightsInfo.state === "ok" || rightsInfo.state === "missing"));
534
551
  const rights = form.send_rights && (form.provider === "graph" || form.provider === "tenant" || form.provider === "default")
535
552
  ? h(
536
553
  SettingsSection,
537
554
  { id: "mail-rights", title: L.rightsTitle, description: auto ? L.autoHint : L.rightsHint, testId: "mail-rights" },
538
- rightsInfo && rightsInfo.mode !== "none"
555
+ rightsInfo && rightsInfo.mode !== "none" && rightsKnown
539
556
  ? h("div", { className: "scalio-mail-rights-state" },
540
- h("span", { className: `scalio-badge is-${{ ok: "ok", missing: "warn" }[rightsInfo.state] || "neutral"}`, "data-testid": "mail-rights-state" },
541
- L.rightsState[rightsInfo.state] || rightsInfo.state),
557
+ h("span", { className: `scalio-badge is-${{ ok: "ok", missing: "warn" }[rightsInfo.state]}`, "data-testid": "mail-rights-state" },
558
+ L.rightsState[rightsInfo.state]),
542
559
  h("button", { type: "button", className: "scalio-btn is-ghost", onClick: loadRights, "data-testid": "mail-rights-check" }, L.rightsCheck))
543
560
  : null,
544
- rightsInfo && rightsInfo.detail
561
+ // «unknown»: the app can not ask Exchange; no badge, one sentence what to do (the test mail confirms it)
562
+ rightsInfo && rightsInfo.mode !== "none" && !rightsKnown
563
+ ? h("p", { className: "scalio-settings-help", "data-testid": "mail-rights-unknown" }, L.rightsUnknown)
564
+ : null,
565
+ rightsInfo && rightsInfo.detail && !rightsOk
545
566
  ? h("p", { className: "scalio-settings-help is-error", "data-testid": "mail-rights-detail" }, rightsInfo.detail)
546
567
  : null,
547
568
  showGrant