@scalio-cloud/ui 0.94.0 → 0.95.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 +19 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.94.0",
3
+ "version": "0.95.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
@@ -306,6 +306,17 @@ function select(id, value, options, onChange, extra) {
306
306
  // With scalio-platform 0.45.0 the status names a `reason` when the app can not set the send right itself: the button
307
307
  // «Senderecht setzen» stays visible but greyed out with that reason (grantOffHint {read_only, no_exchange, identity}:
308
308
  // the app's own texts, e.g. Citadel «Mit Scalio Schreiben setzt Citadel das Senderecht selbst»).
309
+ // With scalio-platform 0.60.0 settings and the test mail answer carry from_name_applies, from_name_hint and
310
+ // from_name_hint_de: when applies is false (e.g. Microsoft 365 sends with the mailbox's display name) the sender name
311
+ // has no effect; the field is locked and the hint shown. Without these fields (older backends) nothing changes.
312
+ function pickNameInfo(src) {
313
+ return { applies: src.from_name_applies !== false, hint: src.from_name_hint || "", hint_de: src.from_name_hint_de || "" };
314
+ }
315
+ function nameHintText(info, lang) {
316
+ if (!info || info.applies) return "";
317
+ return (lang === "en" ? info.hint : info.hint_de || info.hint) || (lang === "en" ? info.hint_de : info.hint) || "";
318
+ }
319
+
309
320
  function settlingTime(iso, lang) {
310
321
  const d = new Date(iso);
311
322
  if (isNaN(d.getTime())) return iso;
@@ -327,6 +338,7 @@ function MailTransport(props) {
327
338
  const [scriptMsg, setScriptMsg] = React.useState(null);
328
339
  const [rightsInfo, setRightsInfo] = React.useState(null); // {mode, state, detail, sender} (scalio-platform 0.43.0)
329
340
  const [granting, setGranting] = React.useState(false);
341
+ const [nameInfo, setNameInfo] = React.useState(null); // from_name_* of the last test mail answer (scalio-platform 0.60.0)
330
342
  const [mbxList, setMbxList] = React.useState(null); // shared mailboxes of the chosen tenant, or null
331
343
  const [mbxOther, setMbxOther] = React.useState(false);
332
344
  const [testOk, setTestOk] = React.useState(false);
@@ -428,6 +440,7 @@ function MailTransport(props) {
428
440
  setTestMsg(null);
429
441
  try {
430
442
  const r = await client.test(to.trim());
443
+ if (r && typeof r.from_name_applies === "boolean") setNameInfo(pickNameInfo(r));
431
444
  const text = L.testSent.replace("{to}", (r && r.to) || to);
432
445
  setTestOk(true);
433
446
  if (props.notify) props.notify(text, "success");
@@ -487,6 +500,9 @@ function MailTransport(props) {
487
500
  const providers = (form.providers || ["off", "smtp", "graph"]).filter((id) => L.providers[id]);
488
501
  // ADR 0090: the default from Compass or the installation (scalio-platform 0.19.0); never a secret in it
489
502
  const dflt = form.default || null;
503
+ const nameInfoNow = nameInfo || (typeof form.from_name_applies === "boolean" ? pickNameInfo(form) : null);
504
+ const nameLocked = !!(nameInfoNow && !nameInfoNow.applies);
505
+ const nameHint = nameHintText(nameInfoNow, lang);
490
506
  const defaultUsable = !!(dflt && dflt.available);
491
507
  const defaultBlock = () => {
492
508
  if (!defaultUsable) return h("div", { className: "scalio-notice is-info", "data-testid": "mail-default-none" }, L.defaultNone);
@@ -497,6 +513,7 @@ function MailTransport(props) {
497
513
  h("p", { className: "scalio-field-label" }, `${L.defaultFrom[dflt.source] || L.defaultFrom.compass}: ${L.defaultWays[dflt.provider] || dflt.provider}`),
498
514
  h("dl", { className: "scalio-mail-default-facts" },
499
515
  facts.filter((f) => f[1]).map((f) => h(React.Fragment, { key: f[0] }, h("dt", null, f[0]), h("dd", null, f[1])))),
516
+ nameHint ? h("p", { className: "scalio-settings-help", "data-testid": "mail-from-name-hint" }, nameHint) : null,
500
517
  h("p", { className: "scalio-settings-help" }, L.defaultHint));
501
518
  };
502
519
  const transport = h(
@@ -520,7 +537,8 @@ function MailTransport(props) {
520
537
  : null,
521
538
  form.provider !== "off" && form.provider !== "default"
522
539
  ? h("div", { className: "scalio-mail-grid" },
523
- h(Field, { id: "mail-from-name", label: L.fromName }, input("mail-from-name", form.from_name, (v) => set({ from_name: v }), { maxLength: 80, disabled: busy })),
540
+ h(Field, { id: "mail-from-name", label: L.fromName, hint: nameHint || undefined },
541
+ input("mail-from-name", form.from_name, (v) => set({ from_name: v }), { maxLength: 80, disabled: busy || nameLocked })),
524
542
  form.provider === "smtp"
525
543
  ? h(Field, { id: "mail-from", label: L.fromAddress }, input("mail-from", form.from_address, (v) => set({ from_address: v }),
526
544
  { type: "email", maxLength: 254, placeholder: "noreply@example.com", disabled: busy }))