@scalio-cloud/ui 0.89.0 → 0.90.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 CHANGED
@@ -873,6 +873,23 @@ The package holds only design values and fonts under the SIL OFL, nothing confid
873
873
  Design tokens and preset: (c) Scalio Cloud LLC, free to use in Scalio apps. Fonts: SIL Open Font License 1.1,
874
874
  see `fonts/licenses/`. Icons in `react/icons.js`: Lucide, ISC license, see `licenses/lucide-LICENSE.txt`.
875
875
 
876
+ ## Limited Mode banner: `LimitedModeBanner` (React, from 0.90.0)
877
+
878
+ One banner for all apps instead of one per app (scalio-docs ADR 0126). Over the license limit the backend
879
+ (scalio-license) sends `over` and, from day 15, `limited: true`. The banner shows nothing for the first 7 days, a yellow
880
+ notice with the date from day 8, and a red "Limited mode: read-only" from day 15. German and English, de-CH / en-GB date.
881
+
882
+ ```jsx
883
+ import { LimitedModeBanner } from "@scalio-cloud/ui/react";
884
+ <LimitedModeBanner license={license} product="Citadel" unit="users" lang={lang} onOpen={() => navigate("/settings/license")} />
885
+ ```
886
+
887
+ `license`: `{ limited, limited_reason?, over: { <kind>: { current, limit, notice_from, limited_from } } }` as the backend sends it.
888
+ `unit`: `users` (active Microsoft 365 users, default), `tenants` or `desktops`. Without an excess but with `limited: true`
889
+ (ended subscription, Atrium) the red banner shows `limited_reason` or a default text. `onOpen` adds the link "Lizenz" / "License".
890
+ Test ids: `license-limit-banner` (yellow), `license-limited-banner` (red), `license-limit-link`. `limitedModeState(license, now)`
891
+ returns the state (`null`, `notice`, `limited`, `subscription`) for apps that need it elsewhere. Texts: `LABELS.<lang>.limitedMode`.
892
+
876
893
  ## Eingabefelder prüfen: `Input` (React, from 0.44.0)
877
894
 
878
895
  Taken over from Scalio Kontor, so every app checks fields the same way. `<Input check="…">` is the native
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.89.0",
3
+ "version": "0.90.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/index.js CHANGED
@@ -386,6 +386,6 @@ module.exports = {
386
386
  TEST_IDS,
387
387
  initials,
388
388
  };
389
- 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"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./agent_scripts"), require("./ai"), require("./markdown"), require("./tenancy"), require("./legal"));
389
+ Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./limited_mode"), 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"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./agent_scripts"), require("./ai"), require("./markdown"), require("./tenancy"), require("./legal"));
390
390
  // After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
391
391
  Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./clientErrors"));
package/react/labels.js CHANGED
@@ -503,6 +503,19 @@ const LABELS = {
503
503
  setUpFactor: "Zum Profil",
504
504
  run: "Auf Werkseinstellungen zurücksetzen",
505
505
  },
