@scalio-cloud/ui 0.70.0 → 0.72.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 +1 -1
- package/package.json +1 -1
- package/react/mail.js +30 -4
- package/react/nav.js +55 -11
package/README.md
CHANGED
|
@@ -174,7 +174,7 @@ const NAV = { sections: [
|
|
|
174
174
|
] },
|
|
175
175
|
] };
|
|
176
176
|
|
|
177
|
-
const apps = useScalioApps(() => api.get("/apps").then((r) => r.data)); // once per page load
|
|
177
|
+
const apps = useScalioApps(() => api.get("/apps").then((r) => r.data)); // once per page load, retried after 1/2/4 s (not on 401/403/404)
|
|
178
178
|
<AppShell
|
|
179
179
|
switcher={apps.features.switcher && <ProductSwitcher current="citadel" links={apps.links} stage={apps.stage} sso={sso} lang={lang} />}
|
|
180
180
|
header={<AppHeader ... onMenu={() => setDrawer(true)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.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
|
@@ -20,6 +20,11 @@ const LABELS = {
|
|
|
20
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
21
|
autoGrant: "Senderecht setzen",
|
|
22
22
|
autoGranted: "Senderecht gesetzt",
|
|
23
|
+
grantOff: {
|
|
24
|
+
read_only: "Die Verbindung zum Tenant darf Exchange Online nur lesen. Darum setzt die App das Senderecht nicht selbst: Führen Sie das Skript aus.",
|
|
25
|
+
no_exchange: "Die Verbindung zum Tenant hat keinen Zugang zur Exchange-Verwaltung. Darum setzt die App das Senderecht nicht selbst: Führen Sie das Skript aus.",
|
|
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
|
+
},
|
|
23
28
|
rightsCheck: "Status prüfen",
|
|
24
29
|
rightsState: { ok: "Senderecht vorhanden", missing: "Senderecht fehlt", unknown: "Senderecht nicht prüfbar, die Testmail zeigt es" },
|
|
25
30
|
rightsScriptAlso: "Lieber selbst ausführen? Skript anzeigen",
|
|
@@ -54,7 +59,7 @@ const LABELS = {
|
|
|
54
59
|
tenantChoose: "Bitte wählen",
|
|
55
60
|
noTenants: "Noch kein Tenant verbunden. Verbinden Sie zuerst einen Tenant, dann wählen Sie ihn hier.",
|
|
56
61
|
rightsTitle: "Senderecht in Exchange Online",
|
|
57
|
-
rightsHint: "Damit die App nur als dieses Postfach senden darf: Führen Sie das Skript einmal als Exchange-Administrator in der Azure Cloud Shell
|
|
62
|
+
rightsHint: "Damit die App nur als dieses Postfach senden darf: Führen Sie das Skript einmal als Exchange-Administrator in der Azure Cloud Shell oder in PowerShell 7 auf Ihrem Computer aus (fehlende Module installiert es selbst). Es nutzt «RBAC for Applications» und kann erneut laufen, auch nach einem Wechsel des Postfachs. Exchange übernimmt das Recht nach bis zu zwei Stunden; dann die Testmail senden.",
|
|
58
63
|
showScript: "Skript anzeigen",
|
|
59
64
|
copy: "Kopieren",
|
|
60
65
|
copied: "Skript kopiert",
|
|
@@ -107,6 +112,11 @@ const LABELS = {
|
|
|
107
112
|
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
113
|
autoGrant: "Set send right",
|
|
109
114
|
autoGranted: "Send right set",
|
|
115
|
+
grantOff: {
|
|
116
|
+
read_only: "The connection to the tenant may only read Exchange Online, so the app does not set the send right itself: run the script.",
|
|
117
|
+
no_exchange: "The connection to the tenant has no access to the Exchange administration, so the app does not set the send right itself: run the script.",
|
|
118
|
+
identity: "The app could not read its own identity in the tenant. Check the tenant connection or run the script.",
|
|
119
|
+
},
|
|
110
120
|
rightsCheck: "Check status",
|
|
111
121
|
rightsState: { ok: "Send right in place", missing: "Send right missing", unknown: "Send right can not be checked, the test mail shows it" },
|
|
112
122
|
rightsScriptAlso: "Rather run it yourself? Show script",
|
|
@@ -141,7 +151,7 @@ const LABELS = {
|
|
|
141
151
|
tenantChoose: "Please choose",
|
|
142
152
|
noTenants: "No tenant connected yet. Connect a tenant first, then choose it here.",
|
|
143
153
|
rightsTitle: "Send right in Exchange Online",
|
|
144
|
-
rightsHint: "So the app may send only as this mailbox: run the script once as an Exchange administrator in Azure Cloud Shell (
|
|
154
|
+
rightsHint: "So the app may send only as this mailbox: run the script once as an Exchange administrator in Azure Cloud Shell or in PowerShell 7 on your computer (it installs missing modules itself). It uses RBAC for Applications and can run again, also after changing the mailbox. Exchange applies the right within up to two hours; then send the test mail.",
|
|
145
155
|
showScript: "Show script",
|
|
146
156
|
copy: "Copy",
|
|
147
157
|
copied: "Script copied",
|
|
@@ -272,6 +282,9 @@ function select(id, value, options, onChange, extra) {
|
|
|
272
282
|
// Exchange Online» shows the PowerShell from GET /mail/send-rights). With scalio-platform 0.19.0 (ADR 0090) the backend may
|
|
273
283
|
// list the provider `default` («Vorgabe verwenden») and send `default` {available, source, provider, from_name,
|
|
274
284
|
// from_address, tenant_id, smtp_host}: the page shows where the default comes from and where mails go.
|
|
285
|
+
// With scalio-platform 0.45.0 the status names a `reason` when the app can not set the send right itself: the button
|
|
286
|
+
// «Senderecht setzen» stays visible but greyed out with that reason (grantOffHint {read_only, no_exchange, identity}:
|
|
287
|
+
// the app's own texts, e.g. Citadel «Mit Scalio Schreiben setzt Citadel das Senderecht selbst»).
|
|
275
288
|
function MailTransport(props) {
|
|
276
289
|
const { client, lang } = props;
|
|
277
290
|
const L = mailLabels(lang, props.labels);
|
|
@@ -514,6 +527,10 @@ function MailTransport(props) {
|
|
|
514
527
|
);
|
|
515
528
|
|
|
516
529
|
const auto = !!(rightsInfo && rightsInfo.mode === "auto" && client.grantRights);
|
|
530
|
+
// The button «Senderecht setzen» is there in every app (like Foundry); greyed out with the reason where the app's
|
|
531
|
+
// own connection may not set it (scalio-platform 0.45.0 `reason`). Not for an own app registration (provider graph).
|
|
532
|
+
const offReason = rightsInfo && rightsInfo.mode === "script" && L.grantOff[rightsInfo.reason] ? rightsInfo.reason : "";
|
|
533
|
+
const showGrant = auto || (!!offReason && !!client.grantRights);
|
|
517
534
|
const rights = form.send_rights && (form.provider === "graph" || form.provider === "tenant" || form.provider === "default")
|
|
518
535
|
? h(
|
|
519
536
|
SettingsSection,
|
|
@@ -524,9 +541,18 @@ function MailTransport(props) {
|
|
|
524
541
|
L.rightsState[rightsInfo.state] || rightsInfo.state),
|
|
525
542
|
h("button", { type: "button", className: "scalio-btn is-ghost", onClick: loadRights, "data-testid": "mail-rights-check" }, L.rightsCheck))
|
|
526
543
|
: null,
|
|
527
|
-
|
|
544
|
+
rightsInfo && rightsInfo.detail
|
|
545
|
+
? h("p", { className: "scalio-settings-help is-error", "data-testid": "mail-rights-detail" }, rightsInfo.detail)
|
|
546
|
+
: null,
|
|
547
|
+
showGrant
|
|
528
548
|
? h("div", { className: "scalio-settings-section-footer" },
|
|
529
|
-
|
|
549
|
+
offReason
|
|
550
|
+
? h("p", { className: "scalio-settings-help", "data-testid": "mail-rights-grant-off" },
|
|
551
|
+
(props.grantOffHint && props.grantOffHint[offReason]) || L.grantOff[offReason])
|
|
552
|
+
: null,
|
|
553
|
+
h("button", { type: "button", className: "scalio-btn is-primary", onClick: grant, disabled: granting || !auto,
|
|
554
|
+
title: offReason ? ((props.grantOffHint && props.grantOffHint[offReason]) || L.grantOff[offReason]) : undefined,
|
|
555
|
+
"data-testid": "mail-rights-grant" },
|
|
530
556
|
h(Icons.Check, { className: "scalio-icon" }), L.autoGrant))
|
|
531
557
|
: null,
|
|
532
558
|
script
|
package/react/nav.js
CHANGED
|
@@ -421,24 +421,66 @@ function ProductSwitcher({ current, links, stage, sso, lang, labels, products, t
|
|
|
421
421
|
|
|
422
422
|
// GET /api/apps once per page load. fetchApps returns a promise with the JSON answer.
|
|
423
423
|
// Until the answer is in (or on error) switcher and support stay hidden.
|
|
424
|
+
// A failed call is retried after 1, 2 and 4 s (options.retryDelays in ms), but not on 401/403/404 (error.response.status
|
|
425
|
+
// as with axios, or error.status). When the last component using the hook unmounts, a waiting retry is dropped;
|
|
426
|
+
// after the last retry the next mount asks again. All users share one call; the first caller's options count.
|
|
427
|
+
const SCALIO_APPS_RETRY_DELAYS = [1000, 2000, 4000];
|
|
424
428
|
let appsCache = null;
|
|
425
429
|
let appsPending = null;
|
|
430
|
+
let appsUsers = 0;
|
|
431
|
+
let appsAbort = null;
|
|
426
432
|
|
|
427
|
-
function
|
|
433
|
+
function errorStatus(e) {
|
|
434
|
+
return e && (e.status || (e.response && e.response.status));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function loadScalioApps(fetchApps, delays) {
|
|
438
|
+
let attempt = 0;
|
|
439
|
+
const run = () =>
|
|
440
|
+
Promise.resolve()
|
|
441
|
+
.then(fetchApps)
|
|
442
|
+
.catch((e) => {
|
|
443
|
+
const status = errorStatus(e);
|
|
444
|
+
if (status === 401 || status === 403 || status === 404 || attempt >= delays.length || appsUsers <= 0) throw e;
|
|
445
|
+
const pause = delays[attempt++];
|
|
446
|
+
return new Promise((resolve, reject) => {
|
|
447
|
+
const timer = setTimeout(() => {
|
|
448
|
+
appsAbort = null;
|
|
449
|
+
resolve(run());
|
|
450
|
+
}, pause);
|
|
451
|
+
appsAbort = () => {
|
|
452
|
+
clearTimeout(timer);
|
|
453
|
+
appsAbort = null;
|
|
454
|
+
reject(e);
|
|
455
|
+
};
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
return run().then((d) => {
|
|
459
|
+
appsCache = d || {};
|
|
460
|
+
return appsCache;
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function useScalioApps(fetchApps, options) {
|
|
428
465
|
const [data, setData] = React.useState(appsCache);
|
|
466
|
+
const delays = (options && options.retryDelays) || SCALIO_APPS_RETRY_DELAYS;
|
|
429
467
|
React.useEffect(() => {
|
|
430
468
|
if (appsCache || !fetchApps) return undefined;
|
|
431
469
|
let alive = true;
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
appsPending.then((d) => alive && setData(d)).catch(() => {
|
|
441
|
-
return () => {
|
|
470
|
+
appsUsers++;
|
|
471
|
+
if (!appsPending) {
|
|
472
|
+
const pending = loadScalioApps(fetchApps, delays);
|
|
473
|
+
appsPending = pending;
|
|
474
|
+
pending.catch(() => {
|
|
475
|
+
if (appsPending === pending) appsPending = null;
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
appsPending.then((d) => alive && setData(d)).catch(() => {});
|
|
479
|
+
return () => {
|
|
480
|
+
alive = false;
|
|
481
|
+
appsUsers--;
|
|
482
|
+
if (appsUsers <= 0 && appsAbort) appsAbort();
|
|
483
|
+
};
|
|
442
484
|
}, [fetchApps]);
|
|
443
485
|
return {
|
|
444
486
|
links: (data && data.links) || {},
|
|
@@ -449,6 +491,7 @@ function useScalioApps(fetchApps) {
|
|
|
449
491
|
}
|
|
450
492
|
|
|
451
493
|
function resetScalioApps() {
|
|
494
|
+
if (appsAbort) appsAbort();
|
|
452
495
|
appsCache = null;
|
|
453
496
|
appsPending = null;
|
|
454
497
|
}
|
|
@@ -550,6 +593,7 @@ module.exports = {
|
|
|
550
593
|
stageBadge,
|
|
551
594
|
scalioFeatures,
|
|
552
595
|
useScalioApps,
|
|
596
|
+
SCALIO_APPS_RETRY_DELAYS,
|
|
553
597
|
resetScalioApps,
|
|
554
598
|
SupportDrawer,
|
|
555
599
|
visibleSections,
|