@scalio-cloud/ui 0.91.0 → 0.93.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
@@ -80,6 +80,7 @@ server {
80
80
  | `TRUSTED_PROXIES` | Proxies whose `X-Forwarded-For` counts (Caddy, Azure front end); the last entry is used |
81
81
  | `SCALIO_APP` | App name (`nexus`, …) for the app-specific machine paths |
82
82
  | `SCALIO_GEOIP_DB` | Country database, default `/etc/nginx/geoip/dbip-country.mmdb` |
83
+ | `SCALIO_ACCESS_STATUS` | Public status file, default `/usr/share/nginx/html/access-status.json` (from 0.93.0) |
83
84
 
84
85
  Both lists empty: no limit (both files stay empty). An address passes if it is in the IP list or its country is
85
86
  allowed. An invalid entry closes the instance for everyone except the machine paths and names the entry in the log
@@ -88,6 +89,23 @@ allowed. An invalid entry closes the instance for everyone except the machine pa
88
89
  `ngx_http_geoip2_module` and the free DB-IP «IP to Country Lite» database (CC BY 4.0: show «IP Geolocation by DB-IP»
89
90
  on the about page). Tests (`test/access.test.js`) run with real nginx when it is installed.
90
91
 
92
+ ### Show the limit in the settings: `AccessLimitStatus` (React, from 0.93.0)
93
+
94
+ At start the script also writes `access-status.json` into the web root (nginx serves it like any static file):
95
+ `{ "active": true, "ip_ranges": 3, "countries": ["CH", "DE"], "countries_unavailable": false, "invalid": false }`.
96
+ Only numbers and country codes, never an IP address. `countries_unavailable`: countries set but no database or geoip2
97
+ module (only the IP list counts); `invalid`: a wrong entry closed the instance. A file that cannot be written only
98
+ logs a line; the settings then show «Status nicht verfügbar». The component reads it (read only, changing happens in
99
+ Scalio Compass) and belongs in Einstellungen -> Sicherheit:
100
+
101
+ ```jsx
102
+ import { AccessLimitStatus } from "@scalio-cloud/ui/react";
103
+ <AccessLimitStatus lang={lang} /> // props: status (skips the request), url, fetcher, labels
104
+ ```
105
+
106
+ Test ids: `access-limit`, `access-limit-state`, `access-limit-ips`, `access-limit-countries`, `access-limit-warn`.
107
+ `accessLimitState(data)` returns `off`, `on`, `partial`, `invalid` or `null`. Texts: `LABELS.<lang>.accessLimit`.
108
+
91
109
  ## Sign-in state (React, from 0.37.0)
92
110
 
93
111
  `createAuth({ api, formatError, signInWithPasskey, passkeyCancelled, legacyTokenKey })` gives `{ AuthProvider,
@@ -232,11 +250,11 @@ app's tabs. `<TenantList tenants columns actions appName limit onAdd />` is the
232
250
  columns Tenant, Organisation (only with several), Verbindungsart, Zugang, Status, then the app's columns; buttons
233
251
  Bearbeiten (opens `TenantEditDialog` with all tabs, since 0.81.0) and Entfernen; «+ Tenant» stops at `limits.tenants`). `<TenantWizard>` adds a
234
252
  tenant in four steps (Name und Organisation → Verbindung und Zugang → `<App>`-Einstellungen → Prüfen; the tenant is
235
- created after step 1 by `onCreate`, `renderConnect` embeds the connection, `appStep` is the app's step, locked
253
+ created only at the end («Prüfen») by `onCreate` (steps before only check with `onValidate` and keep values in memory; cancel creates nothing), `renderConnect(null, values, set)` embeds the connection, `appStep` is the app's step, locked
236
254
  methods stay visible with their reason). `<TenantEditDialog>` shows the same parts as tabs.
237
255
  `<TenancySelect organizations tenants tenantId onSelect manage />` (0.81.0) is the selection at the top: the
238
- organization (only with more than one) and, when the chosen organization has more than one tenant, its tenant; with
239
- one organization only the tenant select (only with several). The app keeps one value, the tenant id.
256
+ organization (from two organizations on, whatever their tenant counts) and, when the chosen organization has more than one tenant, its tenant; with
257
+ one organization only the tenant select (only with several). `hideAll` drops «Alle …». The app keeps one value, the tenant id.
240
258
  `organizationSetupStep({value, onChange, onSave, prefilled})` is the setup step «Organisation» (name, short code,
241
259
  classification, language; prefilled from the Microsoft sign-in). `showOrganizationSelect` / `showTenantSelect`: the
242
260
  selects at the top only with more than one (ADR 0128 O5). Never show prices in these parts.
@@ -8,6 +8,8 @@
8
8
  # loaded in nginx.conf (load_module, or modules/*.conf as in the Alpine package)
9
9
  # TRUSTED_PROXIES CIDR list of the proxy in front (Caddy network, Azure ingress); its X-Forwarded-For counts
10
10
  # SCALIO_APP nexus, citadel, … : picks the app's machine paths (machine-paths.txt)
11
+ # SCALIO_ACCESS_STATUS public status file for the settings page, default /usr/share/nginx/html/access-status.json
12
+ # (active yes/no, number of IP ranges, countries; never an address); cannot be written: only a log line
11
13
  # SCALIO_GEOIP_DB country database (DB-IP «IP to Country Lite», mmdb); default /etc/nginx/geoip/dbip-country.mmdb
12
14
  #
13
15
  # Allowed is who is in the IP list OR in an allowed country; machine paths stay open. Everyone else gets 403 with a
@@ -25,6 +27,7 @@ PATHS_FILE="${SCALIO_MACHINE_PATHS_FILE:-$(dirname "$0")/machine-paths.txt}"
25
27
  GEOIP_DB="${SCALIO_GEOIP_DB:-$DIR/geoip/dbip-country.mmdb}"
26
28
  NGINX_CONF="${SCALIO_NGINX_CONF:-$DIR/nginx.conf}"
27
29
  APP="${SCALIO_APP:-}"
30
+ STATUS_FILE="${SCALIO_ACCESS_STATUS:-/usr/share/nginx/html/access-status.json}"
28
31
 
29
32
  log() { echo "scalio-access: $*" >&2; }
30
33
 
@@ -50,6 +53,18 @@ valid_cidr() {
50
53
  return 0
51
54
  }
52
55
 
56
+ # Public status for the settings (AccessLimitStatus): numbers and country codes only, never an IP address.
57
+ # $1 active (true|false), $2 ip ranges, $3 countries (space separated), $4 countries unavailable, $5 invalid entries
58
+ write_status() {
59
+ cl=""
60
+ for c in $3; do cl="${cl:+$cl, }\"$c\""; done
61
+ if ! { mkdir -p "$(dirname "$STATUS_FILE")" &&
62
+ printf '{"active": %s, "ip_ranges": %s, "countries": [%s], "countries_unavailable": %s, "invalid": %s}\n' \
63
+ "$1" "$2" "$cl" "$4" "$5" > "$STATUS_FILE.tmp" && mv "$STATUS_FILE.tmp" "$STATUS_FILE"; } 2>/dev/null; then
64
+ log "cannot write the status file $STATUS_FILE (the settings page shows no status)"
65
+ fi
66
+ }
67
+
53
68
  IPS=$(words "${ALLOWED_CLIENT_IPS:-}")
54
69
  COUNTRIES=$(words "${ALLOWED_COUNTRIES:-}" | tr 'a-z' 'A-Z')
55
70
  PROXIES=$(words "${TRUSTED_PROXIES:-}")
@@ -58,27 +73,34 @@ mkdir -p "$(dirname "$HTTP_CONF")" "$(dirname "$SERVER_CONF")"
58
73
  if [ -z "$IPS" ] && [ -z "$COUNTRIES" ]; then
59
74
  : > "$HTTP_CONF"
60
75
  : > "$SERVER_CONF"
76
+ write_status false 0 "" false false
61
77
  log "no access limit (ALLOWED_CLIENT_IPS and ALLOWED_COUNTRIES empty)"
62
78
  exit 0
63
79
  fi
64
80
 
65
81
  broken=""
82
+ invalid=false
66
83
  for c in $IPS $PROXIES; do valid_cidr "$c" || broken="$broken $c"; done
67
84
  for c in $COUNTRIES; do echo "$c" | grep -Eq '^[A-Z]{2}$' || broken="$broken $c"; done
68
85
  geo_ok=1
86
+ geo_missing=false
69
87
  if [ -n "$COUNTRIES" ] && [ ! -r "$GEOIP_DB" ]; then
70
- geo_ok=0
88
+ geo_ok=0; geo_missing=true
71
89
  log "ALLOWED_COUNTRIES set, but no country database at $GEOIP_DB: only the IP list counts"
72
90
  elif [ -n "$COUNTRIES" ] && ! cat "$NGINX_CONF" "$DIR"/modules/*.conf "$DIR"/modules-enabled/*.conf 2>/dev/null \
73
91
  | grep -v '^[[:space:]]*#' | grep -q 'ngx_http_geoip2_module'; then
74
92
  # Without load_module nginx would refuse the geoip2 block and not start at all.
75
- geo_ok=0
93
+ geo_ok=0; geo_missing=true
76
94
  log "ALLOWED_COUNTRIES set, but the geoip2 module is not loaded ($NGINX_CONF): only the IP list counts"
77
95
  fi
78
96
  if [ -n "$broken" ]; then
79
97
  log "invalid entries:$broken -> access closed for everyone except the machine paths"
80
98
  IPS=""; COUNTRIES=""
99
+ invalid=true
81
100
  fi
101
+ COUNTRIES_SHOWN="$COUNTRIES"
102
+ [ "$geo_ok" = 1 ] || COUNTRIES_SHOWN=""
103
+ write_status true "$(echo "$IPS" | wc -w | tr -d ' ')" "$COUNTRIES_SHOWN" "$geo_missing" "$invalid"
82
104
 
83
105
  {
84
106
  echo "# Written by scalio-access (@scalio-cloud/ui nginx/access-limit.sh) at container start. Do not edit."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.91.0",
3
+ "version": "0.93.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,66 @@
1
+ "use strict";
2
+ // Einstellungen -> Sicherheit: shows the IP and country limit of the instance (scalio-docs ADR 0085, zugang/Z1).
3
+ // nginx/access-limit.sh writes /access-status.json at container start:
4
+ // { active, ip_ranges, countries: ["CH"], countries_unavailable?, invalid? } (numbers and codes, never an address)
5
+ // Read only: the limit is set in Scalio Compass (ALLOWED_CLIENT_IPS / ALLOWED_COUNTRIES), not here.
6
+ const React = require("react");
7
+ const h = React.createElement;
8
+ const { labelsFor } = require("./labels");
9
+ const { StatusBadge, Notice } = require("./blocks");
10
+ const { SettingsSection, SettingsRow } = require("./settings");
11
+
12
+ // -> null (unknown) | { kind: "off" | "on" | "partial" | "invalid", ipRanges, countries }
13
+ function accessLimitState(data) {
14
+ if (!data || typeof data.active !== "boolean") return null;
15
+ const countries = (Array.isArray(data.countries) ? data.countries : [])
16
+ .filter((c) => typeof c === "string" && c).map((c) => c.toUpperCase());
17
+ const n = Number(data.ip_ranges);
18
+ const ipRanges = Number.isFinite(n) && n > 0 ? Math.floor(n) : 0;
19
+ if (!data.active) return { kind: "off", ipRanges: 0, countries: [] };
20
+ const kind = data.invalid ? "invalid" : data.countries_unavailable ? "partial" : "on";
21
+ return { kind, ipRanges, countries };
22
+ }
23
+
24
+ // Props: status (the parsed file; skips the request), url (default /access-status.json), fetcher (tests), lang, labels.
25
+ function AccessLimitStatus(props) {
26
+ const L = labelsFor(props.lang, props.labels).accessLimit;
27
+ const [data, setData] = React.useState(props.status || null);
28
+ const [loaded, setLoaded] = React.useState(!!props.status);
29
+ React.useEffect(() => {
30
+ if (props.status) { setData(props.status); setLoaded(true); return undefined; }
31
+ let alive = true;
32
+ const get = props.fetcher || (typeof fetch === "function" ? fetch : null);
33
+ const done = (d) => { if (alive) { setData(d); setLoaded(true); } };
34
+ if (!get) { done(null); return undefined; }
35
+ Promise.resolve()
36
+ .then(() => get(props.url || "/access-status.json", { cache: "no-store", headers: { Accept: "application/json" } }))
37
+ .then((r) => (r && r.ok ? r.json() : null))
38
+ .then(done, () => done(null));
39
+ return () => { alive = false; };
40
+ }, [props.status, props.url, props.fetcher]);
41
+
42
+ const s = accessLimitState(data);
43
+ const text = !loaded ? L.loading : !s ? L.unknown : s.kind === "off" ? L.off : L.on;
44
+ const tone = !s ? "neutral" : s.kind === "off" ? "neutral" : s.kind === "on" ? "ok" : "warn";
45
+ const ips = s && s.ipRanges === 1 ? L.ipOne : (L.ipMany || "").replace("{n}", s ? s.ipRanges : 0);
46
+ return h(
47
+ SettingsSection,
48
+ { id: "access-limit", title: L.title, description: L.hint, testId: "access-limit" },
49
+ h(SettingsRow, { title: L.state }, h(StatusBadge, { tone, testId: "access-limit-state" }, text)),
50
+ s && s.kind !== "off"
51
+ ? h(
52
+ "div",
53
+ { className: "scalio-settings-form" },
54
+ h(SettingsRow, { title: L.ips }, h("span", { "data-testid": "access-limit-ips" }, ips)),
55
+ h(SettingsRow, { title: L.countries },
56
+ h("span", { "data-testid": "access-limit-countries" }, s.countries.length ? s.countries.join(", ") : L.none)),
57
+ h("p", { className: "scalio-settings-help", "data-testid": "access-limit-machine" }, L.machine),
58
+ s.kind === "invalid" ? h(Notice, { kind: "error", testId: "access-limit-warn", lang: props.lang, labels: props.labels }, L.invalid) : null,
59
+ s.kind === "partial" ? h(Notice, { kind: "warn", testId: "access-limit-warn", lang: props.lang, labels: props.labels }, L.noCountryDb) : null
60
+ )
61
+ : null,
62
+ h("p", { className: "scalio-settings-help", "data-testid": "access-limit-where" }, L.where)
63
+ );
64
+ }
65
+
66
+ module.exports = { AccessLimitStatus, accessLimitState };
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("./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"));
389
+ Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./limited_mode"), require("./access_limit"), 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,24 @@ const LABELS = {
503
503
  setUpFactor: "Zum Profil",
504
504
  run: "Auf Werkseinstellungen zurücksetzen",
505
505
  },
506
+ accessLimit: {
507
+ title: "Zugriff eingrenzen",
508
+ hint: "Wer diese Instanz öffnen darf: nach IP-Adresse oder Land.",
509
+ state: "Stand",
510
+ loading: "Wird geladen …",
511
+ unknown: "Status nicht verfügbar",
512
+ off: "Keine Eingrenzung: jede Adresse darf zugreifen",
513
+ on: "Eingegrenzt",
514
+ ips: "Erlaubte IP-Bereiche",
515
+ ipOne: "1 IP-Bereich",
516
+ ipMany: "{n} IP-Bereiche",
517
+ countries: "Erlaubte Länder",
518
+ none: "Keine",
519
+ machine: "Maschinen-Pfade (Health, Version, Provisionierung) bleiben immer offen. Wer weder in einem IP-Bereich noch in einem erlaubten Land ist, sieht eine Seite «Zugriff nicht freigegeben».",
520
+ invalid: "Ein Eintrag der Eingrenzung ist ungültig. Aus Sicherheitsgründen ist der Zugriff für alle gesperrt, bis der Eintrag in Scalio Compass korrigiert ist.",
521
+ noCountryDb: "Die Länderdatenbank ist in dieser Instanz nicht verfügbar. Es gelten nur die IP-Bereiche; die Länder sind noch nicht wirksam.",
522
+ where: "Die Eingrenzung ändern Sie in Scalio Compass unter «Zugriff eingrenzen». Die Änderung gilt nach dem nächsten Start der Instanz. Die IP-Adressen selbst werden hier nicht angezeigt.",
523
+ },
506
524
  limitedMode: {
507
525
  license: "Lizenz",
508
526
  limitedTitle: "Eingeschränkter Modus: nur lesen",
@@ -1088,6 +1106,24 @@ const LABELS = {
1088
1106
  setUpFactor: "Go to profile",
1089
1107
  run: "Reset to factory settings",
1090
1108
  },
1109
+ accessLimit: {
1110
+ title: "Restrict access",
1111
+ hint: "Who may open this instance: by IP address or country.",
1112
+ state: "Status",
1113
+ loading: "Loading …",
1114
+ unknown: "Status not available",
1115
+ off: "No restriction: every address may connect",
1116
+ on: "Restricted",
1117
+ ips: "Allowed IP ranges",
1118
+ ipOne: "1 IP range",
1119
+ ipMany: "{n} IP ranges",
1120
+ countries: "Allowed countries",
1121
+ none: "None",
1122
+ machine: "Machine paths (health, version, provisioning) always stay open. Anyone outside the IP ranges and the allowed countries sees an «Access not allowed» page.",
1123
+ invalid: "An entry of the restriction is invalid. For safety access is closed for everyone until the entry is corrected in Scalio Compass.",
1124
+ noCountryDb: "The country database is not available in this instance. Only the IP ranges apply; the countries are not effective yet.",
1125
+ where: "Change the restriction in Scalio Compass under «Restrict access». It applies after the next start of the instance. The IP addresses themselves are not shown here.",
1126
+ },
1091
1127
  limitedMode: {
1092
1128
  license: "License",
1093
1129
  limitedTitle: "Limited mode: read-only",
@@ -1190,6 +1226,7 @@ function labelsFor(lang, overrides) {
1190
1226
  mfa: Object.assign({}, base.mfa, o.mfa),
1191
1227
  users: Object.assign({}, base.users, o.users),
1192
1228
  license: Object.assign({}, base.license, o.license),
1229
+ accessLimit: Object.assign({}, base.accessLimit, o.accessLimit),
1193
1230
  limitedMode: Object.assign({}, base.limitedMode, o.limitedMode, { units: Object.assign({}, base.limitedMode.units, (o.limitedMode || {}).units) }),
1194
1231
  edition: Object.assign({}, base.edition, o.edition),
1195
1232
  accountTabs: Object.assign({}, base.accountTabs, o.accountTabs),
package/react/tenancy.js CHANGED
@@ -471,26 +471,27 @@ function ConnectionChoice({ value, onChange, methods, locked, writeLocked, write
471
471
  }
472
472
 
473
473
  // «Tenant hinzufügen» in four steps (ADR 0128 point 6): Name und Organisation → Verbindung und Zugang →
474
- // <App>-Einstellungen → Prüfen. The tenant is created when step 1 is done (`onCreate(values) -> tenant`), so step 2 can
475
- // connect it (`renderConnect(tenant, values)`, e.g. TenantConnectStep). `appStep(tenant, values, setValues)` returns
476
- // {content, canNext?, onNext?} or null (no step 3). `onFinish(tenant, values)` saves the rest.
474
+ // <App>-Einstellungen → Prüfen. Nothing is created before the last step: the steps before only check
475
+ // (`onValidate(values)`, throws to stay on step 1) and keep the values in memory (`renderConnect(null, values, setValues)`,
476
+ // `appStep(null, values, setValues)` return {content, canNext?, onNext?} or null for no step 3). On «Prüfen» the wizard
477
+ // calls `onCreate(values) -> tenant` and then `onFinish(tenant, values)` (connect, app settings). Cancel creates nothing.
477
478
  function TenantWizard(props) {
478
479
  const { open, onClose, organizations, defaultOrganization, methods, locked, writeLocked, writeHidden, methodText,
479
- appName, appStep, renderConnect, onCreate, onFinish, lang, labels, review } = props;
480
+ appName, appStep, renderConnect, onValidate, onCreate, onFinish, lang, labels, review } = props;
480
481
  const L = tenancyLabels(lang, labels);
481
482
  const orgs = organizations || [];
482
483
  const first = () => ({ name: "", domain: "", organization_id: defaultOrganization || (orgs[0] && orgs[0].id) || "",
483
484
  method: (methods || ["direct"]).find((m) => !(locked || {})[m]) || "direct", write: false });
484
485
  const [step, setStep] = React.useState(0);
485
486
  const [values, setValues] = React.useState(first);
486
- const [tenant, setTenant] = React.useState(null);
487
- React.useEffect(() => { if (open) { setStep(0); setValues(first()); setTenant(null); } }, [open]); // eslint-disable-line react-hooks/exhaustive-deps
487
+ const tenant = null; // nothing exists before the last step
488
+ React.useEffect(() => { if (open) { setStep(0); setValues(first()); } }, [open]); // eslint-disable-line react-hooks/exhaustive-deps
488
489
  if (!open) return null;
489
490
  const set = (patch) => setValues((s) => Object.assign({}, s, patch));
490
491
  const app = appStep ? appStep(tenant, values, set) : null;
491
492
  const steps = [
492
493
  { id: "name", label: L.stepName, title: L.stepName, canNext: !!values.name.trim() && (!orgs.length || !!values.organization_id),
493
- onNext: async () => { if (!tenant) setTenant(await onCreate(values)); },
494
+ onNext: async () => { if (onValidate) await onValidate(values); },
494
495
  content: h("div", { className: "scalio-tenancy-grid" },
495
496
  h(Field, { label: L.tenantName, hint: L.tenantNameHint },
496
497
  h("input", { className: "scalio-input", value: values.name, onChange: (e) => set({ name: e.target.value }), "data-testid": "tenant-wizard-name" })),
@@ -502,7 +503,7 @@ function TenantWizard(props) {
502
503
  { id: "connection", label: L.stepConnection, title: L.stepConnection,
503
504
  content: h(React.Fragment, null,
504
505
  h(ConnectionChoice, { value: values, onChange: setValues, methods, locked, writeLocked, writeHidden, methodText, lang, labels }),
505
- renderConnect && tenant && values.method !== "simulated" ? h("div", { className: "scalio-tenancy-connect", "data-testid": "tenant-wizard-connect" }, renderConnect(tenant, values)) : null) },
506
+ renderConnect && values.method !== "simulated" ? h("div", { className: "scalio-tenancy-connect", "data-testid": "tenant-wizard-connect" }, renderConnect(tenant, values, set)) : null) },
506
507
  ];
507
508
  if (app) steps.push(Object.assign({ id: "app", label: fill(L.settings, { app: appName || "App" }), title: fill(L.settings, { app: appName || "App" }) }, app));
508
509
  const rows = [[L.tenantName, values.name], [L.domain, values.domain], orgs.length ? [L.organization, (orgs.find((o) => o.id === values.organization_id) || {}).name] : null,
@@ -514,7 +515,10 @@ function TenantWizard(props) {
514
515
  return h(SetupWizard, {
515
516
  open, title: L.addTenantTitle, steps, step, onStepChange: setStep, onClose, wide: true, lang, testId: "tenant-wizard",
516
517
  success: { title: L.finished, text: L.finishedText },
517
- onFinish: () => onFinish && onFinish(tenant, values),
518
+ onFinish: async () => {
519
+ const created = onCreate ? await onCreate(values) : null;
520
+ if (onFinish) await onFinish(created, values);
521
+ },
518
522
  onDone: onClose,
519
523
  });
520
524
  }
@@ -560,24 +564,29 @@ function TenantEditDialog({ tenant, organizations, onSave, onClose, renderConnec
560
564
  // The selection at the top of every app (ADR 0128 O5, Markus 2026-11-15): first the organization, and only when the
561
565
  // chosen organization has more than one tenant also its tenant. With one organization only the tenant select (when
562
566
  // there are several). The app keeps one value, the tenant id ("" = all): choosing an organization with one tenant picks
563
- // that tenant, one with several picks its first. `manage` = {label?, onSelect} adds «Mandanten verwalten …».
567
+ // that tenant, one with several picks its first, one without tenants picks none (""). The organization select shows
568
+ // from two organizations on, whatever their tenant counts. `hideAll` drops «Alle …» (apps where it has no effect, e.g.
569
+ // Citadel, Foundry). `manage` = {label?, onSelect} adds «Mandanten verwalten …».
564
570
  const MANAGE = "__scalio_manage";
565
- function TenancySelect({ organizations, tenants, tenantId, onSelect, manage, lang, labels, hint }) {
571
+ function TenancySelect({ organizations, tenants, tenantId, onSelect, manage, lang, labels, hint, hideAll }) {
566
572
  const { ContextSelect } = require("./nav");
567
573
  const L = tenancyLabels(lang, labels);
568
574
  const list = tenants || [];
569
- const used = (organizations || []).filter((o) => list.some((t) => t.organization_id === o.id));
575
+ const orgs = organizations || [];
570
576
  const current = list.find((t) => t.id === tenantId);
571
- const orgId = current ? current.organization_id : "";
577
+ // An organization without tenants has no tenant id to carry it, so the choice is kept here until a tenant is picked.
578
+ const [chosenOrg, setChosenOrg] = React.useState("");
579
+ let orgId = current ? current.organization_id : (orgs.some((o) => o.id === chosenOrg) ? chosenOrg : "");
580
+ if (!orgId && hideAll && orgs.length) orgId = orgs[0].id;
572
581
  const inOrg = orgId ? list.filter((t) => t.organization_id === orgId) : list;
573
582
  const manageOpt = manage ? [{ value: MANAGE, label: manage.label || L.manage }] : [];
574
583
  const pick = (fn) => (v) => (v === MANAGE ? manage.onSelect() : fn(v));
575
584
  const tenantHint = hint === undefined ? (current && current.domain) || "" : hint;
576
- if (showOrganizationSelect(used)) {
585
+ if (showOrganizationSelect(orgs)) {
577
586
  const org = h(ContextSelect, {
578
587
  key: "org", id: "scalio-organization-select", label: L.organization, value: orgId, testId: "organization-switcher",
579
- options: [{ value: "", label: L.allOrganizations }].concat(used.map((o) => ({ value: o.id, label: o.name })), manageOpt),
580
- onChange: pick((id) => onSelect(id ? (list.find((t) => t.organization_id === id) || {}).id || "" : "")),
588
+ options: (hideAll ? [] : [{ value: "", label: L.allOrganizations }]).concat(orgs.map((o) => ({ value: o.id, label: o.name })), manageOpt),
589
+ onChange: pick((id) => { setChosenOrg(id); onSelect(id ? (list.find((t) => t.organization_id === id) || {}).id || "" : ""); }),
581
590
  hint: orgId && !showTenantSelect(inOrg) ? tenantHint : undefined,
582
591
  });
583
592
  const ten = orgId && showTenantSelect(inOrg) ? h(ContextSelect, {
@@ -589,7 +598,7 @@ function TenancySelect({ organizations, tenants, tenantId, onSelect, manage, lan
589
598
  if (!showTenantSelect(list)) return null;
590
599
  return h(ContextSelect, {
591
600
  id: "scalio-tenant-select", label: L.tenant, value: tenantId || "", testId: "tenant-switcher", hint: tenantHint,
592
- options: [{ value: "", label: L.allTenants }].concat(list.map((t) => ({ value: t.id, label: t.name })), manageOpt),
601
+ options: (hideAll ? [] : [{ value: "", label: L.allTenants }]).concat(list.map((t) => ({ value: t.id, label: t.name })), manageOpt),
593
602
  onChange: pick(onSelect),
594
603
  });
595
604
  }