@scalio-cloud/ui 0.38.0 → 0.39.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 +9 -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/shadcn/sonner.mjs +1 -0
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; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.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/shadcn/sonner.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// shadcn/ui component shared by the Scalio apps (code-quality plan QA6, Grundregel 8). Import it as
|
|
2
2
|
// "@scalio-cloud/ui/shadcn/sonner"; the app installs the Radix peer dependencies it uses (README).
|
|
3
|
+
import * as React from "react";
|
|
3
4
|
import { Toaster as Sonner, toast } from "sonner";
|
|
4
5
|
const Toaster = ({
|
|
5
6
|
theme = "system",
|