506
+ limitedMode: {
507
+ license: "Lizenz",
508
+ limitedTitle: "Eingeschränkter Modus: nur lesen",
509
+ limited: "{current} {unit}, die Lizenz deckt {limit}. {product} liest nur noch, bis die Lizenz erweitert wird oder die Zahl sinkt.",
510
+ notice: "{current} {unit}, die Lizenz deckt {limit}. Ab {date} liest {product} nur noch (eingeschränkter Modus). Bitte erweitern Sie die Lizenz oder senken Sie die Zahl.",
511
+ noticeNoDate: "{current} {unit}, die Lizenz deckt {limit}. Bald liest {product} nur noch (eingeschränkter Modus). Bitte erweitern Sie die Lizenz oder senken Sie die Zahl.",
512
+ subscription: "Das Abonnement ist abgelaufen. {product} liest nur noch, bis ein neuer Lizenzschlüssel eingegeben wird. Die Daten bleiben erhalten.",
513
+ units: {
514
+ users: { title: "Mehr Benutzer als lizenziert", count: "aktive Microsoft-365-Benutzer" },
515
+ tenants: { title: "Mehr Tenants als lizenziert", count: "Tenants" },
516
+ desktops: { title: "Mehr Desktops als lizenziert", count: "Desktops" },
517
+ },
518
+ },
506
519
  license: {
507
520
  title: "Lizenz",
508
521
  hint: "Lizenzen kaufen und verlängern Sie in Scalio Compass. Der Schlüssel gilt nur für die Installations-ID unten.",
@@ -1075,6 +1088,19 @@ const LABELS = {
1075
1088
  setUpFactor: "Go to profile",
1076
1089
  run: "Reset to factory settings",
1077
1090
  },
1091
+ limitedMode: {
1092
+ license: "License",
1093
+ limitedTitle: "Limited mode: read-only",
1094
+ limited: "{current} {unit}, the license covers {limit}. {product} only reads until the license is extended or the number drops.",
1095
+ notice: "{current} {unit}, the license covers {limit}. From {date} {product} only reads (limited mode). Please extend the license or reduce the number.",
1096
+ noticeNoDate: "{current} {unit}, the license covers {limit}. Soon {product} will only read (limited mode). Please extend the license or reduce the number.",
1097
+ subscription: "The subscription has ended. {product} only reads until a new license key is entered. Data is kept.",
1098
+ units: {
1099
+ users: { title: "More users than licensed", count: "active Microsoft 365 users" },
1100
+ tenants: { title: "More tenants than licensed", count: "tenants" },
1101
+ desktops: { title: "More desktops than licensed", count: "desktops" },
1102
+ },
1103
+ },
1078
1104
  license: {
1079
1105
  title: "License",
1080
1106
  hint: "Buy or extend a license in Scalio Compass. The key is bound to the installation ID below.",
@@ -1164,6 +1190,7 @@ function labelsFor(lang, overrides) {
1164
1190
  mfa: Object.assign({}, base.mfa, o.mfa),
1165
1191
  users: Object.assign({}, base.users, o.users),
1166
1192
  license: Object.assign({}, base.license, o.license),
1193
+ limitedMode: Object.assign({}, base.limitedMode, o.limitedMode, { units: Object.assign({}, base.limitedMode.units, (o.limitedMode || {}).units) }),
1167
1194
  edition: Object.assign({}, base.edition, o.edition),
1168
1195
  accountTabs: Object.assign({}, base.accountTabs, o.accountTabs),
1169
1196
  passwordPolicy: Object.assign({}, base.passwordPolicy, o.passwordPolicy),
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ // Limited Mode banner (scalio-docs ADR 0126): over the license limit the app warns for 7 days, announces the date
3
+ // from day 8 (yellow), and is read-only from day 15 (red). The backend (scalio-license) sends `over` and `limited`:
4
+ // license = { limited: bool, limited_reason?: string,
5
+ // over: { <kind>: { current, limit, since, notice_from, limited_from } } }
6
+ // The banner only shows what the backend decided; nothing is calculated except "has notice_from passed".
7
+ const React = require("react");
8
+ const h = React.createElement;
9
+ const Icons = require("./icons");
10
+ const { labelsFor } = require("./labels");
11
+ const { Notice } = require("./blocks");
12
+
13
+ function fill(text, values) {
14
+ return String(text || "").replace(/\{(\w+)\}/g, (m, k) => (values && values[k] !== undefined ? values[k] : m));
15
+ }
16
+
17
+ function validDate(v) {
18
+ const d = v instanceof Date ? v : new Date(v);
19
+ return Number.isNaN(d.getTime()) ? null : d;
20
+ }
21
+
22
+ // -> null (show nothing) | { kind: "notice", current, limit, ... } | { kind: "limited", ... } |
23
+ // { kind: "subscription", reason } (read-only without an excess, e.g. an ended subscription).
24
+ function limitedModeState(license, now) {
25
+ if (!license) return null;
26
+ const over = Object.values(license.over || {})[0];
27
+ if (!over) return license.limited ? { kind: "subscription", reason: license.limited_reason || "" } : null;
28
+ if (license.limited) return { kind: "limited", ...over };
29
+ const from = validDate(over.notice_from);
30
+ if (from && (now || new Date()) >= from) return { kind: "notice", ...over };
31
+ return null;
32
+ }
33
+
34
+ // Props: license, product ("Citadel"), unit ("users" | "tenants" | "desktops", default users), lang, labels,
35
+ // onOpen (adds the link "Lizenz" / "License"), icon, now (tests), testId prefix is fixed:
36
+ // license-limited-banner (red), license-limit-banner (yellow), license-limit-link.
37
+ function LimitedModeBanner(props) {
38
+ const s = limitedModeState(props.license, props.now);
39
+ if (!s) return null;
40
+ const L = labelsFor(props.lang, props.labels).limitedMode;
41
+ const product = props.product || "Scalio";
42
+ const unit = (L.units[props.unit] || L.units.users);
43
+ const action = props.onOpen ? { label: L.license, onClick: props.onOpen, testId: "license-limit-link" } : undefined;
44
+ const common = { banner: true, icon: props.icon || Icons.Alert, lang: props.lang, labels: props.labels, action };
45
+ if (s.kind === "subscription")
46
+ return h(Notice, Object.assign({ kind: "error", testId: "license-limited-banner", title: L.limitedTitle }, common),
47
+ s.reason || fill(L.subscription, { product }));
48
+ const values = { current: s.current, limit: s.limit, unit: unit.count, product };
49
+ if (s.kind === "limited")
50
+ return h(Notice, Object.assign({ kind: "error", testId: "license-limited-banner", title: L.limitedTitle }, common),
51
+ fill(L.limited, values));
52
+ const date = validDate(s.limited_from);
53
+ const when = date ? date.toLocaleDateString(props.lang === "en" ? "en-GB" : "de-CH") : "";
54
+ return h(Notice, Object.assign({ kind: "warn", testId: "license-limit-banner", title: unit.title }, common),
55
+ fill(date ? L.notice : L.noticeNoDate, Object.assign(values, { date: when })));
56
+ }
57
+
58
+ module.exports = { LimitedModeBanner, limitedModeState };