@scalio-cloud/ui 0.111.2-rc.140 → 0.112.0-dev.141
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/dist/app-kit/ScalioAgentSettings.d.ts +40 -0
- package/dist/app-kit/ScalioAgentSettings.d.ts.map +1 -0
- package/dist/app-kit/ScalioAiSettings.d.ts +45 -0
- package/dist/app-kit/ScalioAiSettings.d.ts.map +1 -0
- package/dist/app-kit/ScalioGovernanceCatalog.d.ts +53 -0
- package/dist/app-kit/ScalioGovernanceCatalog.d.ts.map +1 -0
- package/dist/app-kit/ScalioKpiGrid.d.ts +24 -0
- package/dist/app-kit/ScalioKpiGrid.d.ts.map +1 -0
- package/dist/app-kit/ScalioPeerCard.d.ts +49 -0
- package/dist/app-kit/ScalioPeerCard.d.ts.map +1 -0
- package/dist/app-kit/ScalioSetupWizard.d.ts +61 -0
- package/dist/app-kit/ScalioSetupWizard.d.ts.map +1 -0
- package/dist/app-kit/ScalioTenancy.d.ts +78 -0
- package/dist/app-kit/ScalioTenancy.d.ts.map +1 -0
- package/dist/app-kit/_uiReact.d.ts +78 -4
- package/dist/app-kit/_uiReact.d.ts.map +1 -1
- package/dist/app-kit/index.d.ts +7 -0
- package/dist/app-kit/index.d.ts.map +1 -1
- package/dist/app-kit/index.js +930 -2
- package/dist/app-kit/index.js.map +1 -1
- package/dist/app-kit/index.mjs +896 -2
- package/dist/app-kit/index.mjs.map +1 -1
- package/dist/{chunk-WBI44QWN.mjs → chunk-GRPGQLP5.mjs} +28 -2
- package/dist/chunk-GRPGQLP5.mjs.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +27 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +3 -1
- package/dist/core/tenantConnect.d.ts +31 -0
- package/dist/core/tenantConnect.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-WBI44QWN.mjs.map +0 -1
package/dist/app-kit/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
N_,
|
|
3
3
|
can,
|
|
4
|
+
createTenantConnectClient,
|
|
4
5
|
mailReady
|
|
5
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-GRPGQLP5.mjs";
|
|
6
7
|
|
|
7
8
|
// src/app-kit/ScalioSecurityFactors.tsx
|
|
8
9
|
import { useMemo } from "react";
|
|
@@ -11,6 +12,8 @@ import { toast } from "sonner";
|
|
|
11
12
|
// src/app-kit/_uiReact.ts
|
|
12
13
|
import uiReact from "@scalio-cloud/ui/react";
|
|
13
14
|
var {
|
|
15
|
+
AgentsPanel,
|
|
16
|
+
AiSettingsPanel,
|
|
14
17
|
AppHeader,
|
|
15
18
|
AppShell,
|
|
16
19
|
AuditLog,
|
|
@@ -21,12 +24,14 @@ var {
|
|
|
21
24
|
BackupPanel,
|
|
22
25
|
FactoryReset,
|
|
23
26
|
JobsPanel,
|
|
27
|
+
KpiTile,
|
|
24
28
|
LanguageChoice,
|
|
25
29
|
LicensePanel,
|
|
26
30
|
LoginPage,
|
|
27
31
|
MailTransport,
|
|
28
32
|
MaintenanceNotice,
|
|
29
33
|
MicrosoftConnection,
|
|
34
|
+
OrganizationsPanel,
|
|
30
35
|
PageHeader,
|
|
31
36
|
PasswordChange,
|
|
32
37
|
PasswordPolicySelect,
|
|
@@ -40,10 +45,15 @@ var {
|
|
|
40
45
|
SelfTestPanel,
|
|
41
46
|
SettingsLayout,
|
|
42
47
|
SettingsSection,
|
|
48
|
+
SetupWizard,
|
|
43
49
|
Sidebar,
|
|
50
|
+
StatusBadge,
|
|
44
51
|
SupportConnection,
|
|
45
52
|
SupportDrawer,
|
|
46
53
|
TenantConnectStep,
|
|
54
|
+
TenantEditDialog,
|
|
55
|
+
TenantList,
|
|
56
|
+
TenantWizard,
|
|
47
57
|
ThemeChoice,
|
|
48
58
|
ThemeProvider,
|
|
49
59
|
TimezoneChoice,
|
|
@@ -51,6 +61,8 @@ var {
|
|
|
51
61
|
UserAdmin,
|
|
52
62
|
accountArea,
|
|
53
63
|
accountGroups,
|
|
64
|
+
agentsApi,
|
|
65
|
+
aiApi,
|
|
54
66
|
announceTenantChange,
|
|
55
67
|
auditApi,
|
|
56
68
|
backupApi,
|
|
@@ -60,11 +72,16 @@ var {
|
|
|
60
72
|
labelsFor,
|
|
61
73
|
licenseApi,
|
|
62
74
|
mailApi,
|
|
75
|
+
organizationSetupStep,
|
|
76
|
+
organizationsApi,
|
|
77
|
+
peersApi,
|
|
63
78
|
rolesApi,
|
|
64
79
|
saasUpdatesApi,
|
|
65
80
|
securityApi,
|
|
66
81
|
selftestApi,
|
|
82
|
+
setupWizardApi,
|
|
67
83
|
supportApi,
|
|
84
|
+
useSetupWizard,
|
|
68
85
|
usersApi
|
|
69
86
|
} = uiReact;
|
|
70
87
|
|
|
@@ -2149,7 +2166,876 @@ function ScalioLayout({
|
|
|
2149
2166
|
}
|
|
2150
2167
|
);
|
|
2151
2168
|
}
|
|
2169
|
+
|
|
2170
|
+
// src/app-kit/ScalioAiSettings.tsx
|
|
2171
|
+
import { useEffect as useEffect13, useMemo as useMemo13, useState as useState12 } from "react";
|
|
2172
|
+
import { Loader2 as Loader24 } from "lucide-react";
|
|
2173
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
2174
|
+
function defaultFormatError(error) {
|
|
2175
|
+
const err = error;
|
|
2176
|
+
const detail = err?.response?.data?.detail;
|
|
2177
|
+
if (typeof detail === "string" && detail) return detail;
|
|
2178
|
+
return err?.message || "Request failed";
|
|
2179
|
+
}
|
|
2180
|
+
function ScalioAiSettings({
|
|
2181
|
+
api,
|
|
2182
|
+
lang = "en",
|
|
2183
|
+
endpoint = "/ai/settings",
|
|
2184
|
+
canReset = true,
|
|
2185
|
+
formatError = defaultFormatError,
|
|
2186
|
+
onNotify,
|
|
2187
|
+
onAfterSave
|
|
2188
|
+
}) {
|
|
2189
|
+
const [page, setPage] = useState12(null);
|
|
2190
|
+
const client = useMemo13(() => aiApi(api), [api]);
|
|
2191
|
+
useEffect13(() => {
|
|
2192
|
+
let active = true;
|
|
2193
|
+
api.get(endpoint).then((res) => {
|
|
2194
|
+
if (active) setPage(res.data);
|
|
2195
|
+
}).catch((error) => {
|
|
2196
|
+
if (active) onNotify?.(formatError(error), "error");
|
|
2197
|
+
});
|
|
2198
|
+
return () => {
|
|
2199
|
+
active = false;
|
|
2200
|
+
};
|
|
2201
|
+
}, [api, endpoint, formatError, onNotify]);
|
|
2202
|
+
if (!page) {
|
|
2203
|
+
return /* @__PURE__ */ jsx27("div", { className: "flex items-center justify-center py-8", "data-testid": "scalio-ai-settings-loading", children: /* @__PURE__ */ jsx27(Loader24, { className: "w-5 h-5 animate-spin text-primary", "aria-label": "Loading" }) });
|
|
2204
|
+
}
|
|
2205
|
+
const features = (page.features || []).map((feature) => ({
|
|
2206
|
+
key: feature.key,
|
|
2207
|
+
max: feature.max,
|
|
2208
|
+
label: lang === "en" ? feature.label_en || feature.label : feature.label
|
|
2209
|
+
}));
|
|
2210
|
+
const handleSave = async (patch) => {
|
|
2211
|
+
const res = await api.put(endpoint, patch);
|
|
2212
|
+
setPage((prev) => prev ? { ...prev, ai: res.data } : prev);
|
|
2213
|
+
onAfterSave?.(res.data);
|
|
2214
|
+
};
|
|
2215
|
+
return /* @__PURE__ */ jsx27(
|
|
2216
|
+
AiSettingsPanel,
|
|
2217
|
+
{
|
|
2218
|
+
value: page.ai,
|
|
2219
|
+
status: { licensed: page.licensed, scalio: page.scalio },
|
|
2220
|
+
client,
|
|
2221
|
+
canReset,
|
|
2222
|
+
features,
|
|
2223
|
+
lang,
|
|
2224
|
+
onSave: handleSave,
|
|
2225
|
+
formatError,
|
|
2226
|
+
notify: (message, tone) => onNotify?.(message, tone)
|
|
2227
|
+
}
|
|
2228
|
+
);
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
// src/app-kit/ScalioSetupWizard.tsx
|
|
2232
|
+
import { useEffect as useEffect14, useMemo as useMemo14, useState as useState13 } from "react";
|
|
2233
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
2234
|
+
function ScalioSetupWizard({
|
|
2235
|
+
api,
|
|
2236
|
+
enabled,
|
|
2237
|
+
lang = "en",
|
|
2238
|
+
title,
|
|
2239
|
+
subtitle,
|
|
2240
|
+
success,
|
|
2241
|
+
steps,
|
|
2242
|
+
includeOrganizationStep = true,
|
|
2243
|
+
licenseStep = null,
|
|
2244
|
+
wide = true,
|
|
2245
|
+
onCompleted
|
|
2246
|
+
}) {
|
|
2247
|
+
const client = useMemo14(() => setupWizardApi(api), [api]);
|
|
2248
|
+
const wizard = useSetupWizard({ client, enabled, onCompleted });
|
|
2249
|
+
const [unlicensed, setUnlicensed] = useState13(false);
|
|
2250
|
+
const [org, setOrg] = useState13(null);
|
|
2251
|
+
const open = enabled && Boolean(wizard.open);
|
|
2252
|
+
useEffect14(() => {
|
|
2253
|
+
if (!open || !licenseStep) return;
|
|
2254
|
+
let active = true;
|
|
2255
|
+
api.get("/license/summary").then((res) => {
|
|
2256
|
+
if (active) setUnlicensed(res.data?.edition === "community");
|
|
2257
|
+
}).catch(() => {
|
|
2258
|
+
if (active) setUnlicensed(false);
|
|
2259
|
+
});
|
|
2260
|
+
return () => {
|
|
2261
|
+
active = false;
|
|
2262
|
+
};
|
|
2263
|
+
}, [api, licenseStep, open]);
|
|
2264
|
+
useEffect14(() => {
|
|
2265
|
+
if (!open || !includeOrganizationStep) return;
|
|
2266
|
+
let active = true;
|
|
2267
|
+
api.get("/organizations/suggestion").then((res) => {
|
|
2268
|
+
if (active) setOrg(res.data);
|
|
2269
|
+
}).catch(() => {
|
|
2270
|
+
if (active) setOrg(null);
|
|
2271
|
+
});
|
|
2272
|
+
return () => {
|
|
2273
|
+
active = false;
|
|
2274
|
+
};
|
|
2275
|
+
}, [api, includeOrganizationStep, open]);
|
|
2276
|
+
if (!enabled) return null;
|
|
2277
|
+
const allSteps = [];
|
|
2278
|
+
if (includeOrganizationStep && org) {
|
|
2279
|
+
allSteps.push(
|
|
2280
|
+
organizationSetupStep({
|
|
2281
|
+
value: org,
|
|
2282
|
+
onChange: setOrg,
|
|
2283
|
+
prefilled: org.prefilled,
|
|
2284
|
+
lang,
|
|
2285
|
+
onSave: async () => {
|
|
2286
|
+
if (org.source === "compass") return;
|
|
2287
|
+
const { name, short_code, classification, language } = org;
|
|
2288
|
+
const res = await api.patch(`/organizations/${encodeURIComponent(org.id)}`, {
|
|
2289
|
+
name,
|
|
2290
|
+
short_code,
|
|
2291
|
+
classification,
|
|
2292
|
+
language
|
|
2293
|
+
});
|
|
2294
|
+
setOrg({ ...res.data, prefilled: org.prefilled });
|
|
2295
|
+
}
|
|
2296
|
+
})
|
|
2297
|
+
);
|
|
2298
|
+
}
|
|
2299
|
+
for (const step of steps) {
|
|
2300
|
+
allSteps.push(step);
|
|
2301
|
+
}
|
|
2302
|
+
if (licenseStep && unlicensed) {
|
|
2303
|
+
allSteps.push({
|
|
2304
|
+
id: "license",
|
|
2305
|
+
optional: true,
|
|
2306
|
+
...licenseStep
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
return /* @__PURE__ */ jsx28(
|
|
2310
|
+
SetupWizard,
|
|
2311
|
+
{
|
|
2312
|
+
...wizard.props,
|
|
2313
|
+
wide,
|
|
2314
|
+
lang,
|
|
2315
|
+
title,
|
|
2316
|
+
subtitle,
|
|
2317
|
+
steps: allSteps,
|
|
2318
|
+
success
|
|
2319
|
+
}
|
|
2320
|
+
);
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
// src/app-kit/ScalioAgentSettings.tsx
|
|
2324
|
+
import { useEffect as useEffect15, useMemo as useMemo15, useState as useState14 } from "react";
|
|
2325
|
+
import { jsx as jsx29, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2326
|
+
function defaultMsiLabel(info, lang) {
|
|
2327
|
+
const version = info.build || info.version || "\u2013";
|
|
2328
|
+
const sha = info.sha256 || "\u2013";
|
|
2329
|
+
return lang === "de" ? `MSI-Version ${version}, SHA-256 ${sha}` : `MSI version ${version}, SHA-256 ${sha}`;
|
|
2330
|
+
}
|
|
2331
|
+
function ScalioAgentSettings({
|
|
2332
|
+
api,
|
|
2333
|
+
apiBase,
|
|
2334
|
+
lang = "en",
|
|
2335
|
+
formatError,
|
|
2336
|
+
onNotify,
|
|
2337
|
+
onCopy,
|
|
2338
|
+
formatMsiLabel,
|
|
2339
|
+
children
|
|
2340
|
+
}) {
|
|
2341
|
+
const client = useMemo15(() => agentsApi(api), [api]);
|
|
2342
|
+
const [msi, setMsi] = useState14(null);
|
|
2343
|
+
useEffect15(() => {
|
|
2344
|
+
let active = true;
|
|
2345
|
+
api.get("/agent/msi/info").then((res) => {
|
|
2346
|
+
if (active) setMsi(res.data);
|
|
2347
|
+
}).catch(() => {
|
|
2348
|
+
if (active) setMsi(null);
|
|
2349
|
+
});
|
|
2350
|
+
return () => {
|
|
2351
|
+
active = false;
|
|
2352
|
+
};
|
|
2353
|
+
}, [api]);
|
|
2354
|
+
const copyText = onCopy ?? ((text) => {
|
|
2355
|
+
void navigator.clipboard?.writeText(text);
|
|
2356
|
+
});
|
|
2357
|
+
return /* @__PURE__ */ jsxs17("div", { className: "space-y-4 min-w-0", "data-testid": "agent-settings", children: [
|
|
2358
|
+
msi?.available && /* @__PURE__ */ jsx29("p", { className: "text-xs text-muted-foreground break-all", "data-testid": "agent-msi-version", children: formatMsiLabel ? formatMsiLabel(msi) : defaultMsiLabel(msi, lang) }),
|
|
2359
|
+
/* @__PURE__ */ jsx29(
|
|
2360
|
+
AgentsPanel,
|
|
2361
|
+
{
|
|
2362
|
+
client,
|
|
2363
|
+
lang,
|
|
2364
|
+
formatError,
|
|
2365
|
+
downloadUrl: msi?.available ? `${apiBase}/agent/msi` : void 0,
|
|
2366
|
+
notify: (text, kind) => onNotify?.(text, kind),
|
|
2367
|
+
copy: copyText
|
|
2368
|
+
}
|
|
2369
|
+
),
|
|
2370
|
+
children
|
|
2371
|
+
] });
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
// src/app-kit/ScalioKpiGrid.tsx
|
|
2375
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
2376
|
+
var COLUMN_CLASSES = {
|
|
2377
|
+
2: "grid-cols-1 sm:grid-cols-2",
|
|
2378
|
+
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
|
2379
|
+
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
|
|
2380
|
+
5: "grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-5"
|
|
2381
|
+
};
|
|
2382
|
+
function ScalioKpiGrid({
|
|
2383
|
+
items,
|
|
2384
|
+
columns = 4,
|
|
2385
|
+
className = "",
|
|
2386
|
+
testId = "scalio-kpi-grid"
|
|
2387
|
+
}) {
|
|
2388
|
+
return /* @__PURE__ */ jsx30(
|
|
2389
|
+
"div",
|
|
2390
|
+
{
|
|
2391
|
+
className: `grid gap-3 min-w-0 ${COLUMN_CLASSES[columns]} ${className}`.trim(),
|
|
2392
|
+
"data-testid": testId,
|
|
2393
|
+
children: items.map((item, index) => /* @__PURE__ */ jsx30("div", { className: "min-w-0", children: /* @__PURE__ */ jsx30(
|
|
2394
|
+
KpiTile,
|
|
2395
|
+
{
|
|
2396
|
+
label: item.label,
|
|
2397
|
+
value: item.value,
|
|
2398
|
+
hint: item.hint,
|
|
2399
|
+
tone: item.tone,
|
|
2400
|
+
onClick: item.onClick,
|
|
2401
|
+
testId: item.testId
|
|
2402
|
+
}
|
|
2403
|
+
) }, item.id ?? `${item.label}-${index}`))
|
|
2404
|
+
}
|
|
2405
|
+
);
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
// src/app-kit/ScalioPeerCard.tsx
|
|
2409
|
+
import { useCallback as useCallback6, useEffect as useEffect16, useState as useState15 } from "react";
|
|
2410
|
+
import { jsx as jsx31, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2411
|
+
var DEFAULT_APPS = {
|
|
2412
|
+
atrium: "Scalio Atrium",
|
|
2413
|
+
beacon: "Scalio Beacon",
|
|
2414
|
+
citadel: "Scalio Citadel",
|
|
2415
|
+
folio: "Scalio Folio",
|
|
2416
|
+
foundry: "Scalio Foundry",
|
|
2417
|
+
nexus: "Scalio Nexus",
|
|
2418
|
+
pulse: "Scalio Pulse",
|
|
2419
|
+
rosetta: "Scalio Rosetta"
|
|
2420
|
+
};
|
|
2421
|
+
var LABELS3 = {
|
|
2422
|
+
en: {
|
|
2423
|
+
title: "Connected apps",
|
|
2424
|
+
empty: "No app paired yet.",
|
|
2425
|
+
removedByPeer: "Removed by the other app",
|
|
2426
|
+
pairAgain: "Pair again",
|
|
2427
|
+
lastSeen: (d) => `Last seen ${d}`,
|
|
2428
|
+
test: "Test",
|
|
2429
|
+
remove: "Remove",
|
|
2430
|
+
urlPlaceholder: "App address (https://\u2026)",
|
|
2431
|
+
codePlaceholder: "One-time code",
|
|
2432
|
+
pair: "Pair",
|
|
2433
|
+
pairedWith: (app) => `Paired with ${app}`,
|
|
2434
|
+
connectionWorks: (app, ver) => `Connection works (${app}${ver ? ` ${ver}` : ""})`,
|
|
2435
|
+
noConnection: "No connection",
|
|
2436
|
+
confirmTitle: (app) => `Remove the pairing with ${app}?`,
|
|
2437
|
+
confirmText: (own) => `${own} then refuses every call of this app. Pair again with a new code.`,
|
|
2438
|
+
removedWarn: "Pairing removed. The other app could not be told: remove the pairing there as well.",
|
|
2439
|
+
removedOk: "Pairing removed",
|
|
2440
|
+
ownUrl: (own, url) => `Address of this ${own} for the other app: ${url}`
|
|
2441
|
+
},
|
|
2442
|
+
de: {
|
|
2443
|
+
title: "Verbundene Apps",
|
|
2444
|
+
empty: "Noch keine App gekoppelt.",
|
|
2445
|
+
removedByPeer: "Von der anderen App entfernt",
|
|
2446
|
+
pairAgain: "Neu koppeln",
|
|
2447
|
+
lastSeen: (d) => `Zuletzt gesehen ${d}`,
|
|
2448
|
+
test: "Pr\xFCfen",
|
|
2449
|
+
remove: "Entfernen",
|
|
2450
|
+
urlPlaceholder: "Adresse der App (https://\u2026)",
|
|
2451
|
+
codePlaceholder: "Einmalcode",
|
|
2452
|
+
pair: "Koppeln",
|
|
2453
|
+
pairedWith: (app) => `Mit ${app} gekoppelt`,
|
|
2454
|
+
connectionWorks: (app, ver) => `Verbindung funktioniert (${app}${ver ? ` ${ver}` : ""})`,
|
|
2455
|
+
noConnection: "Keine Verbindung",
|
|
2456
|
+
confirmTitle: (app) => `Kopplung mit ${app} entfernen?`,
|
|
2457
|
+
confirmText: (own) => `${own} lehnt danach alle Aufrufe dieser App ab. Zum erneuten Koppeln einen neuen Code verwenden.`,
|
|
2458
|
+
removedWarn: "Kopplung entfernt. Die andere App konnte nicht benachrichtigt werden: Kopplung dort ebenfalls entfernen.",
|
|
2459
|
+
removedOk: "Kopplung entfernt",
|
|
2460
|
+
ownUrl: (own, url) => `Adresse dieser ${own}-Instanz f\xFCr die andere App: ${url}`
|
|
2461
|
+
}
|
|
2462
|
+
};
|
|
2463
|
+
var btnClass = "inline-flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-sm text-xs font-bold uppercase tracking-wider border border-border bg-card disabled:opacity-50";
|
|
2464
|
+
var inputClass = "w-full min-w-0 bg-background border border-border rounded-sm px-2.5 py-1.5 text-sm";
|
|
2465
|
+
function defaultFormatError2(error) {
|
|
2466
|
+
const err = error;
|
|
2467
|
+
const detail = err?.response?.data?.detail;
|
|
2468
|
+
return typeof detail === "string" && detail ? detail : err?.message || "Request failed";
|
|
2469
|
+
}
|
|
2470
|
+
function ScalioPeerCard({
|
|
2471
|
+
api,
|
|
2472
|
+
lang = "en",
|
|
2473
|
+
sectionId = "connected-apps",
|
|
2474
|
+
title,
|
|
2475
|
+
description,
|
|
2476
|
+
ownAppName = "Scalio",
|
|
2477
|
+
urlPlaceholder,
|
|
2478
|
+
appNames,
|
|
2479
|
+
formatDateTime = (v) => v,
|
|
2480
|
+
formatError = defaultFormatError2,
|
|
2481
|
+
onConfirm,
|
|
2482
|
+
onNotify,
|
|
2483
|
+
testId = "connected-apps"
|
|
2484
|
+
}) {
|
|
2485
|
+
const L = LABELS3[lang];
|
|
2486
|
+
const names = { ...DEFAULT_APPS, ...appNames };
|
|
2487
|
+
const [data, setData] = useState15(null);
|
|
2488
|
+
const [url, setUrl] = useState15("");
|
|
2489
|
+
const [code, setCode] = useState15("");
|
|
2490
|
+
const [busy, setBusy] = useState15(false);
|
|
2491
|
+
const load = useCallback6(() => {
|
|
2492
|
+
api.get("/peers").then((res) => setData(res.data)).catch(() => setData({ peers: [] }));
|
|
2493
|
+
}, [api]);
|
|
2494
|
+
useEffect16(() => {
|
|
2495
|
+
load();
|
|
2496
|
+
}, [load]);
|
|
2497
|
+
const labelOf = (app) => names[app] || app;
|
|
2498
|
+
const handlePair = async () => {
|
|
2499
|
+
setBusy(true);
|
|
2500
|
+
try {
|
|
2501
|
+
const res = await api.post("/peers", { url: url.trim(), code: code.trim() });
|
|
2502
|
+
onNotify?.(L.pairedWith(labelOf(res.data.app)), "success");
|
|
2503
|
+
setUrl("");
|
|
2504
|
+
setCode("");
|
|
2505
|
+
} catch (error) {
|
|
2506
|
+
onNotify?.(formatError(error), "error");
|
|
2507
|
+
} finally {
|
|
2508
|
+
setBusy(false);
|
|
2509
|
+
load();
|
|
2510
|
+
}
|
|
2511
|
+
};
|
|
2512
|
+
const handleCheck = async (peer) => {
|
|
2513
|
+
try {
|
|
2514
|
+
const res = await api.post(`/peers/${encodeURIComponent(peer.id)}/check`);
|
|
2515
|
+
if (res.data.ok) {
|
|
2516
|
+
onNotify?.(L.connectionWorks(labelOf(res.data.app || peer.app), res.data.version || ""), "success");
|
|
2517
|
+
} else {
|
|
2518
|
+
onNotify?.(res.data.message?.[lang] || res.data.message?.en || res.data.detail || L.noConnection, "error");
|
|
2519
|
+
}
|
|
2520
|
+
} catch (error) {
|
|
2521
|
+
onNotify?.(formatError(error), "error");
|
|
2522
|
+
}
|
|
2523
|
+
load();
|
|
2524
|
+
};
|
|
2525
|
+
const handleRemove = async (peer) => {
|
|
2526
|
+
if (onConfirm) {
|
|
2527
|
+
const ok = await onConfirm({
|
|
2528
|
+
title: L.confirmTitle(labelOf(peer.app)),
|
|
2529
|
+
text: L.confirmText(ownAppName),
|
|
2530
|
+
action: L.remove
|
|
2531
|
+
});
|
|
2532
|
+
if (!ok) return;
|
|
2533
|
+
}
|
|
2534
|
+
try {
|
|
2535
|
+
const res = await api.delete(`/peers/${encodeURIComponent(peer.id)}`);
|
|
2536
|
+
if (res.data?.notified === false && peer.status !== "removed_by_peer") {
|
|
2537
|
+
onNotify?.(L.removedWarn, "warning");
|
|
2538
|
+
} else {
|
|
2539
|
+
onNotify?.(L.removedOk, "success");
|
|
2540
|
+
}
|
|
2541
|
+
} catch (error) {
|
|
2542
|
+
onNotify?.(formatError(error), "error");
|
|
2543
|
+
}
|
|
2544
|
+
load();
|
|
2545
|
+
};
|
|
2546
|
+
const peers = data?.peers || [];
|
|
2547
|
+
return /* @__PURE__ */ jsx31(SettingsSection, { id: sectionId, title: title ?? L.title, description, testId, children: /* @__PURE__ */ jsxs18("div", { className: "space-y-2 min-w-0", children: [
|
|
2548
|
+
data && peers.length === 0 && /* @__PURE__ */ jsx31("p", { className: "text-sm text-muted-foreground", children: L.empty }),
|
|
2549
|
+
peers.map((peer) => /* @__PURE__ */ jsxs18(
|
|
2550
|
+
"div",
|
|
2551
|
+
{
|
|
2552
|
+
className: "flex flex-wrap items-center gap-2 text-xs border-t border-border pt-2 min-w-0",
|
|
2553
|
+
"data-testid": `peer-${peer.id}`,
|
|
2554
|
+
children: [
|
|
2555
|
+
/* @__PURE__ */ jsx31("span", { className: "font-medium", children: labelOf(peer.app) }),
|
|
2556
|
+
/* @__PURE__ */ jsx31("span", { className: "text-muted-foreground break-all", children: peer.url }),
|
|
2557
|
+
peer.status === "removed_by_peer" ? /* @__PURE__ */ jsx31(StatusBadge, { tone: "error", children: L.removedByPeer }) : peer.usable === false && /* @__PURE__ */ jsx31(StatusBadge, { tone: "error", children: L.pairAgain }),
|
|
2558
|
+
peer.last_seen && /* @__PURE__ */ jsx31("span", { className: "text-muted-foreground", children: L.lastSeen(formatDateTime(peer.last_seen)) }),
|
|
2559
|
+
/* @__PURE__ */ jsx31("span", { className: "flex-1" }),
|
|
2560
|
+
/* @__PURE__ */ jsx31(
|
|
2561
|
+
"button",
|
|
2562
|
+
{
|
|
2563
|
+
type: "button",
|
|
2564
|
+
className: btnClass,
|
|
2565
|
+
onClick: () => void handleCheck(peer),
|
|
2566
|
+
"data-testid": `peer-check-${peer.id}`,
|
|
2567
|
+
children: L.test
|
|
2568
|
+
}
|
|
2569
|
+
),
|
|
2570
|
+
/* @__PURE__ */ jsx31(
|
|
2571
|
+
"button",
|
|
2572
|
+
{
|
|
2573
|
+
type: "button",
|
|
2574
|
+
className: btnClass,
|
|
2575
|
+
onClick: () => void handleRemove(peer),
|
|
2576
|
+
"data-testid": `peer-remove-${peer.id}`,
|
|
2577
|
+
children: L.remove
|
|
2578
|
+
}
|
|
2579
|
+
)
|
|
2580
|
+
]
|
|
2581
|
+
},
|
|
2582
|
+
peer.id
|
|
2583
|
+
)),
|
|
2584
|
+
/* @__PURE__ */ jsxs18("div", { className: "grid gap-2 sm:grid-cols-[2fr_1fr_auto] border-t border-border pt-3", children: [
|
|
2585
|
+
/* @__PURE__ */ jsx31(
|
|
2586
|
+
"input",
|
|
2587
|
+
{
|
|
2588
|
+
className: inputClass,
|
|
2589
|
+
value: url,
|
|
2590
|
+
maxLength: 300,
|
|
2591
|
+
placeholder: urlPlaceholder ?? L.urlPlaceholder,
|
|
2592
|
+
onChange: (e) => setUrl(e.target.value),
|
|
2593
|
+
"data-testid": "peer-url"
|
|
2594
|
+
}
|
|
2595
|
+
),
|
|
2596
|
+
/* @__PURE__ */ jsx31(
|
|
2597
|
+
"input",
|
|
2598
|
+
{
|
|
2599
|
+
className: inputClass,
|
|
2600
|
+
value: code,
|
|
2601
|
+
maxLength: 100,
|
|
2602
|
+
placeholder: L.codePlaceholder,
|
|
2603
|
+
onChange: (e) => setCode(e.target.value),
|
|
2604
|
+
"data-testid": "peer-code"
|
|
2605
|
+
}
|
|
2606
|
+
),
|
|
2607
|
+
/* @__PURE__ */ jsx31(
|
|
2608
|
+
"button",
|
|
2609
|
+
{
|
|
2610
|
+
type: "button",
|
|
2611
|
+
className: btnClass,
|
|
2612
|
+
disabled: busy || !url.trim().startsWith("https://") || code.trim().length < 8,
|
|
2613
|
+
onClick: () => void handlePair(),
|
|
2614
|
+
"data-testid": "peer-pair",
|
|
2615
|
+
children: L.pair
|
|
2616
|
+
}
|
|
2617
|
+
)
|
|
2618
|
+
] }),
|
|
2619
|
+
data?.own_url && /* @__PURE__ */ jsx31("p", { className: "text-xs text-muted-foreground break-all", children: L.ownUrl(ownAppName, data.own_url) })
|
|
2620
|
+
] }) });
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
// src/app-kit/ScalioGovernanceCatalog.tsx
|
|
2624
|
+
import { useEffect as useEffect17, useState as useState16 } from "react";
|
|
2625
|
+
import { RefreshCw, Trash2 } from "lucide-react";
|
|
2626
|
+
import { jsx as jsx32, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2627
|
+
var CHANNELS = {
|
|
2628
|
+
en: [
|
|
2629
|
+
{ key: "dev", label: "Dev (newest dev build)" },
|
|
2630
|
+
{ key: "test", label: "Test (release candidates)" },
|
|
2631
|
+
{ key: "prod", label: "Prod (final releases only)" }
|
|
2632
|
+
],
|
|
2633
|
+
de: [
|
|
2634
|
+
{ key: "dev", label: "Dev (neuester Dev-Build)" },
|
|
2635
|
+
{ key: "test", label: "Test (Release Candidates)" },
|
|
2636
|
+
{ key: "prod", label: "Prod (nur finale Releases)" }
|
|
2637
|
+
]
|
|
2638
|
+
};
|
|
2639
|
+
var STATES = {
|
|
2640
|
+
en: {
|
|
2641
|
+
ok: "Source works: the pack of this stage is fetched.",
|
|
2642
|
+
token_unreadable: "The stored token can no longer be read (the instance secret changed). Enter the token again.",
|
|
2643
|
+
not_found_no_token: "GitHub answers 404: the repository is private and no token is stored. Enter a fine-grained token with Contents: read on this repository.",
|
|
2644
|
+
not_found: "GitHub answers 404: the repository does not exist or the token has no access to it. Check the repository name and the token's repository access.",
|
|
2645
|
+
token_invalid: "GitHub rejects the token (HTTP 401): expired or revoked. Enter a new token.",
|
|
2646
|
+
forbidden: "GitHub refuses the request (HTTP 403): missing permission or rate limit.",
|
|
2647
|
+
error: "The last fetch failed, see the message below."
|
|
2648
|
+
},
|
|
2649
|
+
de: {
|
|
2650
|
+
ok: "Quelle funktioniert: Das Paket dieser Stage wird abgerufen.",
|
|
2651
|
+
token_unreadable: "Das gespeicherte Token kann nicht mehr gelesen werden (Instanz-Secret ge\xE4ndert). Bitte Token erneut eingeben.",
|
|
2652
|
+
not_found_no_token: "GitHub antwortet mit 404: Das Repository ist privat und kein Token ist hinterlegt. Bitte ein Fine-Grained-Token mit \xABContents: read\xBB eingeben.",
|
|
2653
|
+
not_found: "GitHub antwortet mit 404: Das Repository existiert nicht oder das Token hat keinen Zugriff. Repository-Name und Zugriff pr\xFCfen.",
|
|
2654
|
+
token_invalid: "GitHub lehnt das Token ab (HTTP 401): abgelaufen oder widerrufen. Neues Token eingeben.",
|
|
2655
|
+
forbidden: "GitHub verweigert die Anfrage (HTTP 403): fehlende Berechtigung oder Rate-Limit.",
|
|
2656
|
+
error: "Der letzte Abruf ist fehlgeschlagen, siehe Meldung unten."
|
|
2657
|
+
}
|
|
2658
|
+
};
|
|
2659
|
+
var LABELS4 = {
|
|
2660
|
+
en: {
|
|
2661
|
+
source: "Source",
|
|
2662
|
+
intro: "Fetches the signed pack of this stage from GitHub every 15 minutes. Token with read access to the repository's contents only.",
|
|
2663
|
+
repo: "Repository",
|
|
2664
|
+
channel: "Channel",
|
|
2665
|
+
token: "Token",
|
|
2666
|
+
tokenKeep: "Token (empty: keep the stored one)",
|
|
2667
|
+
saveAndFetch: "Save and fetch",
|
|
2668
|
+
removeSource: "Remove source",
|
|
2669
|
+
saved: "Catalog source saved",
|
|
2670
|
+
since: (at) => `Since ${at}`,
|
|
2671
|
+
lastFetch: (at) => `Last fetch: ${at}`
|
|
2672
|
+
},
|
|
2673
|
+
de: {
|
|
2674
|
+
source: "Quelle",
|
|
2675
|
+
intro: "Ruft alle 15 Minuten das signierte Paket dieser Stage von GitHub ab. Token ben\xF6tigt ausschliesslich Leserechte auf die Repository-Inhalte.",
|
|
2676
|
+
repo: "Repository",
|
|
2677
|
+
channel: "Kanal",
|
|
2678
|
+
token: "Token",
|
|
2679
|
+
tokenKeep: "Token (leer lassen, um das gespeicherte zu behalten)",
|
|
2680
|
+
saveAndFetch: "Speichern und abrufen",
|
|
2681
|
+
removeSource: "Quelle entfernen",
|
|
2682
|
+
saved: "Katalogquelle gespeichert",
|
|
2683
|
+
since: (at) => `Seit ${at}`,
|
|
2684
|
+
lastFetch: (at) => `Letzter Abruf: ${at}`
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2687
|
+
function defaultFormatError3(error) {
|
|
2688
|
+
const err = error;
|
|
2689
|
+
const detail = err?.response?.data?.detail;
|
|
2690
|
+
return typeof detail === "string" && detail ? detail : err?.message || "Request failed";
|
|
2691
|
+
}
|
|
2692
|
+
function ScalioGovernanceCatalog({
|
|
2693
|
+
api,
|
|
2694
|
+
lang = "en",
|
|
2695
|
+
basePath = "/governance/catalog",
|
|
2696
|
+
formatDateTime = (v) => v,
|
|
2697
|
+
formatError = defaultFormatError3,
|
|
2698
|
+
onNotify,
|
|
2699
|
+
onCatalogChange,
|
|
2700
|
+
children
|
|
2701
|
+
}) {
|
|
2702
|
+
const L = LABELS4[lang];
|
|
2703
|
+
const channels = CHANNELS[lang];
|
|
2704
|
+
const stateMap = STATES[lang];
|
|
2705
|
+
const [src, setSrc] = useState16(null);
|
|
2706
|
+
const [form, setForm] = useState16({ repo: "", channel: "prod", token: "" });
|
|
2707
|
+
const [busy, setBusy] = useState16(false);
|
|
2708
|
+
useEffect17(() => {
|
|
2709
|
+
let active = true;
|
|
2710
|
+
api.get(`${basePath}/source`).then((res) => {
|
|
2711
|
+
if (!active) return;
|
|
2712
|
+
setSrc(res.data);
|
|
2713
|
+
setForm({ repo: res.data.repo || "", channel: res.data.channel || "prod", token: "" });
|
|
2714
|
+
}).catch((error) => {
|
|
2715
|
+
if (active) onNotify?.(formatError(error), "error");
|
|
2716
|
+
});
|
|
2717
|
+
return () => {
|
|
2718
|
+
active = false;
|
|
2719
|
+
};
|
|
2720
|
+
}, [api, basePath, formatError, onNotify]);
|
|
2721
|
+
const handleSave = async (event) => {
|
|
2722
|
+
event.preventDefault();
|
|
2723
|
+
if (busy) return;
|
|
2724
|
+
setBusy(true);
|
|
2725
|
+
try {
|
|
2726
|
+
const updated = await api.put(`${basePath}/source`, form);
|
|
2727
|
+
setForm((prev) => ({ ...prev, token: "" }));
|
|
2728
|
+
const synced = await api.post(`${basePath}/source/sync`);
|
|
2729
|
+
setSrc({ ...updated.data, last_sync: synced.data });
|
|
2730
|
+
if (synced.data.catalog !== void 0) onCatalogChange?.(synced.data.catalog);
|
|
2731
|
+
onNotify?.(L.saved, "success");
|
|
2732
|
+
} catch (error) {
|
|
2733
|
+
onNotify?.(formatError(error), "error");
|
|
2734
|
+
} finally {
|
|
2735
|
+
setBusy(false);
|
|
2736
|
+
}
|
|
2737
|
+
};
|
|
2738
|
+
const handleRemove = async () => {
|
|
2739
|
+
try {
|
|
2740
|
+
const removed = await api.delete(`${basePath}/source`);
|
|
2741
|
+
setSrc(removed.data);
|
|
2742
|
+
const catalog = await api.get(basePath);
|
|
2743
|
+
onCatalogChange?.(catalog.data);
|
|
2744
|
+
} catch (error) {
|
|
2745
|
+
onNotify?.(formatError(error), "error");
|
|
2746
|
+
}
|
|
2747
|
+
};
|
|
2748
|
+
if (!src) return null;
|
|
2749
|
+
const last = src.last_sync;
|
|
2750
|
+
const st = src.state;
|
|
2751
|
+
return /* @__PURE__ */ jsxs19("div", { className: "space-y-4 min-w-0", children: [
|
|
2752
|
+
/* @__PURE__ */ jsxs19("section", { className: "rounded-md border border-border bg-card min-w-0", "data-testid": "catalog-source", children: [
|
|
2753
|
+
/* @__PURE__ */ jsx32("div", { className: "px-5 py-3 border-b border-border text-xs font-bold uppercase tracking-wider text-muted-foreground", children: L.source }),
|
|
2754
|
+
/* @__PURE__ */ jsxs19("form", { className: "p-5 space-y-4", onSubmit: (e) => void handleSave(e), "data-testid": "catalog-source-form", children: [
|
|
2755
|
+
/* @__PURE__ */ jsx32("p", { className: "text-sm text-muted-foreground", children: L.intro }),
|
|
2756
|
+
/* @__PURE__ */ jsxs19("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
|
|
2757
|
+
/* @__PURE__ */ jsxs19("div", { className: "min-w-0", children: [
|
|
2758
|
+
/* @__PURE__ */ jsx32("label", { className: "block text-[11px] font-mono uppercase tracking-wider text-muted-foreground mb-1.5", children: L.repo }),
|
|
2759
|
+
/* @__PURE__ */ jsx32(
|
|
2760
|
+
"input",
|
|
2761
|
+
{
|
|
2762
|
+
className: "w-full bg-background border border-border rounded-sm px-3 py-2 text-sm",
|
|
2763
|
+
value: form.repo,
|
|
2764
|
+
onChange: (e) => setForm({ ...form, repo: e.target.value }),
|
|
2765
|
+
"data-testid": "catalog-source-repo"
|
|
2766
|
+
}
|
|
2767
|
+
)
|
|
2768
|
+
] }),
|
|
2769
|
+
/* @__PURE__ */ jsxs19("div", { className: "min-w-0", children: [
|
|
2770
|
+
/* @__PURE__ */ jsx32("label", { className: "block text-[11px] font-mono uppercase tracking-wider text-muted-foreground mb-1.5", children: L.channel }),
|
|
2771
|
+
/* @__PURE__ */ jsx32(
|
|
2772
|
+
"select",
|
|
2773
|
+
{
|
|
2774
|
+
className: "w-full bg-background border border-border rounded-sm px-3 py-2 text-sm",
|
|
2775
|
+
value: form.channel,
|
|
2776
|
+
onChange: (e) => setForm({ ...form, channel: e.target.value }),
|
|
2777
|
+
"data-testid": "catalog-source-channel",
|
|
2778
|
+
children: channels.map((ch) => /* @__PURE__ */ jsx32("option", { value: ch.key, children: ch.label }, ch.key))
|
|
2779
|
+
}
|
|
2780
|
+
)
|
|
2781
|
+
] }),
|
|
2782
|
+
/* @__PURE__ */ jsxs19("div", { className: "sm:col-span-2 min-w-0", children: [
|
|
2783
|
+
/* @__PURE__ */ jsx32("label", { className: "block text-[11px] font-mono uppercase tracking-wider text-muted-foreground mb-1.5", children: src.token_set ? L.tokenKeep : L.token }),
|
|
2784
|
+
/* @__PURE__ */ jsx32(
|
|
2785
|
+
"input",
|
|
2786
|
+
{
|
|
2787
|
+
type: "password",
|
|
2788
|
+
autoComplete: "off",
|
|
2789
|
+
className: "w-full bg-background border border-border rounded-sm px-3 py-2 text-sm",
|
|
2790
|
+
value: form.token,
|
|
2791
|
+
onChange: (e) => setForm({ ...form, token: e.target.value }),
|
|
2792
|
+
"data-testid": "catalog-source-token"
|
|
2793
|
+
}
|
|
2794
|
+
)
|
|
2795
|
+
] })
|
|
2796
|
+
] }),
|
|
2797
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
2798
|
+
/* @__PURE__ */ jsxs19(
|
|
2799
|
+
"button",
|
|
2800
|
+
{
|
|
2801
|
+
type: "submit",
|
|
2802
|
+
disabled: busy,
|
|
2803
|
+
className: "inline-flex items-center gap-2 h-10 px-5 rounded-sm bg-primary text-primary-foreground text-xs font-bold uppercase tracking-wider disabled:opacity-50",
|
|
2804
|
+
"data-testid": "catalog-source-save",
|
|
2805
|
+
children: [
|
|
2806
|
+
/* @__PURE__ */ jsx32(RefreshCw, { className: `w-4 h-4 ${busy ? "animate-spin" : ""}` }),
|
|
2807
|
+
" ",
|
|
2808
|
+
L.saveAndFetch
|
|
2809
|
+
]
|
|
2810
|
+
}
|
|
2811
|
+
),
|
|
2812
|
+
src.configured && /* @__PURE__ */ jsxs19(
|
|
2813
|
+
"button",
|
|
2814
|
+
{
|
|
2815
|
+
type: "button",
|
|
2816
|
+
onClick: () => void handleRemove(),
|
|
2817
|
+
className: "inline-flex items-center gap-2 h-10 px-5 rounded-sm border border-border bg-card text-xs font-bold uppercase tracking-wider",
|
|
2818
|
+
"data-testid": "catalog-source-remove",
|
|
2819
|
+
children: [
|
|
2820
|
+
/* @__PURE__ */ jsx32(Trash2, { className: "w-4 h-4" }),
|
|
2821
|
+
" ",
|
|
2822
|
+
L.removeSource
|
|
2823
|
+
]
|
|
2824
|
+
}
|
|
2825
|
+
)
|
|
2826
|
+
] }),
|
|
2827
|
+
st && /* @__PURE__ */ jsxs19(
|
|
2828
|
+
"div",
|
|
2829
|
+
{
|
|
2830
|
+
className: `text-xs rounded border px-3 py-2 ${st.code === "ok" ? "border-green-600/40 text-green-800 dark:text-green-300" : "border-red-600/40 text-red-800 dark:text-red-300"}`,
|
|
2831
|
+
"data-testid": "catalog-source-state",
|
|
2832
|
+
"data-code": st.code,
|
|
2833
|
+
children: [
|
|
2834
|
+
/* @__PURE__ */ jsx32("div", { className: "font-medium", children: stateMap[st.code] || stateMap.error }),
|
|
2835
|
+
st.since && /* @__PURE__ */ jsx32("div", { className: "text-muted-foreground", children: L.since(formatDateTime(st.since)) })
|
|
2836
|
+
]
|
|
2837
|
+
}
|
|
2838
|
+
),
|
|
2839
|
+
last && /* @__PURE__ */ jsxs19("div", { className: "text-xs font-mono text-muted-foreground space-y-0.5 break-all", children: [
|
|
2840
|
+
last.at && /* @__PURE__ */ jsxs19("div", { children: [
|
|
2841
|
+
L.lastFetch(formatDateTime(last.at)),
|
|
2842
|
+
last.fetched?.length ? ` \xB7 ${last.fetched.join(", ")}` : ""
|
|
2843
|
+
] }),
|
|
2844
|
+
(last.errors || []).map((err) => /* @__PURE__ */ jsx32("div", { className: "text-destructive break-all", children: err }, err))
|
|
2845
|
+
] })
|
|
2846
|
+
] })
|
|
2847
|
+
] }),
|
|
2848
|
+
children
|
|
2849
|
+
] });
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
// src/app-kit/ScalioTenancy.tsx
|
|
2853
|
+
import { useCallback as useCallback7, useEffect as useEffect18, useMemo as useMemo16, useState as useState17 } from "react";
|
|
2854
|
+
import { jsx as jsx33, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2855
|
+
function useCustomerOrgs(api) {
|
|
2856
|
+
const [rows, setRows] = useState17([]);
|
|
2857
|
+
const load = useCallback7(() => {
|
|
2858
|
+
api.get("/organizations").then((res) => setRows((res.data || []).filter((org) => org.kind === "customer"))).catch(() => setRows([]));
|
|
2859
|
+
}, [api]);
|
|
2860
|
+
useEffect18(() => {
|
|
2861
|
+
load();
|
|
2862
|
+
}, [load]);
|
|
2863
|
+
return rows;
|
|
2864
|
+
}
|
|
2865
|
+
function ScalioM365Connection({
|
|
2866
|
+
api,
|
|
2867
|
+
lang = "en",
|
|
2868
|
+
app,
|
|
2869
|
+
tenantId,
|
|
2870
|
+
slot = "read",
|
|
2871
|
+
mode = "wizard",
|
|
2872
|
+
showLater,
|
|
2873
|
+
onChanged,
|
|
2874
|
+
formatError,
|
|
2875
|
+
onNotify
|
|
2876
|
+
}) {
|
|
2877
|
+
const client = useMemo16(
|
|
2878
|
+
() => createTenantConnectClient(api, { tenantId, slot }),
|
|
2879
|
+
[api, slot, tenantId]
|
|
2880
|
+
);
|
|
2881
|
+
if (mode === "panel") {
|
|
2882
|
+
return /* @__PURE__ */ jsx33(
|
|
2883
|
+
MicrosoftConnection,
|
|
2884
|
+
{
|
|
2885
|
+
client,
|
|
2886
|
+
lang,
|
|
2887
|
+
onChanged,
|
|
2888
|
+
formatError,
|
|
2889
|
+
notify: (message, tone) => onNotify?.(message, tone)
|
|
2890
|
+
}
|
|
2891
|
+
);
|
|
2892
|
+
}
|
|
2893
|
+
return /* @__PURE__ */ jsx33(
|
|
2894
|
+
TenantConnectStep,
|
|
2895
|
+
{
|
|
2896
|
+
client,
|
|
2897
|
+
app,
|
|
2898
|
+
lang,
|
|
2899
|
+
onChange: onChanged,
|
|
2900
|
+
showLater
|
|
2901
|
+
}
|
|
2902
|
+
);
|
|
2903
|
+
}
|
|
2904
|
+
function ScalioTenancyPanel({
|
|
2905
|
+
api,
|
|
2906
|
+
lang = "en",
|
|
2907
|
+
tenants,
|
|
2908
|
+
organizations,
|
|
2909
|
+
columns,
|
|
2910
|
+
actions,
|
|
2911
|
+
appName,
|
|
2912
|
+
limit,
|
|
2913
|
+
readOnly,
|
|
2914
|
+
showOrganizations = false,
|
|
2915
|
+
msp,
|
|
2916
|
+
onAdd,
|
|
2917
|
+
children
|
|
2918
|
+
}) {
|
|
2919
|
+
const orgClient = useMemo16(() => organizationsApi(api), [api]);
|
|
2920
|
+
return /* @__PURE__ */ jsxs20("div", { className: "space-y-6 min-w-0", "data-testid": "scalio-tenancy-panel", children: [
|
|
2921
|
+
showOrganizations && /* @__PURE__ */ jsx33(
|
|
2922
|
+
OrganizationsPanel,
|
|
2923
|
+
{
|
|
2924
|
+
client: orgClient,
|
|
2925
|
+
msp,
|
|
2926
|
+
lang,
|
|
2927
|
+
readOnly
|
|
2928
|
+
}
|
|
2929
|
+
),
|
|
2930
|
+
tenants && /* @__PURE__ */ jsx33(
|
|
2931
|
+
TenantList,
|
|
2932
|
+
{
|
|
2933
|
+
tenants,
|
|
2934
|
+
organizations,
|
|
2935
|
+
columns,
|
|
2936
|
+
actions,
|
|
2937
|
+
appName,
|
|
2938
|
+
limit,
|
|
2939
|
+
onAdd,
|
|
2940
|
+
lang,
|
|
2941
|
+
readOnly
|
|
2942
|
+
}
|
|
2943
|
+
),
|
|
2944
|
+
children
|
|
2945
|
+
] });
|
|
2946
|
+
}
|
|
2947
|
+
var SHARE_LABELS = {
|
|
2948
|
+
en: {
|
|
2949
|
+
loading: "Checking share link\u2026",
|
|
2950
|
+
title: (app) => `Connect tenant to ${app}`,
|
|
2951
|
+
accept: "Accept tenant connection",
|
|
2952
|
+
accepted: "Tenant connection accepted.",
|
|
2953
|
+
invalid: "This share link is invalid or expired.",
|
|
2954
|
+
back: "Continue"
|
|
2955
|
+
},
|
|
2956
|
+
de: {
|
|
2957
|
+
loading: "Freigabelink wird gepr\xFCft\u2026",
|
|
2958
|
+
title: (app) => `Tenant mit ${app} verbinden`,
|
|
2959
|
+
accept: "Tenant-Verbindung \xFCbernehmen",
|
|
2960
|
+
accepted: "Tenant-Verbindung \xFCbernommen.",
|
|
2961
|
+
invalid: "Dieser Freigabelink ist ung\xFCltig oder abgelaufen.",
|
|
2962
|
+
back: "Weiter"
|
|
2963
|
+
}
|
|
2964
|
+
};
|
|
2965
|
+
function ScalioTenantSharePage({
|
|
2966
|
+
api,
|
|
2967
|
+
token,
|
|
2968
|
+
lang = "en",
|
|
2969
|
+
appName,
|
|
2970
|
+
onDone,
|
|
2971
|
+
formatError
|
|
2972
|
+
}) {
|
|
2973
|
+
const L = SHARE_LABELS[lang];
|
|
2974
|
+
const [info, setInfo] = useState17(null);
|
|
2975
|
+
const [error, setError] = useState17(null);
|
|
2976
|
+
const [busy, setBusy] = useState17(false);
|
|
2977
|
+
const [done, setDone] = useState17(false);
|
|
2978
|
+
useEffect18(() => {
|
|
2979
|
+
let active = true;
|
|
2980
|
+
api.get(`/tenant-share/${encodeURIComponent(token)}`).then((res) => {
|
|
2981
|
+
if (active) setInfo(res.data);
|
|
2982
|
+
}).catch((err) => {
|
|
2983
|
+
if (active) setError(formatError ? formatError(err) : L.invalid);
|
|
2984
|
+
});
|
|
2985
|
+
return () => {
|
|
2986
|
+
active = false;
|
|
2987
|
+
};
|
|
2988
|
+
}, [L.invalid, api, formatError, token]);
|
|
2989
|
+
const handleAccept = async () => {
|
|
2990
|
+
setBusy(true);
|
|
2991
|
+
setError(null);
|
|
2992
|
+
try {
|
|
2993
|
+
await api.post(`/tenant-share/${encodeURIComponent(token)}/accept`);
|
|
2994
|
+
setDone(true);
|
|
2995
|
+
} catch (err) {
|
|
2996
|
+
setError(formatError ? formatError(err) : L.invalid);
|
|
2997
|
+
} finally {
|
|
2998
|
+
setBusy(false);
|
|
2999
|
+
}
|
|
3000
|
+
};
|
|
3001
|
+
return /* @__PURE__ */ jsxs20("div", { className: "max-w-lg mx-auto my-12 p-6 rounded-md border border-border bg-card space-y-4", "data-testid": "scalio-tenant-share", children: [
|
|
3002
|
+
/* @__PURE__ */ jsx33("h1", { className: "text-lg font-bold tracking-tight", children: L.title(appName) }),
|
|
3003
|
+
!info && !error && /* @__PURE__ */ jsx33("p", { className: "text-sm text-muted-foreground", children: L.loading }),
|
|
3004
|
+
error && /* @__PURE__ */ jsx33("p", { className: "text-sm text-destructive", role: "alert", children: error }),
|
|
3005
|
+
info && !done && /* @__PURE__ */ jsxs20("div", { className: "space-y-4", children: [
|
|
3006
|
+
/* @__PURE__ */ jsxs20("div", { className: "text-sm", children: [
|
|
3007
|
+
info.tenant_name && /* @__PURE__ */ jsx33("div", { className: "font-medium", children: info.tenant_name }),
|
|
3008
|
+
info.domain && /* @__PURE__ */ jsx33("div", { className: "text-muted-foreground font-mono text-xs", children: info.domain })
|
|
3009
|
+
] }),
|
|
3010
|
+
/* @__PURE__ */ jsx33(
|
|
3011
|
+
"button",
|
|
3012
|
+
{
|
|
3013
|
+
type: "button",
|
|
3014
|
+
disabled: busy,
|
|
3015
|
+
onClick: () => void handleAccept(),
|
|
3016
|
+
className: "inline-flex items-center justify-center h-10 px-5 rounded-sm bg-primary text-primary-foreground text-xs font-bold uppercase tracking-wider disabled:opacity-50",
|
|
3017
|
+
"data-testid": "tenant-share-accept",
|
|
3018
|
+
children: L.accept
|
|
3019
|
+
}
|
|
3020
|
+
)
|
|
3021
|
+
] }),
|
|
3022
|
+
done && /* @__PURE__ */ jsxs20("div", { className: "space-y-3", children: [
|
|
3023
|
+
/* @__PURE__ */ jsx33("p", { className: "text-sm text-green-700 dark:text-green-400", children: L.accepted }),
|
|
3024
|
+
onDone && /* @__PURE__ */ jsx33(
|
|
3025
|
+
"button",
|
|
3026
|
+
{
|
|
3027
|
+
type: "button",
|
|
3028
|
+
onClick: onDone,
|
|
3029
|
+
className: "inline-flex items-center justify-center h-9 px-4 rounded-sm border border-border bg-background text-xs font-bold uppercase tracking-wider",
|
|
3030
|
+
children: L.back
|
|
3031
|
+
}
|
|
3032
|
+
)
|
|
3033
|
+
] })
|
|
3034
|
+
] });
|
|
3035
|
+
}
|
|
2152
3036
|
export {
|
|
3037
|
+
ScalioAgentSettings,
|
|
3038
|
+
ScalioAiSettings,
|
|
2153
3039
|
ScalioAppProviders,
|
|
2154
3040
|
ScalioAuditHeader,
|
|
2155
3041
|
ScalioAuditPage,
|
|
@@ -2164,16 +3050,20 @@ export {
|
|
|
2164
3050
|
ScalioFormDialog,
|
|
2165
3051
|
ScalioFormError,
|
|
2166
3052
|
ScalioFormField,
|
|
3053
|
+
ScalioGovernanceCatalog,
|
|
2167
3054
|
ScalioInvitePage,
|
|
2168
3055
|
ScalioJobsPage,
|
|
3056
|
+
ScalioKpiGrid,
|
|
2169
3057
|
ScalioLayout,
|
|
2170
3058
|
ScalioLicensePanel,
|
|
2171
3059
|
ScalioLoginPage,
|
|
3060
|
+
ScalioM365Connection,
|
|
2172
3061
|
ScalioMailSettings,
|
|
2173
3062
|
ScalioMaintenanceBanner,
|
|
2174
3063
|
ScalioMoneyInput,
|
|
2175
3064
|
ScalioOfflineBanner,
|
|
2176
3065
|
ScalioPasswordChangePage,
|
|
3066
|
+
ScalioPeerCard,
|
|
2177
3067
|
ScalioProfilePage,
|
|
2178
3068
|
ScalioResultBadge,
|
|
2179
3069
|
ScalioRoleTenants,
|
|
@@ -2181,13 +3071,17 @@ export {
|
|
|
2181
3071
|
ScalioSaasUpdatesSection,
|
|
2182
3072
|
ScalioSecurityFactors,
|
|
2183
3073
|
ScalioSelfTestPage,
|
|
3074
|
+
ScalioSetupWizard,
|
|
2184
3075
|
ScalioSkeleton,
|
|
2185
3076
|
ScalioSupportCard,
|
|
2186
3077
|
ScalioTagInput,
|
|
3078
|
+
ScalioTenancyPanel,
|
|
2187
3079
|
ScalioTenantSettings,
|
|
3080
|
+
ScalioTenantSharePage,
|
|
2188
3081
|
ScalioUsersPage,
|
|
2189
3082
|
formatDisplayValue,
|
|
2190
3083
|
formatMinorToEditable,
|
|
2191
|
-
parseEditableToMinor
|
|
3084
|
+
parseEditableToMinor,
|
|
3085
|
+
useCustomerOrgs
|
|
2192
3086
|
};
|
|
2193
3087
|
//# sourceMappingURL=index.mjs.map
|