@scalio-cloud/ui 0.38.1 → 0.40.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 +10 -0
- package/nav.css +14 -0
- package/package.json +1 -1
- package/react/customers.js +78 -0
- package/react/index.js +1 -1
- package/react/labels.js +8 -0
- package/react/mail.js +43 -6
package/README.md
CHANGED
|
@@ -295,6 +295,16 @@ const users = usersApi(api); // once, outside the component
|
|
|
295
295
|
<MicrosoftConnection linked={user.microsoft} canUnlink={user.has_password} onLink={...} onUnlink={...} lang={lang} />
|
|
296
296
|
```
|
|
297
297
|
|
|
298
|
+
### Kunden pro Konto (`customerAccessProps`, `CustomerAccessEditor`)
|
|
299
|
+
|
|
300
|
+
Which customers an account sees (ADR 0063 U5, backend `scalio_tenant.customers`, field `access` {all, customer_ids}).
|
|
301
|
+
Administrators always see all customers.
|
|
302
|
+
|
|
303
|
+
```jsx
|
|
304
|
+
import { UserAdmin, customerAccessProps } from "@scalio-cloud/ui/react";
|
|
305
|
+
<UserAdmin ... {...customerAccessProps({ customers, lang, emptyHint: t("No customers yet. Add them under Settings, Tenants.") })} />
|
|
306
|
+
```
|
|
307
|
+
|
|
298
308
|
### Rollen und Microsoft Entra (`RoleAdmin`, `RoleSourceSettings`)
|
|
299
309
|
|
|
300
310
|
```jsx
|
package/nav.css
CHANGED
|
@@ -445,6 +445,15 @@
|
|
|
445
445
|
.scalio-users-actions .scalio-btn { height: 2rem; }
|
|
446
446
|
.scalio-users-actions .scalio-btn-icon { width: 2rem; }
|
|
447
447
|
.scalio-users-select { height: 2rem; padding: 0 0.5rem; font-size: 0.8125rem; width: auto; }
|
|
448
|
+
/* Customer picker of an account (customers.js, ADR 0063 U5) */
|
|
449
|
+
.scalio-access { position: relative; }
|
|
450
|
+
.scalio-access-open { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
|
|
451
|
+
.scalio-access-panel { position: absolute; z-index: 20; margin-top: 0.25rem; width: 16rem; padding: 0.75rem; display: grid; gap: 0.5rem;
|
|
452
|
+
background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: 2px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.15); font-size: 0.75rem; }
|
|
453
|
+
.scalio-access-panel label { display: flex; align-items: center; gap: 0.5rem; }
|
|
454
|
+
.scalio-access-all { font-weight: 600; }
|
|
455
|
+
.scalio-access-list { max-height: 12rem; overflow-y: auto; display: grid; gap: 0.25rem; }
|
|
456
|
+
.scalio-access-actions { display: flex; justify-content: flex-end; gap: 0.5rem; padding-top: 0.25rem; }
|
|
448
457
|
.scalio-users-empty, .scalio-users-loading { margin: 0; padding: 2rem 1rem; text-align: center; color: hsl(var(--muted-foreground)); border: 1px dashed hsl(var(--border)); border-radius: 2px; }
|
|
449
458
|
.scalio-users-field { display: flex; flex-direction: column; gap: 0.25rem; }
|
|
450
459
|
.scalio-users-field .scalio-field-label { margin-top: 0; }
|
|
@@ -750,6 +759,11 @@
|
|
|
750
759
|
.scalio-mail-providers { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0; padding: 0; border: 0; }
|
|
751
760
|
.scalio-mail-providers legend { width: 100%; margin-bottom: 0.5rem; }
|
|
752
761
|
.scalio-mail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
|
|
762
|
+
.scalio-mail-default { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem; border: 1px solid hsl(var(--border)); border-radius: 2px; background: hsl(var(--muted)); }
|
|
763
|
+
.scalio-mail-default p { margin: 0; }
|
|
764
|
+
.scalio-mail-default-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0; font-size: 0.875rem; }
|
|
765
|
+
.scalio-mail-default-facts dt { color: hsl(var(--muted-foreground)); }
|
|
766
|
+
.scalio-mail-default-facts dd { margin: 0; overflow-wrap: anywhere; }
|
|
753
767
|
.scalio-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
754
768
|
.scalio-mail-test { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
|
|
755
769
|
.scalio-mail-test .scalio-input { flex: 1 1 15rem; width: auto; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.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,
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Which customers an account sees (scalio-docs ADR 0063 U5, backend scalio_tenant.customers): «All customers» or the
|
|
3
|
+
// ticked ones. value = {all, customer_ids}. customerAccessProps() gives UserAdmin its accessColumn and accessField, so
|
|
4
|
+
// every app shows the same column and picker under Konten und Rollen -> Benutzer.
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const h = React.createElement;
|
|
7
|
+
const { labelsFor } = require("./labels");
|
|
8
|
+
|
|
9
|
+
const EMPTY = { all: true, customer_ids: [] };
|
|
10
|
+
|
|
11
|
+
function normalizeAccess(a) {
|
|
12
|
+
if (!a || a.all) return { all: true, customer_ids: [] };
|
|
13
|
+
return { all: false, customer_ids: Array.isArray(a.customer_ids) ? a.customer_ids.slice() : [] };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Text for one account: «All customers», the names of its customers, or «No customer».
|
|
17
|
+
function customerAccessLabel(access, customers, L) {
|
|
18
|
+
const a = normalizeAccess(access);
|
|
19
|
+
if (a.all) return L.allCustomers;
|
|
20
|
+
const names = a.customer_ids.map((id) => ((customers || []).find((c) => c.id === id) || { name: id }).name);
|
|
21
|
+
return names.length ? names.join(", ") : L.noCustomer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Props: value, customers [{id, name}], onChange(value), disabled (administrators always see all), lang, labels,
|
|
25
|
+
// emptyHint (text when there are no customers yet), testId.
|
|
26
|
+
function CustomerAccessEditor(props) {
|
|
27
|
+
const L = labelsFor(props.lang, props.labels).users;
|
|
28
|
+
const value = normalizeAccess(props.value);
|
|
29
|
+
const customers = props.customers || [];
|
|
30
|
+
const testId = props.testId || "customer-access";
|
|
31
|
+
const [open, setOpen] = React.useState(false);
|
|
32
|
+
const [draft, setDraft] = React.useState(value);
|
|
33
|
+
const key = JSON.stringify(value);
|
|
34
|
+
React.useEffect(() => { setDraft(normalizeAccess(props.value)); }, [key]);
|
|
35
|
+
if (props.disabled) return h("span", { className: "scalio-users-hint", "data-testid": testId }, L.allCustomers);
|
|
36
|
+
const toggle = (id) => setDraft(Object.assign({}, draft, {
|
|
37
|
+
customer_ids: draft.customer_ids.includes(id) ? draft.customer_ids.filter((x) => x !== id) : draft.customer_ids.concat([id]),
|
|
38
|
+
}));
|
|
39
|
+
return h("div", { className: "scalio-access", "data-testid": testId },
|
|
40
|
+
h("button", { type: "button", className: "scalio-users-select scalio-access-open", "aria-expanded": open,
|
|
41
|
+
onClick: () => setOpen(!open), "data-testid": `${testId}-open` }, customerAccessLabel(value, customers, L)),
|
|
42
|
+
open ? h("div", { className: "scalio-access-panel", role: "dialog", "aria-label": L.customers },
|
|
43
|
+
h("label", { className: "scalio-access-all" },
|
|
44
|
+
h("input", { type: "checkbox", checked: draft.all, "data-testid": `${testId}-all`,
|
|
45
|
+
onChange: (e) => setDraft(Object.assign({}, draft, { all: e.target.checked })) }),
|
|
46
|
+
L.allCustomers),
|
|
47
|
+
draft.all ? null : customers.length === 0
|
|
48
|
+
? h("p", { className: "scalio-users-hint" }, props.emptyHint || L.noCustomersYet)
|
|
49
|
+
: h("div", { className: "scalio-access-list" }, customers.map((c) => h("label", { key: c.id },
|
|
50
|
+
h("input", { type: "checkbox", checked: draft.customer_ids.includes(c.id), onChange: () => toggle(c.id),
|
|
51
|
+
"data-testid": `${testId}-customer-${c.id}` }),
|
|
52
|
+
c.name))),
|
|
53
|
+
h("div", { className: "scalio-access-actions" },
|
|
54
|
+
h("button", { type: "button", className: "scalio-btn", onClick: () => { setDraft(value); setOpen(false); } }, L.cancel),
|
|
55
|
+
h("button", { type: "button", className: "scalio-btn scalio-btn-primary", "data-testid": `${testId}-save`,
|
|
56
|
+
onClick: () => { props.onChange(draft); setOpen(false); } }, L.save))) : null);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// accessColumn and accessField for UserAdmin. opts: customers, lang, labels, adminRole ("admin"), emptyHint, testId.
|
|
60
|
+
function customerAccessProps(opts) {
|
|
61
|
+
const o = opts || {};
|
|
62
|
+
const L = labelsFor(o.lang, o.labels).users;
|
|
63
|
+
const adminRole = o.adminRole || "admin";
|
|
64
|
+
const prefix = o.testId || "user-access";
|
|
65
|
+
return {
|
|
66
|
+
accessColumn: {
|
|
67
|
+
label: L.customers,
|
|
68
|
+
render: (u) => h("span", { className: "scalio-users-hint" },
|
|
69
|
+
u.role === adminRole ? L.allCustomers : customerAccessLabel(u.raw && u.raw.access, o.customers, L)),
|
|
70
|
+
},
|
|
71
|
+
accessField: (value, onChange, role, u) => h(CustomerAccessEditor, {
|
|
72
|
+
value: value || (u && u.raw && u.raw.access) || EMPTY, customers: o.customers, onChange, disabled: role === adminRole,
|
|
73
|
+
lang: o.lang, labels: o.labels, emptyHint: o.emptyHint, testId: `${prefix}-${u ? u.email : "new"}`,
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = { CustomerAccessEditor, customerAccessLabel, customerAccessProps, normalizeAccess };
|
package/react/index.js
CHANGED
|
@@ -378,6 +378,6 @@ module.exports = {
|
|
|
378
378
|
TEST_IDS,
|
|
379
379
|
initials,
|
|
380
380
|
};
|
|
381
|
-
Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"));
|
|
381
|
+
Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"));
|
|
382
382
|
// After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
|
|
383
383
|
Object.assign(module.exports, require("./auth"), require("./session"));
|
package/react/labels.js
CHANGED
|
@@ -201,6 +201,10 @@ const LABELS = {
|
|
|
201
201
|
user: "Benutzer",
|
|
202
202
|
role: "Rolle",
|
|
203
203
|
access: "Zugriff",
|
|
204
|
+
customers: "Kunden",
|
|
205
|
+
allCustomers: "Alle Kunden",
|
|
206
|
+
noCustomer: "Kein Kunde",
|
|
207
|
+
noCustomersYet: "Noch keine Kunden. Legen Sie sie unter Einstellungen an.",
|
|
204
208
|
lastLogin: "Letzte Anmeldung",
|
|
205
209
|
you: "Sie",
|
|
206
210
|
password: "Passwort",
|
|
@@ -711,6 +715,10 @@ const LABELS = {
|
|
|
711
715
|
user: "User",
|
|
712
716
|
role: "Role",
|
|
713
717
|
access: "Access",
|
|
718
|
+
customers: "Customers",
|
|
719
|
+
allCustomers: "All customers",
|
|
720
|
+
noCustomer: "No customer",
|
|
721
|
+
noCustomersYet: "No customers yet. Add them under Settings.",
|
|
714
722
|
lastLogin: "Last sign-in",
|
|
715
723
|
you: "you",
|
|
716
724
|
password: "Password",
|
package/react/mail.js
CHANGED
|
@@ -12,7 +12,14 @@ const LABELS = {
|
|
|
12
12
|
transportTitle: "E-Mail-Versand",
|
|
13
13
|
transportHint: "Über welchen Server die App Mails schickt. Passwort und Client-Secret werden verschlüsselt gespeichert und nie angezeigt.",
|
|
14
14
|
provider: "Mails senden mit",
|
|
15
|
-
providers: { off: "Aus", smtp: "SMTP-Server", graph: "Microsoft 365", tenant: "Microsoft 365 über die Tenant-Verbindung" },
|
|
15
|
+
providers: { default: "Vorgabe verwenden (empfohlen)", off: "Aus", smtp: "SMTP-Server", graph: "Microsoft 365", tenant: "Microsoft 365 über die Tenant-Verbindung" },
|
|
16
|
+
defaultWays: { smtp: "SMTP-Server", graph: "Microsoft 365", tenant: "Microsoft 365 über die Tenant-Verbindung", scalio: "Über Scalio" },
|
|
17
|
+
defaultFrom: { compass: "Vorgabe aus Compass", installation: "Vorgabe der Installation" },
|
|
18
|
+
defaultSender: "Absender",
|
|
19
|
+
defaultServer: "Server",
|
|
20
|
+
defaultTenant: "Tenant",
|
|
21
|
+
defaultHint: "Gilt für alle Scalio-Apps dieses Kunden. Wählen Sie einen eigenen Weg, wenn diese App anders senden soll (z. B. mit einem eigenen Postfach).",
|
|
22
|
+
defaultNone: "Es gibt noch keine Vorgabe. Bis Compass oder die Installation eine liefert, sendet die App keine Mails.",
|
|
16
23
|
fromName: "Absendername",
|
|
17
24
|
fromAddress: "Absenderadresse",
|
|
18
25
|
language: "Sprache der Mails",
|
|
@@ -78,7 +85,14 @@ const LABELS = {
|
|
|
78
85
|
transportTitle: "E-mail sending",
|
|
79
86
|
transportHint: "Which server the app sends mail through. Password and client secret are stored encrypted and never shown.",
|
|
80
87
|
provider: "Send mail with",
|
|
81
|
-
providers: { off: "Off", smtp: "SMTP server", graph: "Microsoft 365", tenant: "Microsoft 365 through the tenant connection" },
|
|
88
|
+
providers: { default: "Use the default (recommended)", off: "Off", smtp: "SMTP server", graph: "Microsoft 365", tenant: "Microsoft 365 through the tenant connection" },
|
|
89
|
+
defaultWays: { smtp: "SMTP server", graph: "Microsoft 365", tenant: "Microsoft 365 through the tenant connection", scalio: "Through Scalio" },
|
|
90
|
+
defaultFrom: { compass: "Default from Compass", installation: "Default of the installation" },
|
|
91
|
+
defaultSender: "Sender",
|
|
92
|
+
defaultServer: "Server",
|
|
93
|
+
defaultTenant: "Tenant",
|
|
94
|
+
defaultHint: "Applies to all Scalio apps of this customer. Choose an own way if this app should send differently (for example with an own mailbox).",
|
|
95
|
+
defaultNone: "There is no default yet. Until Compass or the installation provides one, the app sends no mail.",
|
|
82
96
|
fromName: "Sender name",
|
|
83
97
|
fromAddress: "Sender address",
|
|
84
98
|
language: "Language of the mails",
|
|
@@ -223,7 +237,9 @@ function select(id, value, options, onChange, extra) {
|
|
|
223
237
|
// offered when the backend lists it in settings.providers, scalio-platform 0.10.0), children (more blocks after «Testmail», e.g. Beacon's
|
|
224
238
|
// mail intake), outbox (false hides «Letzte Mails»). With scalio-platform 0.12.0 the backend may list `tenants` (the app is
|
|
225
239
|
// connected to several tenants: the administrator picks the one that sends) and `send_rights` (the block «Senderecht in
|
|
226
|
-
// Exchange Online» shows the PowerShell from GET /mail/send-rights).
|
|
240
|
+
// Exchange Online» shows the PowerShell from GET /mail/send-rights). With scalio-platform 0.19.0 (ADR 0090) the backend may
|
|
241
|
+
// list the provider `default` («Vorgabe verwenden») and send `default` {available, source, provider, from_name,
|
|
242
|
+
// from_address, tenant_id, smtp_host}: the page shows where the default comes from and where mails go.
|
|
227
243
|
function MailTransport(props) {
|
|
228
244
|
const { client, lang } = props;
|
|
229
245
|
const L = mailLabels(lang, props.labels);
|
|
@@ -262,6 +278,7 @@ function MailTransport(props) {
|
|
|
262
278
|
m.clear();
|
|
263
279
|
try {
|
|
264
280
|
const body = { provider: form.provider, from_name: form.from_name, from_address: form.from_address, language: form.language };
|
|
281
|
+
if (form.provider === "default") delete body.from_address;
|
|
265
282
|
if (form.provider === "smtp") body.smtp = Object.assign({}, form.smtp, { port: Number(form.smtp.port) || 587 });
|
|
266
283
|
if (form.provider === "graph") body.graph = form.graph;
|
|
267
284
|
if (form.provider === "tenant") {
|
|
@@ -318,6 +335,20 @@ function MailTransport(props) {
|
|
|
318
335
|
const tenants = Array.isArray(form.tenants) ? form.tenants : null;
|
|
319
336
|
|
|
320
337
|
const providers = (form.providers || ["off", "smtp", "graph"]).filter((id) => L.providers[id]);
|
|
338
|
+
// ADR 0090: the default from Compass or the installation (scalio-platform 0.19.0); never a secret in it
|
|
339
|
+
const dflt = form.default || null;
|
|
340
|
+
const defaultUsable = !!(dflt && dflt.available);
|
|
341
|
+
const defaultBlock = () => {
|
|
342
|
+
if (!defaultUsable) return h("div", { className: "scalio-notice is-info", "data-testid": "mail-default-none" }, L.defaultNone);
|
|
343
|
+
const facts = [[L.defaultSender, dflt.from_name ? `${dflt.from_name} <${dflt.from_address}>` : dflt.from_address]];
|
|
344
|
+
if (dflt.smtp_host) facts.push([L.defaultServer, dflt.smtp_host]);
|
|
345
|
+
if (dflt.tenant_id) facts.push([L.defaultTenant, dflt.tenant_id]);
|
|
346
|
+
return h("div", { className: "scalio-mail-default", "data-testid": "mail-default" },
|
|
347
|
+
h("p", { className: "scalio-field-label" }, `${L.defaultFrom[dflt.source] || L.defaultFrom.compass}: ${L.defaultWays[dflt.provider] || dflt.provider}`),
|
|
348
|
+
h("dl", { className: "scalio-mail-default-facts" },
|
|
349
|
+
facts.filter((f) => f[1]).map((f) => h(React.Fragment, { key: f[0] }, h("dt", null, f[0]), h("dd", null, f[1])))),
|
|
350
|
+
h("p", { className: "scalio-settings-help" }, L.defaultHint));
|
|
351
|
+
};
|
|
321
352
|
const transport = h(
|
|
322
353
|
SettingsSection,
|
|
323
354
|
{ id: "mail", title: L.transportTitle, description: L.transportHint, testId: "mail-transport" },
|
|
@@ -330,7 +361,13 @@ function MailTransport(props) {
|
|
|
330
361
|
providers.map((id) => h("label", { key: id, className: "scalio-settings-check" },
|
|
331
362
|
h("input", { type: "radio", name: "mail-provider", checked: form.provider === id, "data-testid": `mail-provider-${id}`,
|
|
332
363
|
onChange: () => set({ provider: id }) }), h("span", null, L.providers[id])))),
|
|
333
|
-
form.provider
|
|
364
|
+
form.provider === "default" ? defaultBlock() : null,
|
|
365
|
+
form.provider === "default"
|
|
366
|
+
? h("div", { className: "scalio-mail-grid" },
|
|
367
|
+
h(Field, { id: "mail-lang", label: L.language, hint: L.languageHint },
|
|
368
|
+
select("mail-lang", form.language, [["de", L.languages.de], ["en", L.languages.en]], (v) => set({ language: v }), { disabled: busy })))
|
|
369
|
+
: null,
|
|
370
|
+
form.provider !== "off" && form.provider !== "default"
|
|
334
371
|
? h("div", { className: "scalio-mail-grid" },
|
|
335
372
|
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 })),
|
|
336
373
|
form.provider === "smtp"
|
|
@@ -392,12 +429,12 @@ function MailTransport(props) {
|
|
|
392
429
|
{ id: "mail-test", title: L.testTitle, description: L.testHint, testId: "mail-test-section" },
|
|
393
430
|
h("div", { className: "scalio-mail-test" },
|
|
394
431
|
input("mail-test-to", to, setTo, { type: "email", placeholder: L.recipient, "aria-label": L.recipient, maxLength: 254 }),
|
|
395
|
-
h("button", { type: "button", className: "scalio-btn", onClick: test, disabled: testing || form.provider === "off", "data-testid": "mail-test" },
|
|
432
|
+
h("button", { type: "button", className: "scalio-btn", onClick: test, disabled: testing || form.provider === "off" || (form.provider === "default" && !defaultUsable), "data-testid": "mail-test" },
|
|
396
433
|
h(Icons.CornerDownLeft, { className: "scalio-icon" }), L.sendTest)),
|
|
397
434
|
h(Notice, { msg: testMsg, testId: "mail-test-message" })
|
|
398
435
|
);
|
|
399
436
|
|
|
400
|
-
const rights = form.send_rights && (form.provider === "graph" || form.provider === "tenant")
|
|
437
|
+
const rights = form.send_rights && (form.provider === "graph" || form.provider === "tenant" || form.provider === "default")
|
|
401
438
|
? h(
|
|
402
439
|
SettingsSection,
|
|
403
440
|
{ id: "mail-rights", title: L.rightsTitle, description: L.rightsHint, testId: "mail-rights" },
|