@scalio-cloud/ui 0.75.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/react/mail.js +28 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.75.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/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