@scalio-cloud/ui 0.66.0 → 0.67.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.
Files changed (3) hide show
  1. package/nav.css +8 -0
  2. package/package.json +1 -1
  3. package/react/mail.js +117 -9
package/nav.css CHANGED
@@ -953,3 +953,11 @@ ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; lis
953
953
  .scalio-md-table th, .scalio-md-table td { padding: 0.375rem 0.75rem; border: 1px solid hsl(var(--border)); vertical-align: top; }
954
954
  .scalio-md-table thead { background: hsl(var(--secondary)); }
955
955
  .scalio-md-table th { font-weight: 700; }
956
+ /* Mail setup steps (BL-449): way, mailbox, send right, test mail */
957
+ .scalio-mail-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
958
+ .scalio-mail-step { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; border: 1px solid hsl(var(--border)); border-radius: 2px; background: hsl(var(--card)); font-size: 0.875rem; }
959
+ .scalio-mail-step.is-open { border-color: hsl(var(--primary) / 0.45); }
960
+ .scalio-mail-step.is-check { border-color: rgb(217 119 6 / 0.45); }
961
+ .scalio-mail-step-name { font-weight: 600; }
962
+ .scalio-mail-step-state { margin-left: auto; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
963
+ .scalio-mail-rights-state { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.66.0",
3
+ "version": "0.67.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/mail.js CHANGED
@@ -10,6 +10,20 @@ const { SettingsSection, SettingsField: Field } = require("./settings");
10
10
  const LABELS = {
11
11
  de: {
12
12
  transportTitle: "E-Mail-Versand",
13
+ steps: ["Weg", "Postfach", "Senderecht", "Testmail"],
14
+ stepsTitle: "Einrichtung",
15
+ stepState: { done: "erledigt", open: "offen", check: "prüfen", none: "nicht nötig" },
16
+ mailboxPick: "Postfach, das sendet",
17
+ mailboxOther: "Andere Adresse eingeben",
18
+ mailboxHint: "Ein freigegebenes Postfach (Shared Mailbox) braucht keine Lizenz.",
19
+ autoTitle: "Senderecht automatisch setzen",
20
+ autoHint: "Die App richtet das Senderecht mit ihrer Verbindung zum Tenant selbst ein, nur für dieses Postfach («RBAC for Applications»). Exchange übernimmt es nach bis zu zwei Stunden.",
21
+ autoGrant: "Senderecht setzen",
22
+ autoGranted: "Senderecht gesetzt",
23
+ rightsCheck: "Status prüfen",
24
+ rightsState: { ok: "Senderecht vorhanden", missing: "Senderecht fehlt", unknown: "Senderecht nicht prüfbar, die Testmail zeigt es" },
25
+ rightsScriptAlso: "Lieber selbst ausführen? Skript anzeigen",
26
+ testFirst: "Speichern Sie zuerst Weg und Postfach.",
13
27
  transportHint: "Über welchen Server die App Mails schickt. Passwort und Client-Secret werden verschlüsselt gespeichert und nie angezeigt.",
14
28
  provider: "Mails senden mit",
15
29
  providers: { default: "Vorgabe verwenden (empfohlen)", off: "Aus", smtp: "SMTP-Server", graph: "Microsoft 365", tenant: "Microsoft 365 über die Tenant-Verbindung" },
@@ -83,6 +97,20 @@ const LABELS = {
83
97
  },
84
98
  en: {
85
99
  transportTitle: "E-mail sending",
100
+ steps: ["Way", "Mailbox", "Send right", "Test mail"],
101
+ stepsTitle: "Setup",
102
+ stepState: { done: "done", open: "open", check: "check", none: "not needed" },
103
+ mailboxPick: "Mailbox that sends",
104
+ mailboxOther: "Enter another address",
105
+ mailboxHint: "A shared mailbox needs no license.",
106
+ autoTitle: "Set the send right automatically",
107
+ autoHint: "The app sets up the send right itself with its connection to the tenant, for this mailbox only (RBAC for Applications). Exchange applies it within up to two hours.",
108
+ autoGrant: "Set send right",
109
+ autoGranted: "Send right set",
110
+ rightsCheck: "Check status",
111
+ rightsState: { ok: "Send right in place", missing: "Send right missing", unknown: "Send right can not be checked, the test mail shows it" },
112
+ rightsScriptAlso: "Rather run it yourself? Show script",
113
+ testFirst: "Save the way and the mailbox first.",
86
114
  transportHint: "Which server the app sends mail through. Password and client secret are stored encrypted and never shown.",
87
115
  provider: "Send mail with",
88
116
  providers: { default: "Use the default (recommended)", off: "Off", smtp: "SMTP server", graph: "Microsoft 365", tenant: "Microsoft 365 through the tenant connection" },
@@ -199,6 +227,10 @@ function mailApi(api, base) {
199
227
  preview: (body) => api.post(`${b}/templates/preview`, body).then(data),
200
228
  testTemplate: (body) => api.post(`${b}/templates/test`, body).then(data),
201
229
  sendRights: () => api.get(`${b}/send-rights`).then(data),
230
+ // scalio-platform 0.43.0 (BL-449); an older backend answers 404 and the page falls back to the script
231
+ mailboxes: (tenantId) => api.get(`${b}/mailboxes`, { params: { tenant_id: tenantId || "" } }).then(data),
232
+ rightsStatus: () => api.get(`${b}/send-rights/status`).then(data),
233
+ grantRights: () => api.post(`${b}/send-rights/grant`, {}).then(data),
202
234
  };
203
235
  }
204
236
 
@@ -253,18 +285,40 @@ function MailTransport(props) {
253
285
  const [script, setScript] = React.useState(null);
254
286
  const [scriptBusy, setScriptBusy] = React.useState(false);
255
287
  const [scriptMsg, setScriptMsg] = React.useState(null);
288
+ const [rightsInfo, setRightsInfo] = React.useState(null); // {mode, state, detail, sender} (scalio-platform 0.43.0)
289
+ const [granting, setGranting] = React.useState(false);
290
+ const [mbxList, setMbxList] = React.useState(null); // shared mailboxes of the chosen tenant, or null
291
+ const [mbxOther, setMbxOther] = React.useState(false);
292
+ const [testOk, setTestOk] = React.useState(false);
256
293
  const showOutbox = props.outbox !== false;
257
294
 
258
295
  const loadOutbox = React.useCallback(() => {
259
296
  if (!showOutbox) return Promise.resolve();
260
297
  return client.outbox().then((r) => setRows(r || [])).catch(() => setRows([]));
261
298
  }, [client, showOutbox]);
299
+ const loadRights = React.useCallback(() => {
300
+ if (!client.rightsStatus) return Promise.resolve();
301
+ return client.rightsStatus().then((r) => setRightsInfo(r && r.mode ? r : null)).catch(() => setRightsInfo(null));
302
+ }, [client]);
262
303
  React.useEffect(() => {
263
304
  let alive = true;
264
- client.settings().then((d) => alive && setForm(d)).catch((e) => alive && m.fail(e));
305
+ client.settings().then((d) => { if (alive) { setForm(d); if (d && d.send_rights) loadRights(); } }).catch((e) => alive && m.fail(e));
265
306
  loadOutbox();
266
307
  return () => { alive = false; };
267
308
  }, [client]); // eslint-disable-line react-hooks/exhaustive-deps
309
+ // Step 2: the shared mailboxes of the tenant that sends (only when the app can list them)
310
+ const mbxTenant = form && form.provider === "tenant"
311
+ ? (Array.isArray(form.tenants) ? (form.graph.tenant_id || (form.tenants.length === 1 ? form.tenants[0].id : "")) : "-")
312
+ : "";
313
+ React.useEffect(() => {
314
+ let alive = true;
315
+ setMbxList(null);
316
+ if (!mbxTenant || !client.mailboxes) return undefined;
317
+ client.mailboxes(mbxTenant === "-" ? "" : mbxTenant)
318
+ .then((r) => alive && setMbxList(r && Array.isArray(r.mailboxes) && r.mailboxes.length ? r.mailboxes : null))
319
+ .catch(() => alive && setMbxList(null));
320
+ return () => { alive = false; };
321
+ }, [client, mbxTenant]);
268
322
 
269
323
  if (!form) return h(SettingsSection, { id: "mail", title: L.transportTitle, description: L.transportHint, testId: "mail-transport" }, h(Notice, { msg: m.msg, testId: "mail-message" }));
270
324
 
@@ -283,10 +337,14 @@ function MailTransport(props) {
283
337
  if (form.provider === "graph") body.graph = form.graph;
284
338
  if (form.provider === "tenant") {
285
339
  body.graph = { sender: form.graph.sender };
286
- if (Array.isArray(form.tenants)) body.graph.tenant_id = form.graph.tenant_id || "";
340
+ if (Array.isArray(form.tenants)) body.graph.tenant_id = mbxTenant || "";
287
341
  }
288
- setForm(await client.save(body));
342
+ const saved = await client.save(body);
343
+ setForm(saved);
289
344
  setScript(null);
345
+ setTestOk(false);
346
+ setRightsInfo(null);
347
+ if (saved && saved.send_rights) loadRights();
290
348
  m.ok(L.saved);
291
349
  } catch (err) {
292
350
  m.fail(err);
@@ -299,6 +357,7 @@ function MailTransport(props) {
299
357
  try {
300
358
  const r = await client.test(to.trim());
301
359
  const text = L.testSent.replace("{to}", (r && r.to) || to);
360
+ setTestOk(true);
302
361
  if (props.notify) props.notify(text, "success");
303
362
  else setTestMsg({ tone: "ok", text });
304
363
  loadOutbox();
@@ -332,6 +391,21 @@ function MailTransport(props) {
332
391
  if (props.notify) props.notify(text, tone);
333
392
  else setScriptMsg({ tone: tone === "error" ? "error" : "ok", text });
334
393
  };
394
+ const grant = async () => {
395
+ setGranting(true);
396
+ setScriptMsg(null);
397
+ try {
398
+ const r = await client.grantRights();
399
+ setRightsInfo(r);
400
+ if (props.notify) props.notify(L.autoGranted, "success");
401
+ else setScriptMsg({ tone: "ok", text: L.autoGranted });
402
+ } catch (err) {
403
+ const text = (props.formatError || errorText)(err);
404
+ if (props.notify) props.notify(text, "error");
405
+ else setScriptMsg({ tone: "error", text });
406
+ }
407
+ setGranting(false);
408
+ };
335
409
  const tenants = Array.isArray(form.tenants) ? form.tenants : null;
336
410
 
337
411
  const providers = (form.providers || ["off", "smtp", "graph"]).filter((id) => L.providers[id]);
@@ -413,8 +487,13 @@ function MailTransport(props) {
413
487
  (tenants.length === 1 ? [] : [["", L.tenantChoose]]).concat(tenants.map((t) => [t.id, t.name || t.id])),
414
488
  part("graph", "tenant_id"), { disabled: busy }))
415
489
  : null,
416
- h(Field, { id: "mail-tenant-sender", label: L.sender }, input("mail-tenant-sender", form.graph.sender, part("graph", "sender"),
417
- { type: "email", maxLength: 254, placeholder: "it@example.com", disabled: busy }))),
490
+ mbxList && !mbxOther
491
+ ? h(Field, { id: "mail-tenant-sender", label: L.mailboxPick, hint: L.mailboxHint },
492
+ select("mail-tenant-sender", mbxList.some((x) => x.address === (form.graph.sender || "").toLowerCase()) ? form.graph.sender.toLowerCase() : "",
493
+ [["", L.tenantChoose]].concat(mbxList.map((x) => [x.address, x.name ? `${x.name} (${x.address})` : x.address]), [["__other", L.mailboxOther]]),
494
+ (v) => (v === "__other" ? setMbxOther(true) : part("graph", "sender")(v)), { disabled: busy }))
495
+ : h(Field, { id: "mail-tenant-sender", label: L.sender }, input("mail-tenant-sender", form.graph.sender, part("graph", "sender"),
496
+ { type: "email", maxLength: 254, placeholder: "it@example.com", disabled: busy }))),
418
497
  h("p", { className: "scalio-settings-help" }, props.tenantHint || L.tenantHint))
419
498
  : null,
420
499
  h(Notice, { msg: m.msg, testId: "mail-message" }),
@@ -434,10 +513,22 @@ function MailTransport(props) {
434
513
  h(Notice, { msg: testMsg, testId: "mail-test-message" })
435
514
  );
436
515
 
516
+ const auto = !!(rightsInfo && rightsInfo.mode === "auto" && client.grantRights);
437
517
  const rights = form.send_rights && (form.provider === "graph" || form.provider === "tenant" || form.provider === "default")
438
518
  ? h(
439
519
  SettingsSection,
440
- { id: "mail-rights", title: L.rightsTitle, description: L.rightsHint, testId: "mail-rights" },
520
+ { id: "mail-rights", title: L.rightsTitle, description: auto ? L.autoHint : L.rightsHint, testId: "mail-rights" },
521
+ rightsInfo && rightsInfo.mode !== "none"
522
+ ? h("div", { className: "scalio-mail-rights-state" },
523
+ h("span", { className: `scalio-badge is-${{ ok: "ok", missing: "warn" }[rightsInfo.state] || "neutral"}`, "data-testid": "mail-rights-state" },
524
+ L.rightsState[rightsInfo.state] || rightsInfo.state),
525
+ h("button", { type: "button", className: "scalio-btn is-ghost", onClick: loadRights, "data-testid": "mail-rights-check" }, L.rightsCheck))
526
+ : null,
527
+ auto
528
+ ? h("div", { className: "scalio-settings-section-footer" },
529
+ h("button", { type: "button", className: "scalio-btn is-primary", onClick: grant, disabled: granting, "data-testid": "mail-rights-grant" },
530
+ h(Icons.Check, { className: "scalio-icon" }), L.autoGrant))
531
+ : null,
441
532
  script
442
533
  ? h(React.Fragment, null,
443
534
  h("pre", { className: "scalio-mail-script", "data-testid": "mail-rights-script" }, script),
@@ -445,8 +536,8 @@ function MailTransport(props) {
445
536
  h("button", { type: "button", className: "scalio-btn", onClick: copyScript, "data-testid": "mail-rights-copy" },
446
537
  h(Icons.Copy, { className: "scalio-icon" }), L.copy)))
447
538
  : h("div", { className: "scalio-settings-section-footer" },
448
- h("button", { type: "button", className: "scalio-btn", onClick: showScript, disabled: scriptBusy, "data-testid": "mail-rights-show" },
449
- L.showScript)),
539
+ h("button", { type: "button", className: auto ? "scalio-btn is-ghost" : "scalio-btn", onClick: showScript, disabled: scriptBusy, "data-testid": "mail-rights-show" },
540
+ auto ? L.rightsScriptAlso : L.showScript)),
450
541
  h(Notice, { msg: scriptMsg, testId: "mail-rights-message" })
451
542
  )
452
543
  : null;
@@ -471,7 +562,24 @@ function MailTransport(props) {
471
562
  )
472
563
  : null;
473
564
 
474
- return h(React.Fragment, null, transport, rights, testBlock, props.children || null, outbox);
565
+ // The four steps on top (like the Nexus assistant): way, mailbox, send right, test mail
566
+ const needsMailbox = ["graph", "tenant"].includes(form.provider);
567
+ const sender = (form.graph && form.graph.sender) || "";
568
+ const wayDone = form.provider !== "off" && (form.provider !== "default" || defaultUsable);
569
+ const stepStates = [
570
+ wayDone ? "done" : "open",
571
+ !needsMailbox ? "none" : (sender ? "done" : "open"),
572
+ !form.send_rights ? "none" : (rightsInfo && rightsInfo.state === "ok" ? "done" : (rightsInfo && rightsInfo.state === "missing" ? "open" : "check")),
573
+ testOk ? "done" : "open",
574
+ ];
575
+ const steps = locked ? null : h("ol", { className: "scalio-mail-steps", "aria-label": L.stepsTitle, "data-testid": "mail-steps" },
576
+ L.steps.map((name, i) => h("li", { key: name, className: `scalio-mail-step is-${stepStates[i]}`, "data-testid": `mail-step-${i + 1}`, "data-state": stepStates[i] },
577
+ h("span", { className: `scalio-wizard-dot ${stepStates[i] === "done" ? "is-done" : ""}`.trim() },
578
+ stepStates[i] === "done" ? h(Icons.Check, { width: 14, height: 14 }) : i + 1),
579
+ h("span", { className: "scalio-mail-step-name" }, name),
580
+ h("span", { className: "scalio-mail-step-state" }, L.stepState[stepStates[i]]))));
581
+
582
+ return h(React.Fragment, null, steps, transport, rights, testBlock, props.children || null, outbox);
475
583
  }
476
584
 
477
585
  // Props: client (mailApi), lang, labels, notify, formatError, editor (the app's rich text editor: a component with