@scalio-cloud/ui 0.108.0 → 0.110.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/dist/app-kit/ScalioAuditPages.d.ts +37 -0
- package/dist/app-kit/ScalioAuditPages.d.ts.map +1 -0
- package/dist/app-kit/ScalioBackupSection.d.ts +27 -0
- package/dist/app-kit/ScalioBackupSection.d.ts.map +1 -0
- package/dist/app-kit/ScalioFactoryReset.d.ts +15 -0
- package/dist/app-kit/ScalioFactoryReset.d.ts.map +1 -0
- package/dist/app-kit/ScalioInvitePage.d.ts +24 -0
- package/dist/app-kit/ScalioInvitePage.d.ts.map +1 -0
- package/dist/app-kit/ScalioLicensePanel.d.ts +23 -0
- package/dist/app-kit/ScalioLicensePanel.d.ts.map +1 -0
- package/dist/app-kit/ScalioLoginPage.d.ts +31 -0
- package/dist/app-kit/ScalioLoginPage.d.ts.map +1 -0
- package/dist/app-kit/ScalioMailSettings.d.ts +13 -0
- package/dist/app-kit/ScalioMailSettings.d.ts.map +1 -0
- package/dist/app-kit/ScalioPasswordChangePage.d.ts +21 -0
- package/dist/app-kit/ScalioPasswordChangePage.d.ts.map +1 -0
- package/dist/app-kit/ScalioProfilePage.d.ts +39 -0
- package/dist/app-kit/ScalioProfilePage.d.ts.map +1 -0
- package/dist/app-kit/ScalioRoleTenants.d.ts +22 -0
- package/dist/app-kit/ScalioRoleTenants.d.ts.map +1 -0
- package/dist/app-kit/ScalioSaasUpdatesSection.d.ts +23 -0
- package/dist/app-kit/ScalioSaasUpdatesSection.d.ts.map +1 -0
- package/dist/app-kit/ScalioSecurityFactors.d.ts +28 -0
- package/dist/app-kit/ScalioSecurityFactors.d.ts.map +1 -0
- package/dist/app-kit/ScalioSelfTestPage.d.ts +14 -0
- package/dist/app-kit/ScalioSelfTestPage.d.ts.map +1 -0
- package/dist/app-kit/ScalioSupportCard.d.ts +13 -0
- package/dist/app-kit/ScalioSupportCard.d.ts.map +1 -0
- package/dist/app-kit/ScalioUsersPage.d.ts +48 -0
- package/dist/app-kit/ScalioUsersPage.d.ts.map +1 -0
- package/dist/app-kit/_uiReact.d.ts +307 -0
- package/dist/app-kit/_uiReact.d.ts.map +1 -0
- package/dist/app-kit/index.d.ts +31 -0
- package/dist/app-kit/index.d.ts.map +1 -0
- package/dist/app-kit/index.js +1128 -0
- package/dist/app-kit/index.js.map +1 -0
- package/dist/app-kit/index.mjs +1051 -0
- package/dist/app-kit/index.mjs.map +1 -0
- package/dist/chunk-A7O3P4YV.mjs +457 -0
- package/dist/chunk-A7O3P4YV.mjs.map +1 -0
- package/dist/config/i18nCheck.d.ts +49 -0
- package/dist/config/i18nCheck.d.ts.map +1 -0
- package/dist/config/index.d.ts +37 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +268 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/index.mjs +234 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/config/openapi.d.ts +34 -0
- package/dist/config/openapi.d.ts.map +1 -0
- package/dist/core/afterLogin.d.ts +6 -0
- package/dist/core/afterLogin.d.ts.map +1 -0
- package/dist/core/api.d.ts +48 -0
- package/dist/core/api.d.ts.map +1 -0
- package/dist/core/auditActions.d.ts +17 -0
- package/dist/core/auditActions.d.ts.map +1 -0
- package/dist/core/datetime.d.ts +18 -0
- package/dist/core/datetime.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +51 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +509 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/index.mjs +39 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/core/legal.d.ts +17 -0
- package/dist/core/legal.d.ts.map +1 -0
- package/dist/core/mailReady.d.ts +12 -0
- package/dist/core/mailReady.d.ts.map +1 -0
- package/dist/core/passkeys.d.ts +30 -0
- package/dist/core/passkeys.d.ts.map +1 -0
- package/dist/core/permissions.d.ts +10 -0
- package/dist/core/permissions.d.ts.map +1 -0
- package/dist/editor/RichTextEditor.d.ts +58 -0
- package/dist/editor/RichTextEditor.d.ts.map +1 -0
- package/dist/editor/index.d.ts +5 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +350 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/index.mjs +324 -0
- package/dist/editor/index.mjs.map +1 -0
- package/package.json +68 -3
|
@@ -0,0 +1,1051 @@
|
|
|
1
|
+
import {
|
|
2
|
+
N_,
|
|
3
|
+
can,
|
|
4
|
+
mailReady
|
|
5
|
+
} from "../chunk-A7O3P4YV.mjs";
|
|
6
|
+
|
|
7
|
+
// src/app-kit/ScalioSecurityFactors.tsx
|
|
8
|
+
import { useMemo } from "react";
|
|
9
|
+
import { toast } from "sonner";
|
|
10
|
+
|
|
11
|
+
// src/app-kit/_uiReact.ts
|
|
12
|
+
import uiReact from "@scalio-cloud/ui/react";
|
|
13
|
+
var {
|
|
14
|
+
AuditLog,
|
|
15
|
+
AuditNav,
|
|
16
|
+
AuthHeader,
|
|
17
|
+
AuthLayout,
|
|
18
|
+
AuthMessage,
|
|
19
|
+
BackupPanel,
|
|
20
|
+
FactoryReset,
|
|
21
|
+
JobsPanel,
|
|
22
|
+
LanguageChoice,
|
|
23
|
+
LicensePanel,
|
|
24
|
+
LoginPage,
|
|
25
|
+
MailTransport,
|
|
26
|
+
MaintenanceNotice,
|
|
27
|
+
MicrosoftConnection,
|
|
28
|
+
PageHeader,
|
|
29
|
+
PasswordChange,
|
|
30
|
+
PasswordPolicySelect,
|
|
31
|
+
ProfileIdentity,
|
|
32
|
+
ProfileSection,
|
|
33
|
+
RoleAdmin,
|
|
34
|
+
RoleSourceSettings,
|
|
35
|
+
SaasUpdatesPanel,
|
|
36
|
+
SecurityFactors,
|
|
37
|
+
SelfTestPanel,
|
|
38
|
+
SettingsLayout,
|
|
39
|
+
SettingsSection,
|
|
40
|
+
SupportConnection,
|
|
41
|
+
ThemeChoice,
|
|
42
|
+
TimezoneChoice,
|
|
43
|
+
UpdateBanner,
|
|
44
|
+
UserAdmin,
|
|
45
|
+
accountArea,
|
|
46
|
+
accountGroups,
|
|
47
|
+
auditApi,
|
|
48
|
+
backupApi,
|
|
49
|
+
customerAccessProps,
|
|
50
|
+
factoryResetApi,
|
|
51
|
+
jobsApi,
|
|
52
|
+
labelsFor,
|
|
53
|
+
licenseApi,
|
|
54
|
+
mailApi,
|
|
55
|
+
rolesApi,
|
|
56
|
+
saasUpdatesApi,
|
|
57
|
+
securityApi,
|
|
58
|
+
selftestApi,
|
|
59
|
+
supportApi,
|
|
60
|
+
usersApi
|
|
61
|
+
} = uiReact;
|
|
62
|
+
|
|
63
|
+
// src/app-kit/ScalioSecurityFactors.tsx
|
|
64
|
+
import { jsx } from "react/jsx-runtime";
|
|
65
|
+
var defaultNotify = (text, tone) => {
|
|
66
|
+
if (tone === "error") toast.error(text);
|
|
67
|
+
else toast.success(text);
|
|
68
|
+
};
|
|
69
|
+
function ScalioSecurityFactors({
|
|
70
|
+
api,
|
|
71
|
+
product,
|
|
72
|
+
lang,
|
|
73
|
+
email,
|
|
74
|
+
qr,
|
|
75
|
+
confirm,
|
|
76
|
+
formatApiErrorDetail,
|
|
77
|
+
startRegistration,
|
|
78
|
+
browserSupportsWebAuthn,
|
|
79
|
+
onMfaChange,
|
|
80
|
+
className = "mt-8 pt-6 border-t border-border"
|
|
81
|
+
}) {
|
|
82
|
+
const client = useMemo(
|
|
83
|
+
() => securityApi(api, { startRegistration, browserSupportsWebAuthn }),
|
|
84
|
+
[api, startRegistration, browserSupportsWebAuthn]
|
|
85
|
+
);
|
|
86
|
+
const formatError = (e) => {
|
|
87
|
+
const err = e;
|
|
88
|
+
return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || "";
|
|
89
|
+
};
|
|
90
|
+
return /* @__PURE__ */ jsx(
|
|
91
|
+
SecurityFactors,
|
|
92
|
+
{
|
|
93
|
+
client,
|
|
94
|
+
lang,
|
|
95
|
+
product,
|
|
96
|
+
email,
|
|
97
|
+
qr,
|
|
98
|
+
notify: defaultNotify,
|
|
99
|
+
confirm,
|
|
100
|
+
formatError,
|
|
101
|
+
className,
|
|
102
|
+
onMfaChange
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/app-kit/ScalioPasswordChangePage.tsx
|
|
108
|
+
import { toast as toast2 } from "sonner";
|
|
109
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
110
|
+
function ScalioPasswordChangePage({
|
|
111
|
+
api,
|
|
112
|
+
brand,
|
|
113
|
+
legalUrl,
|
|
114
|
+
email,
|
|
115
|
+
lang,
|
|
116
|
+
onLangChange,
|
|
117
|
+
t,
|
|
118
|
+
minLength = 12,
|
|
119
|
+
onPasswordChanged,
|
|
120
|
+
onLogout
|
|
121
|
+
}) {
|
|
122
|
+
const change = async (current, next) => {
|
|
123
|
+
const { data } = await api.post("/auth/change-password", {
|
|
124
|
+
current_password: current,
|
|
125
|
+
new_password: next
|
|
126
|
+
});
|
|
127
|
+
return data;
|
|
128
|
+
};
|
|
129
|
+
return /* @__PURE__ */ jsx2(AuthLayout, { legalUrl, brand, lang, onLangChange, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", "data-testid": "password-change-required", children: [
|
|
130
|
+
/* @__PURE__ */ jsx2(
|
|
131
|
+
AuthHeader,
|
|
132
|
+
{
|
|
133
|
+
eyebrow: email,
|
|
134
|
+
title: t("Choose your password"),
|
|
135
|
+
subtitle: t("You signed in with a start password. Choose your own password to continue.")
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
/* @__PURE__ */ jsx2(
|
|
139
|
+
PasswordChange,
|
|
140
|
+
{
|
|
141
|
+
onSubmit: change,
|
|
142
|
+
minLength,
|
|
143
|
+
lang,
|
|
144
|
+
onDone: () => {
|
|
145
|
+
toast2.success(t("Password changed."));
|
|
146
|
+
onPasswordChanged();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ jsx2(
|
|
151
|
+
"button",
|
|
152
|
+
{
|
|
153
|
+
type: "button",
|
|
154
|
+
onClick: onLogout,
|
|
155
|
+
"data-testid": "password-change-logout",
|
|
156
|
+
className: "w-full h-9 text-xs font-bold uppercase tracking-wider text-muted-foreground hover:text-foreground",
|
|
157
|
+
children: t("Sign out")
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
] }) });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// src/app-kit/ScalioProfilePage.tsx
|
|
164
|
+
import { useEffect, useState } from "react";
|
|
165
|
+
import { toast as toast3 } from "sonner";
|
|
166
|
+
import { Loader2 } from "lucide-react";
|
|
167
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
168
|
+
var FIELD_CLASS = "mt-1 w-full h-10 px-3 bg-background border border-input rounded-sm text-sm focus:outline-none focus:ring-1 focus:ring-ring focus:border-ring transition-colors";
|
|
169
|
+
var LABEL_CLASS = "text-[11px] font-bold uppercase tracking-widest text-muted-foreground";
|
|
170
|
+
var PRIMARY_CLASS = "inline-flex h-10 items-center justify-center gap-2 px-4 bg-primary text-primary-foreground rounded-sm text-xs font-bold uppercase tracking-wider hover:bg-primary/90 transition-colors disabled:opacity-60";
|
|
171
|
+
var MS_LINK_ERRORS = {
|
|
172
|
+
linked_elsewhere: N_("This Microsoft account belongs to another account here. Ask an administrator."),
|
|
173
|
+
already_linked: N_("Your account is already linked with Microsoft."),
|
|
174
|
+
failed: N_("Linking with Microsoft failed. Please try again.")
|
|
175
|
+
};
|
|
176
|
+
function ScalioProfilePage({
|
|
177
|
+
api,
|
|
178
|
+
apiBaseUrl,
|
|
179
|
+
user,
|
|
180
|
+
updateUser,
|
|
181
|
+
lang,
|
|
182
|
+
setLang,
|
|
183
|
+
t,
|
|
184
|
+
theme,
|
|
185
|
+
setTheme,
|
|
186
|
+
formatApiErrorDetail,
|
|
187
|
+
roleLabels,
|
|
188
|
+
languageEndpoint = "/auth/language",
|
|
189
|
+
minPasswordLength = 12,
|
|
190
|
+
securityFactors
|
|
191
|
+
}) {
|
|
192
|
+
const L = labelsFor(lang);
|
|
193
|
+
const P = L.profile_;
|
|
194
|
+
const [name, setName] = useState(user?.name || "");
|
|
195
|
+
const [savingName, setSavingName] = useState(false);
|
|
196
|
+
const [ssoOn, setSsoOn] = useState(false);
|
|
197
|
+
const saved = () => {
|
|
198
|
+
toast3.success(P.saved);
|
|
199
|
+
};
|
|
200
|
+
const errorText = (e) => {
|
|
201
|
+
const err = e;
|
|
202
|
+
return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || t("Something went wrong. Please try again.");
|
|
203
|
+
};
|
|
204
|
+
const defaultRoles = {
|
|
205
|
+
admin: t("Administrator"),
|
|
206
|
+
operator: t("Operator"),
|
|
207
|
+
editor: t("Editor"),
|
|
208
|
+
reader: t("Reader")
|
|
209
|
+
};
|
|
210
|
+
const resolvedRoles = roleLabels ?? defaultRoles;
|
|
211
|
+
const roleName = user?.role && resolvedRoles[user.role] || t("Reader");
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
api.get("/auth/scalio/status").then((r) => setSsoOn(Boolean(r.data?.enabled))).catch(() => setSsoOn(false));
|
|
214
|
+
if (typeof window === "undefined") return;
|
|
215
|
+
const result = new URLSearchParams(window.location.search).get("microsoft");
|
|
216
|
+
if (!result) return;
|
|
217
|
+
window.history.replaceState(null, "", window.location.pathname);
|
|
218
|
+
if (result === "linked") {
|
|
219
|
+
toast3.success(t("Your Microsoft account is linked."));
|
|
220
|
+
api.get("/auth/me").then((r) => updateUser(r.data)).catch(() => null);
|
|
221
|
+
} else {
|
|
222
|
+
toast3.error(t(MS_LINK_ERRORS[result] ?? MS_LINK_ERRORS.failed));
|
|
223
|
+
}
|
|
224
|
+
}, []);
|
|
225
|
+
const unlinkMicrosoft = async () => {
|
|
226
|
+
try {
|
|
227
|
+
await api.delete("/auth/scalio/link");
|
|
228
|
+
if (user) updateUser({ ...user, microsoft: false });
|
|
229
|
+
toast3.success(t("The Microsoft link was removed."));
|
|
230
|
+
} catch (err) {
|
|
231
|
+
toast3.error(errorText(err));
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const chooseLang = async (nextLang) => {
|
|
235
|
+
setLang(nextLang);
|
|
236
|
+
try {
|
|
237
|
+
const { data } = await api.post(languageEndpoint, {
|
|
238
|
+
language: nextLang
|
|
239
|
+
});
|
|
240
|
+
if (user) updateUser({ ...user, language: data?.language ?? nextLang });
|
|
241
|
+
saved();
|
|
242
|
+
if (data?.language_sync && typeof window !== "undefined") {
|
|
243
|
+
window.location.assign(
|
|
244
|
+
`${apiBaseUrl.replace(/\/api$/, "")}${data.language_sync}?next=${encodeURIComponent("/profile")}`
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
} catch (err) {
|
|
248
|
+
if (languageEndpoint === "/auth/preferences") {
|
|
249
|
+
toast3.error(errorText(err));
|
|
250
|
+
} else {
|
|
251
|
+
saved();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
const saveName = async (e) => {
|
|
256
|
+
e.preventDefault();
|
|
257
|
+
setSavingName(true);
|
|
258
|
+
try {
|
|
259
|
+
const { data } = await api.put("/auth/profile", { name });
|
|
260
|
+
updateUser(data);
|
|
261
|
+
toast3.success(t("Profile saved"));
|
|
262
|
+
} catch (err) {
|
|
263
|
+
toast3.error(errorText(err));
|
|
264
|
+
} finally {
|
|
265
|
+
setSavingName(false);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
const chooseTz = async (tz) => {
|
|
269
|
+
try {
|
|
270
|
+
await api.post("/auth/preferences", { timezone: tz });
|
|
271
|
+
if (user) updateUser({ ...user, timezone: tz });
|
|
272
|
+
saved();
|
|
273
|
+
} catch (err) {
|
|
274
|
+
toast3.error(errorText(err));
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
const changePassword = async (current, next) => {
|
|
278
|
+
await api.post("/auth/change-password", { current_password: current, new_password: next });
|
|
279
|
+
};
|
|
280
|
+
return /* @__PURE__ */ jsxs2("div", { "data-testid": "profile-page", className: "space-y-6", children: [
|
|
281
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
282
|
+
/* @__PURE__ */ jsx3("h1", { className: "font-display font-black uppercase tracking-tight text-3xl sm:text-4xl", children: L.profile }),
|
|
283
|
+
/* @__PURE__ */ jsx3("p", { className: "text-sm text-muted-foreground", children: P.subtitle })
|
|
284
|
+
] }),
|
|
285
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
286
|
+
/* @__PURE__ */ jsx3(ProfileSection, { id: "account", lang, children: /* @__PURE__ */ jsx3(ProfileIdentity, { name: user?.name, email: user?.email, role: roleName, children: /* @__PURE__ */ jsxs2("form", { onSubmit: saveName, className: "flex flex-col sm:flex-row sm:items-end gap-3", children: [
|
|
287
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex-1", children: [
|
|
288
|
+
/* @__PURE__ */ jsx3("label", { className: LABEL_CLASS, htmlFor: "profile-name", children: t("Name") }),
|
|
289
|
+
/* @__PURE__ */ jsx3(
|
|
290
|
+
"input",
|
|
291
|
+
{
|
|
292
|
+
id: "profile-name",
|
|
293
|
+
className: FIELD_CLASS,
|
|
294
|
+
value: name,
|
|
295
|
+
onChange: (e) => setName(e.target.value),
|
|
296
|
+
required: true,
|
|
297
|
+
maxLength: 120,
|
|
298
|
+
autoComplete: "name",
|
|
299
|
+
"data-testid": "profile-name-input"
|
|
300
|
+
}
|
|
301
|
+
)
|
|
302
|
+
] }),
|
|
303
|
+
/* @__PURE__ */ jsxs2(
|
|
304
|
+
"button",
|
|
305
|
+
{
|
|
306
|
+
type: "submit",
|
|
307
|
+
className: PRIMARY_CLASS,
|
|
308
|
+
disabled: savingName || !name.trim() || name.trim() === user?.name,
|
|
309
|
+
"data-testid": "profile-save-btn",
|
|
310
|
+
children: [
|
|
311
|
+
savingName && /* @__PURE__ */ jsx3(Loader2, { className: "w-4 h-4 animate-spin" }),
|
|
312
|
+
t("Save")
|
|
313
|
+
]
|
|
314
|
+
}
|
|
315
|
+
)
|
|
316
|
+
] }) }) }),
|
|
317
|
+
/* @__PURE__ */ jsx3(ProfileSection, { id: "appearance", lang, children: /* @__PURE__ */ jsx3(
|
|
318
|
+
ThemeChoice,
|
|
319
|
+
{
|
|
320
|
+
theme,
|
|
321
|
+
onChange: (m) => {
|
|
322
|
+
setTheme(m);
|
|
323
|
+
saved();
|
|
324
|
+
},
|
|
325
|
+
lang
|
|
326
|
+
}
|
|
327
|
+
) }),
|
|
328
|
+
/* @__PURE__ */ jsxs2(ProfileSection, { id: "language", lang, children: [
|
|
329
|
+
/* @__PURE__ */ jsx3(LanguageChoice, { lang, onChange: chooseLang }),
|
|
330
|
+
/* @__PURE__ */ jsx3(TimezoneChoice, { value: user?.timezone || "", onChange: chooseTz, lang })
|
|
331
|
+
] }),
|
|
332
|
+
/* @__PURE__ */ jsxs2(ProfileSection, { id: "security", lang, testId: "change-password-section", children: [
|
|
333
|
+
/* @__PURE__ */ jsx3(
|
|
334
|
+
PasswordChange,
|
|
335
|
+
{
|
|
336
|
+
onSubmit: changePassword,
|
|
337
|
+
onDone: () => toast3.success(t("Password changed. Other devices have been signed out.")),
|
|
338
|
+
minLength: minPasswordLength,
|
|
339
|
+
lang
|
|
340
|
+
}
|
|
341
|
+
),
|
|
342
|
+
securityFactors
|
|
343
|
+
] }),
|
|
344
|
+
(ssoOn || user?.microsoft) && /* @__PURE__ */ jsx3(ProfileSection, { id: "connections", lang, testId: "connections-section", children: /* @__PURE__ */ jsx3(
|
|
345
|
+
MicrosoftConnection,
|
|
346
|
+
{
|
|
347
|
+
linked: Boolean(user?.microsoft),
|
|
348
|
+
canUnlink: Boolean(user?.has_password),
|
|
349
|
+
lang,
|
|
350
|
+
onLink: () => window.location.assign(`${apiBaseUrl}/auth/scalio/login?link=1`),
|
|
351
|
+
onUnlink: unlinkMicrosoft
|
|
352
|
+
}
|
|
353
|
+
) })
|
|
354
|
+
] })
|
|
355
|
+
] });
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// src/app-kit/ScalioUsersPage.tsx
|
|
359
|
+
import { useCallback, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
360
|
+
import { Navigate, NavLink, useNavigate, useParams, useSearchParams } from "react-router-dom";
|
|
361
|
+
import { toast as toast4 } from "sonner";
|
|
362
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
363
|
+
function roleLabel(name, lang) {
|
|
364
|
+
if (name && typeof name === "object") {
|
|
365
|
+
return (lang === "en" ? name.en || name.de : name.de || name.en) || "";
|
|
366
|
+
}
|
|
367
|
+
return name;
|
|
368
|
+
}
|
|
369
|
+
function ScalioUsersPage({
|
|
370
|
+
api,
|
|
371
|
+
user,
|
|
372
|
+
lang,
|
|
373
|
+
t,
|
|
374
|
+
confirm,
|
|
375
|
+
formatApiErrorDetail,
|
|
376
|
+
defaultRole = "reader",
|
|
377
|
+
customers,
|
|
378
|
+
emptyCustomersHint,
|
|
379
|
+
renderEntraTab
|
|
380
|
+
}) {
|
|
381
|
+
const L = labelsFor(lang);
|
|
382
|
+
const [params] = useSearchParams();
|
|
383
|
+
const { area } = useParams();
|
|
384
|
+
const navigate = useNavigate();
|
|
385
|
+
const usersClient = useMemo2(() => usersApi(api), [api]);
|
|
386
|
+
const rolesClient = useMemo2(() => rolesApi(api), [api]);
|
|
387
|
+
const [rows, setRows] = useState2([]);
|
|
388
|
+
const [ssoOn, setSsoOn] = useState2(false);
|
|
389
|
+
const [mailOn, setMailOn] = useState2(false);
|
|
390
|
+
const [roles, setRoles] = useState2([]);
|
|
391
|
+
const [policy, setPolicy] = useState2(null);
|
|
392
|
+
const load = useCallback(() => {
|
|
393
|
+
api.get("/users").then((r) => setRows(r.data)).catch(() => setRows([]));
|
|
394
|
+
rolesClient.list().then(setRoles).catch(() => setRoles([]));
|
|
395
|
+
api.get("/users/login-policy").then((r) => setPolicy(r.data)).catch(() => setPolicy(null));
|
|
396
|
+
api.get("/auth/scalio/status").then((r) => setSsoOn(Boolean(r.data?.enabled))).catch(() => setSsoOn(false));
|
|
397
|
+
api.get("/mail/settings").then((r) => setMailOn(mailReady(r.data))).catch(() => setMailOn(false));
|
|
398
|
+
}, [api, rolesClient]);
|
|
399
|
+
useEffect2(() => {
|
|
400
|
+
load();
|
|
401
|
+
}, [load]);
|
|
402
|
+
const fail = (e) => {
|
|
403
|
+
const err = e;
|
|
404
|
+
if (err?.licenseShown) return;
|
|
405
|
+
toast4.error(err?.response?.data?.detail ? formatApiErrorDetail(err.response.data.detail) : t("The action failed."));
|
|
406
|
+
};
|
|
407
|
+
const savePolicy = async (value) => {
|
|
408
|
+
if (value !== "local" && !await confirm({
|
|
409
|
+
title: value === "off" ? t("Turn off sign-in with a password?") : t("Only the emergency administrator with a password?"),
|
|
410
|
+
text: value === "off" ? t(
|
|
411
|
+
"From now on, everybody signs in with Microsoft. Passwords and passkeys no longer work. If Microsoft is unreachable, FORCE_LOCAL_LOGIN=true in the environment brings them back."
|
|
412
|
+
) : t(
|
|
413
|
+
"From now on, everybody signs in with Microsoft, except the administrators marked as emergency administrator."
|
|
414
|
+
),
|
|
415
|
+
action: t("Save")
|
|
416
|
+
})) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
try {
|
|
420
|
+
const { data } = await api.put("/users/login-policy", { value });
|
|
421
|
+
setPolicy(data);
|
|
422
|
+
toast4.success(t("Saved"));
|
|
423
|
+
} catch (e) {
|
|
424
|
+
fail(e);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
if (user?.role !== "admin") {
|
|
428
|
+
return /* @__PURE__ */ jsx4("p", { className: "text-sm text-muted-foreground", children: t("Only administrators can manage users.") });
|
|
429
|
+
}
|
|
430
|
+
const pending = rows.filter((u) => u.access_pending).length;
|
|
431
|
+
const emergencyCount = rows.filter(
|
|
432
|
+
(u) => u.emergency_admin && u.role === "admin" && u.has_password && !u.access_pending
|
|
433
|
+
).length;
|
|
434
|
+
const active = accountArea(area);
|
|
435
|
+
if (!area) {
|
|
436
|
+
const old = params.get("tab");
|
|
437
|
+
const target = old === "signIn" ? "sign-in" : old && ["roles", "entra"].includes(old) ? old : "users";
|
|
438
|
+
return /* @__PURE__ */ jsx4(Navigate, { to: `/accounts/${target}`, replace: true });
|
|
439
|
+
}
|
|
440
|
+
const notify2 = (text, tone) => {
|
|
441
|
+
if (tone === "error") toast4.error(text);
|
|
442
|
+
else toast4.success(text);
|
|
443
|
+
};
|
|
444
|
+
const formatErr = (e) => {
|
|
445
|
+
const err = e;
|
|
446
|
+
return err?.response?.data?.detail ? formatApiErrorDetail(err.response.data.detail) : t("The action failed.");
|
|
447
|
+
};
|
|
448
|
+
const groups = accountGroups({ lang }).map(
|
|
449
|
+
(g) => ({
|
|
450
|
+
...g,
|
|
451
|
+
items: g.items.map(
|
|
452
|
+
(it) => it.id === "users" ? {
|
|
453
|
+
...it,
|
|
454
|
+
hint: t("Who can use this app and what they may do"),
|
|
455
|
+
label: pending > 0 ? `${it.label} (${pending})` : it.label
|
|
456
|
+
} : it
|
|
457
|
+
)
|
|
458
|
+
})
|
|
459
|
+
);
|
|
460
|
+
const extraCustomerProps = customers ? customerAccessProps({
|
|
461
|
+
customers,
|
|
462
|
+
lang,
|
|
463
|
+
emptyHint: emptyCustomersHint ?? t("No customers yet. Add them under Settings, Tenants.")
|
|
464
|
+
}) : {};
|
|
465
|
+
return /* @__PURE__ */ jsx4("div", { "data-testid": "users-page", children: /* @__PURE__ */ jsxs3(
|
|
466
|
+
SettingsLayout,
|
|
467
|
+
{
|
|
468
|
+
groups,
|
|
469
|
+
active,
|
|
470
|
+
title: active === "users" ? L.accountTabs.users : void 0,
|
|
471
|
+
root: L.accounts,
|
|
472
|
+
link: NavLink,
|
|
473
|
+
onSelect: (it) => navigate(it.to),
|
|
474
|
+
lang,
|
|
475
|
+
search: false,
|
|
476
|
+
testId: "accounts-layout",
|
|
477
|
+
children: [
|
|
478
|
+
active === "users" && /* @__PURE__ */ jsx4(
|
|
479
|
+
UserAdmin,
|
|
480
|
+
{
|
|
481
|
+
client: usersClient,
|
|
482
|
+
me: user.id,
|
|
483
|
+
lang,
|
|
484
|
+
canLock: true,
|
|
485
|
+
onChange: load,
|
|
486
|
+
roles: roles.map((r) => ({ value: r.id, label: roleLabel(r.name, lang) })),
|
|
487
|
+
defaultRole,
|
|
488
|
+
signInModes: mailOn ? ["microsoft", "password", "invite"] : ["microsoft", "password"],
|
|
489
|
+
microsoftEnabled: ssoOn,
|
|
490
|
+
...extraCustomerProps,
|
|
491
|
+
notify: notify2,
|
|
492
|
+
confirm,
|
|
493
|
+
formatError: formatErr
|
|
494
|
+
}
|
|
495
|
+
),
|
|
496
|
+
active === "roles" && /* @__PURE__ */ jsx4(
|
|
497
|
+
RoleAdmin,
|
|
498
|
+
{
|
|
499
|
+
client: rolesClient,
|
|
500
|
+
lang,
|
|
501
|
+
onChange: load,
|
|
502
|
+
currentRole: user.role,
|
|
503
|
+
notify: notify2,
|
|
504
|
+
confirm,
|
|
505
|
+
formatError: formatErr
|
|
506
|
+
}
|
|
507
|
+
),
|
|
508
|
+
active === "entra" && renderEntraTab?.(load),
|
|
509
|
+
active === "signIn" && policy && /* @__PURE__ */ jsx4("div", { "data-testid": "login-policy-card", className: "bg-card border border-border rounded-sm px-4 py-3", children: /* @__PURE__ */ jsx4(
|
|
510
|
+
PasswordPolicySelect,
|
|
511
|
+
{
|
|
512
|
+
value: policy.value,
|
|
513
|
+
emergencyCount,
|
|
514
|
+
forced: policy.forced,
|
|
515
|
+
onChange: savePolicy,
|
|
516
|
+
lang,
|
|
517
|
+
testId: "login-policy"
|
|
518
|
+
}
|
|
519
|
+
) })
|
|
520
|
+
]
|
|
521
|
+
}
|
|
522
|
+
) });
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// src/app-kit/ScalioLoginPage.tsx
|
|
526
|
+
import { useCallback as useCallback2, useEffect as useEffect3 } from "react";
|
|
527
|
+
import { useNavigate as useNavigate2 } from "react-router-dom";
|
|
528
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
529
|
+
function ScalioLoginPage({
|
|
530
|
+
api,
|
|
531
|
+
apiBase,
|
|
532
|
+
auth,
|
|
533
|
+
appName,
|
|
534
|
+
brand,
|
|
535
|
+
lang,
|
|
536
|
+
onLangChange,
|
|
537
|
+
legalUrl,
|
|
538
|
+
passkeys = false,
|
|
539
|
+
clearSessionKeys = [],
|
|
540
|
+
afterLoginTo = "/",
|
|
541
|
+
onSignedIn
|
|
542
|
+
}) {
|
|
543
|
+
const navigate = useNavigate2();
|
|
544
|
+
useEffect3(() => {
|
|
545
|
+
if (clearSessionKeys.length === 0) return;
|
|
546
|
+
try {
|
|
547
|
+
for (const key of clearSessionKeys) {
|
|
548
|
+
sessionStorage.removeItem(key);
|
|
549
|
+
}
|
|
550
|
+
} catch {
|
|
551
|
+
}
|
|
552
|
+
}, [clearSessionKeys]);
|
|
553
|
+
const handleSignedIn = useCallback2(() => {
|
|
554
|
+
if (onSignedIn) onSignedIn();
|
|
555
|
+
else navigate(afterLoginTo, { replace: true });
|
|
556
|
+
}, [onSignedIn, navigate, afterLoginTo]);
|
|
557
|
+
return /* @__PURE__ */ jsx5(
|
|
558
|
+
LoginPage,
|
|
559
|
+
{
|
|
560
|
+
api,
|
|
561
|
+
apiBase,
|
|
562
|
+
auth,
|
|
563
|
+
appName,
|
|
564
|
+
brand,
|
|
565
|
+
lang,
|
|
566
|
+
onLangChange,
|
|
567
|
+
legalUrl,
|
|
568
|
+
passkeys,
|
|
569
|
+
onSignedIn: handleSignedIn
|
|
570
|
+
}
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// src/app-kit/ScalioInvitePage.tsx
|
|
575
|
+
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
576
|
+
import { useNavigate as useNavigate3 } from "react-router-dom";
|
|
577
|
+
import { Loader2 as Loader22 } from "lucide-react";
|
|
578
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
579
|
+
var FIELD_CLASS2 = "mt-1 w-full h-11 px-3 bg-background border border-input rounded-sm text-sm focus:outline-none focus:ring-1 focus:ring-ring";
|
|
580
|
+
var LABEL_CLASS2 = "text-[11px] font-bold uppercase tracking-widest text-muted-foreground";
|
|
581
|
+
function ScalioInvitePage({
|
|
582
|
+
api,
|
|
583
|
+
brand,
|
|
584
|
+
welcomeTitle,
|
|
585
|
+
legalUrl,
|
|
586
|
+
lang,
|
|
587
|
+
onLangChange,
|
|
588
|
+
t,
|
|
589
|
+
formatApiErrorDetail,
|
|
590
|
+
onAuthenticated,
|
|
591
|
+
redirectTo = "/"
|
|
592
|
+
}) {
|
|
593
|
+
const navigate = useNavigate3();
|
|
594
|
+
const [token] = useState3(() => typeof window !== "undefined" ? window.location.hash.replace(/^#/, "") : "");
|
|
595
|
+
const [info, setInfo] = useState3(null);
|
|
596
|
+
const [invalid, setInvalid] = useState3(false);
|
|
597
|
+
const [pw, setPw] = useState3("");
|
|
598
|
+
const [pw2, setPw2] = useState3("");
|
|
599
|
+
const [error, setError] = useState3("");
|
|
600
|
+
const [busy, setBusy] = useState3(false);
|
|
601
|
+
useEffect4(() => {
|
|
602
|
+
if (!token) {
|
|
603
|
+
setInvalid(true);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
api.get(`/auth/invite/${encodeURIComponent(token)}`).then((r) => setInfo(r.data)).catch(() => setInvalid(true));
|
|
607
|
+
}, [api, token]);
|
|
608
|
+
const submit = async (e) => {
|
|
609
|
+
e.preventDefault();
|
|
610
|
+
setError("");
|
|
611
|
+
if (pw !== pw2) {
|
|
612
|
+
setError(t("The passwords do not match."));
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
setBusy(true);
|
|
616
|
+
try {
|
|
617
|
+
const { data } = await api.post(`/auth/invite/${encodeURIComponent(token)}`, { password: pw });
|
|
618
|
+
onAuthenticated(data.user);
|
|
619
|
+
if (typeof window !== "undefined") {
|
|
620
|
+
window.history.replaceState(null, "", "/invite");
|
|
621
|
+
}
|
|
622
|
+
navigate(redirectTo, { replace: true });
|
|
623
|
+
} catch (err) {
|
|
624
|
+
const eObj = err;
|
|
625
|
+
setError(formatApiErrorDetail(eObj?.response?.data?.detail) || eObj?.message || t("The action failed."));
|
|
626
|
+
} finally {
|
|
627
|
+
setBusy(false);
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
return /* @__PURE__ */ jsx6(AuthLayout, { legalUrl, brand, lang, onLangChange, children: /* @__PURE__ */ jsxs4("div", { className: "space-y-4", "data-testid": "invite-page", children: [
|
|
631
|
+
/* @__PURE__ */ jsx6(
|
|
632
|
+
AuthHeader,
|
|
633
|
+
{
|
|
634
|
+
eyebrow: info?.email,
|
|
635
|
+
title: welcomeTitle,
|
|
636
|
+
subtitle: t("Choose your password to finish the invitation.")
|
|
637
|
+
}
|
|
638
|
+
),
|
|
639
|
+
invalid && /* @__PURE__ */ jsx6(AuthMessage, { kind: "error", testId: "invite-invalid", children: t("This invitation is no longer valid. Ask an administrator for a new one.") }),
|
|
640
|
+
!invalid && !info && /* @__PURE__ */ jsx6(Loader22, { className: "w-5 h-5 animate-spin text-primary" }),
|
|
641
|
+
info && /* @__PURE__ */ jsxs4("form", { onSubmit: submit, className: "space-y-3", children: [
|
|
642
|
+
/* @__PURE__ */ jsxs4("label", { className: "block", children: [
|
|
643
|
+
/* @__PURE__ */ jsx6("span", { className: LABEL_CLASS2, children: t("New password") }),
|
|
644
|
+
/* @__PURE__ */ jsx6(
|
|
645
|
+
"input",
|
|
646
|
+
{
|
|
647
|
+
type: "password",
|
|
648
|
+
autoComplete: "new-password",
|
|
649
|
+
className: FIELD_CLASS2,
|
|
650
|
+
value: pw,
|
|
651
|
+
onChange: (e) => setPw(e.target.value),
|
|
652
|
+
"data-testid": "invite-password"
|
|
653
|
+
}
|
|
654
|
+
)
|
|
655
|
+
] }),
|
|
656
|
+
/* @__PURE__ */ jsxs4("label", { className: "block", children: [
|
|
657
|
+
/* @__PURE__ */ jsx6("span", { className: LABEL_CLASS2, children: t("Repeat password") }),
|
|
658
|
+
/* @__PURE__ */ jsx6(
|
|
659
|
+
"input",
|
|
660
|
+
{
|
|
661
|
+
type: "password",
|
|
662
|
+
autoComplete: "new-password",
|
|
663
|
+
className: FIELD_CLASS2,
|
|
664
|
+
value: pw2,
|
|
665
|
+
onChange: (e) => setPw2(e.target.value),
|
|
666
|
+
"data-testid": "invite-password2"
|
|
667
|
+
}
|
|
668
|
+
)
|
|
669
|
+
] }),
|
|
670
|
+
error && /* @__PURE__ */ jsx6(AuthMessage, { kind: "error", testId: "invite-error", children: error }),
|
|
671
|
+
/* @__PURE__ */ jsxs4(
|
|
672
|
+
"button",
|
|
673
|
+
{
|
|
674
|
+
type: "submit",
|
|
675
|
+
disabled: busy,
|
|
676
|
+
"data-testid": "invite-submit",
|
|
677
|
+
className: "w-full h-11 flex items-center justify-center gap-2 bg-primary text-primary-foreground rounded-sm text-sm font-bold uppercase tracking-wider hover:bg-primary/90 disabled:opacity-60",
|
|
678
|
+
children: [
|
|
679
|
+
busy && /* @__PURE__ */ jsx6(Loader22, { className: "w-4 h-4 animate-spin" }),
|
|
680
|
+
t("Save password and sign in")
|
|
681
|
+
]
|
|
682
|
+
}
|
|
683
|
+
)
|
|
684
|
+
] })
|
|
685
|
+
] }) });
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// src/app-kit/ScalioAuditPages.tsx
|
|
689
|
+
import { useMemo as useMemo3 } from "react";
|
|
690
|
+
import { Link, NavLink as NavLink2 } from "react-router-dom";
|
|
691
|
+
import { toast as toast5 } from "sonner";
|
|
692
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
693
|
+
var defaultNotify2 = (text, tone) => {
|
|
694
|
+
if (tone === "error") toast5.error(text);
|
|
695
|
+
else toast5.success(text);
|
|
696
|
+
};
|
|
697
|
+
function ScalioAuditHeader({ lang, t }) {
|
|
698
|
+
const L = labelsFor(lang);
|
|
699
|
+
return /* @__PURE__ */ jsxs5("div", { className: "space-y-3", children: [
|
|
700
|
+
/* @__PURE__ */ jsx7(PageHeader, { title: L.auditLog, subtitle: t("Who changed what, and the background jobs of this installation") }),
|
|
701
|
+
/* @__PURE__ */ jsx7(AuditNav, { link: NavLink2, lang })
|
|
702
|
+
] });
|
|
703
|
+
}
|
|
704
|
+
function ScalioAuditPage({
|
|
705
|
+
api,
|
|
706
|
+
user,
|
|
707
|
+
lang,
|
|
708
|
+
t,
|
|
709
|
+
actionLabel,
|
|
710
|
+
storageKey
|
|
711
|
+
}) {
|
|
712
|
+
const client = useMemo3(() => auditApi(api), [api]);
|
|
713
|
+
if (!can(user, "audit.view")) return null;
|
|
714
|
+
return /* @__PURE__ */ jsxs5("div", { "data-testid": "audit-page", className: "space-y-5", children: [
|
|
715
|
+
/* @__PURE__ */ jsx7(ScalioAuditHeader, { lang, t }),
|
|
716
|
+
/* @__PURE__ */ jsx7(AuditLog, { client, lang, notify: defaultNotify2, actionLabel, storageKey })
|
|
717
|
+
] });
|
|
718
|
+
}
|
|
719
|
+
function ScalioJobsPage({ api, user, lang, t, confirm }) {
|
|
720
|
+
const client = useMemo3(() => jobsApi(api), [api]);
|
|
721
|
+
if (!can(user, "audit.view")) return null;
|
|
722
|
+
return /* @__PURE__ */ jsxs5("div", { "data-testid": "jobs-page", className: "space-y-5", children: [
|
|
723
|
+
/* @__PURE__ */ jsx7(ScalioAuditHeader, { lang, t }),
|
|
724
|
+
/* @__PURE__ */ jsx7(
|
|
725
|
+
JobsPanel,
|
|
726
|
+
{
|
|
727
|
+
client,
|
|
728
|
+
lang,
|
|
729
|
+
canRun: can(user, "jobs.run"),
|
|
730
|
+
link: Link,
|
|
731
|
+
confirm,
|
|
732
|
+
notify: defaultNotify2
|
|
733
|
+
}
|
|
734
|
+
)
|
|
735
|
+
] });
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// src/app-kit/ScalioSelfTestPage.tsx
|
|
739
|
+
import { useEffect as useEffect5, useMemo as useMemo4, useState as useState4 } from "react";
|
|
740
|
+
import { Navigate as Navigate2 } from "react-router-dom";
|
|
741
|
+
import { toast as toast6 } from "sonner";
|
|
742
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
743
|
+
function ScalioSelfTestPage({ api, user, lang, t }) {
|
|
744
|
+
const [on, setOn] = useState4(null);
|
|
745
|
+
const client = useMemo4(() => selftestApi(api), [api]);
|
|
746
|
+
useEffect5(() => {
|
|
747
|
+
api.get("/e2e/status").then((r) => setOn(Boolean(r.data?.enabled))).catch(() => setOn(false));
|
|
748
|
+
}, [api]);
|
|
749
|
+
if (user?.role !== "admin" || on === false) return /* @__PURE__ */ jsx8(Navigate2, { to: "/", replace: true });
|
|
750
|
+
if (on === null) return null;
|
|
751
|
+
return /* @__PURE__ */ jsxs6("div", { "data-testid": "selftest-page", className: "space-y-5", children: [
|
|
752
|
+
/* @__PURE__ */ jsx8(PageHeader, { eyebrow: t("Tests"), title: t("E2E self-check"), subtitle: t("Self-check of this test instance") }),
|
|
753
|
+
/* @__PURE__ */ jsx8(
|
|
754
|
+
SelfTestPanel,
|
|
755
|
+
{
|
|
756
|
+
client,
|
|
757
|
+
lang,
|
|
758
|
+
notify: (text, tone) => tone === "error" ? toast6.error(text) : toast6.success(text)
|
|
759
|
+
}
|
|
760
|
+
)
|
|
761
|
+
] });
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// src/app-kit/ScalioBackupSection.tsx
|
|
765
|
+
import { useEffect as useEffect6, useMemo as useMemo5, useState as useState5 } from "react";
|
|
766
|
+
import { Link as Link2 } from "react-router-dom";
|
|
767
|
+
import { toast as toast7 } from "sonner";
|
|
768
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
769
|
+
var notify = (text, tone) => {
|
|
770
|
+
if (tone === "error") toast7.error(text);
|
|
771
|
+
else toast7.success(text);
|
|
772
|
+
};
|
|
773
|
+
function ScalioBackupSection({
|
|
774
|
+
api,
|
|
775
|
+
lang,
|
|
776
|
+
t,
|
|
777
|
+
onSignIn,
|
|
778
|
+
withDataOnLabel,
|
|
779
|
+
description,
|
|
780
|
+
accountTo = "/profile"
|
|
781
|
+
}) {
|
|
782
|
+
const client = useMemo5(() => backupApi(api), [api]);
|
|
783
|
+
const labels = useMemo5(
|
|
784
|
+
() => withDataOnLabel ? { backup: { withDataOn: withDataOnLabel } } : void 0,
|
|
785
|
+
[withDataOnLabel]
|
|
786
|
+
);
|
|
787
|
+
return /* @__PURE__ */ jsx9(
|
|
788
|
+
SettingsSection,
|
|
789
|
+
{
|
|
790
|
+
id: "backup",
|
|
791
|
+
title: t("Backup"),
|
|
792
|
+
testId: "backup-card",
|
|
793
|
+
description: description ?? t("Encrypted export and import, e.g. to move to another instance. After a move the tenants are connected again."),
|
|
794
|
+
children: /* @__PURE__ */ jsx9(
|
|
795
|
+
BackupPanel,
|
|
796
|
+
{
|
|
797
|
+
client,
|
|
798
|
+
lang,
|
|
799
|
+
labels,
|
|
800
|
+
accountTo,
|
|
801
|
+
link: Link2,
|
|
802
|
+
notify,
|
|
803
|
+
onSignIn
|
|
804
|
+
}
|
|
805
|
+
)
|
|
806
|
+
}
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
function ScalioMaintenanceBanner({ api, lang }) {
|
|
810
|
+
const client = useMemo5(() => backupApi(api), [api]);
|
|
811
|
+
const [on, setOn] = useState5(false);
|
|
812
|
+
useEffect6(() => {
|
|
813
|
+
const show = () => setOn(true);
|
|
814
|
+
window.addEventListener("scalio-maintenance", show);
|
|
815
|
+
return () => window.removeEventListener("scalio-maintenance", show);
|
|
816
|
+
}, []);
|
|
817
|
+
return on ? /* @__PURE__ */ jsx9(MaintenanceNotice, { client, lang }) : null;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// src/app-kit/ScalioSaasUpdatesSection.tsx
|
|
821
|
+
import { useEffect as useEffect7, useMemo as useMemo6, useState as useState6 } from "react";
|
|
822
|
+
import { toast as toast8 } from "sonner";
|
|
823
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
824
|
+
function ScalioSaasUpdateBanner({ api, lang, onOpen }) {
|
|
825
|
+
const client = useMemo6(() => saasUpdatesApi(api), [api]);
|
|
826
|
+
return /* @__PURE__ */ jsx10(UpdateBanner, { client, lang, onOpen });
|
|
827
|
+
}
|
|
828
|
+
function ScalioSaasUpdatesSection({
|
|
829
|
+
api,
|
|
830
|
+
lang,
|
|
831
|
+
t,
|
|
832
|
+
admin = true
|
|
833
|
+
}) {
|
|
834
|
+
const client = useMemo6(() => saasUpdatesApi(api), [api]);
|
|
835
|
+
const notify2 = useMemo6(
|
|
836
|
+
() => (msg, tone) => tone === "error" ? toast8.error(msg) : toast8.success(msg),
|
|
837
|
+
[]
|
|
838
|
+
);
|
|
839
|
+
const [prerelease, setPrerelease] = useState6(false);
|
|
840
|
+
useEffect7(() => {
|
|
841
|
+
let alive = true;
|
|
842
|
+
client.state().then((d) => {
|
|
843
|
+
if (alive) setPrerelease(Boolean(d?.prerelease?.opt_in));
|
|
844
|
+
}).catch(() => {
|
|
845
|
+
});
|
|
846
|
+
return () => {
|
|
847
|
+
alive = false;
|
|
848
|
+
};
|
|
849
|
+
}, [client]);
|
|
850
|
+
const onPrereleaseChange = async (on, opts) => {
|
|
851
|
+
await api.put("/saas-updates/prerelease-error-reports", { enabled: Boolean(on && opts?.errorReports) });
|
|
852
|
+
const d = await client.act("prerelease", { enabled: Boolean(on) });
|
|
853
|
+
setPrerelease(d?.prerelease ? Boolean(d.prerelease.opt_in) : Boolean(on));
|
|
854
|
+
};
|
|
855
|
+
return /* @__PURE__ */ jsx10(
|
|
856
|
+
SettingsSection,
|
|
857
|
+
{
|
|
858
|
+
id: "updates",
|
|
859
|
+
title: t("Updates"),
|
|
860
|
+
description: t("New versions from Scalio, your maintenance window and the deadline"),
|
|
861
|
+
testId: "saas-updates-card",
|
|
862
|
+
children: /* @__PURE__ */ jsx10(
|
|
863
|
+
SaasUpdatesPanel,
|
|
864
|
+
{
|
|
865
|
+
client,
|
|
866
|
+
lang,
|
|
867
|
+
notify: notify2,
|
|
868
|
+
admin,
|
|
869
|
+
prerelease,
|
|
870
|
+
onPrereleaseChange
|
|
871
|
+
}
|
|
872
|
+
)
|
|
873
|
+
}
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// src/app-kit/ScalioSupportCard.tsx
|
|
878
|
+
import { useMemo as useMemo7 } from "react";
|
|
879
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
880
|
+
function ScalioSupportCard({ api, lang, t }) {
|
|
881
|
+
const client = useMemo7(() => supportApi(api), [api]);
|
|
882
|
+
return /* @__PURE__ */ jsx11(SettingsSection, { id: "support", title: t("Support connection"), testId: "support-connection-card", children: /* @__PURE__ */ jsx11(SupportConnection, { client, lang }) });
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// src/app-kit/ScalioMailSettings.tsx
|
|
886
|
+
import { useMemo as useMemo8 } from "react";
|
|
887
|
+
import { toast as toast9 } from "sonner";
|
|
888
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
889
|
+
var defaultNotify3 = (text, tone) => {
|
|
890
|
+
if (tone === "error") toast9.error(text);
|
|
891
|
+
else toast9.success(text);
|
|
892
|
+
};
|
|
893
|
+
function ScalioMailSettings({
|
|
894
|
+
api,
|
|
895
|
+
lang,
|
|
896
|
+
formatApiErrorDetail
|
|
897
|
+
}) {
|
|
898
|
+
const client = useMemo8(() => mailApi(api), [api]);
|
|
899
|
+
const formatError = (e) => {
|
|
900
|
+
const err = e;
|
|
901
|
+
return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || "";
|
|
902
|
+
};
|
|
903
|
+
return /* @__PURE__ */ jsx12(MailTransport, { client, lang, notify: defaultNotify3, formatError });
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// src/app-kit/ScalioLicensePanel.tsx
|
|
907
|
+
import { useMemo as useMemo9 } from "react";
|
|
908
|
+
import { toast as toast10 } from "sonner";
|
|
909
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
910
|
+
var defaultNotify4 = (text, tone) => {
|
|
911
|
+
if (tone === "error") toast10.error(text);
|
|
912
|
+
else toast10.success(text);
|
|
913
|
+
};
|
|
914
|
+
function ScalioLicensePanel({
|
|
915
|
+
api,
|
|
916
|
+
product,
|
|
917
|
+
lang,
|
|
918
|
+
kindLabel,
|
|
919
|
+
featureLabel,
|
|
920
|
+
confirm,
|
|
921
|
+
formatApiErrorDetail,
|
|
922
|
+
noFeatures
|
|
923
|
+
}) {
|
|
924
|
+
const client = useMemo9(() => licenseApi(api), [api]);
|
|
925
|
+
const formatError = (e) => {
|
|
926
|
+
const err = e;
|
|
927
|
+
return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || "";
|
|
928
|
+
};
|
|
929
|
+
return /* @__PURE__ */ jsx13(
|
|
930
|
+
LicensePanel,
|
|
931
|
+
{
|
|
932
|
+
client,
|
|
933
|
+
lang,
|
|
934
|
+
product,
|
|
935
|
+
kindLabel,
|
|
936
|
+
featureLabel,
|
|
937
|
+
noFeatures,
|
|
938
|
+
notify: defaultNotify4,
|
|
939
|
+
confirm,
|
|
940
|
+
formatError
|
|
941
|
+
}
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
// src/app-kit/ScalioFactoryReset.tsx
|
|
946
|
+
import { useMemo as useMemo10 } from "react";
|
|
947
|
+
import { Link as Link3 } from "react-router-dom";
|
|
948
|
+
import { toast as toast11 } from "sonner";
|
|
949
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
950
|
+
var defaultNotify5 = (text, tone) => {
|
|
951
|
+
if (tone === "error") toast11.error(text);
|
|
952
|
+
else toast11.success(text);
|
|
953
|
+
};
|
|
954
|
+
function ScalioFactoryReset({
|
|
955
|
+
api,
|
|
956
|
+
lang,
|
|
957
|
+
formatApiErrorDetail,
|
|
958
|
+
accountTo = "/profile",
|
|
959
|
+
backupTo = "/settings/backup"
|
|
960
|
+
}) {
|
|
961
|
+
const client = useMemo10(() => factoryResetApi(api), [api]);
|
|
962
|
+
const formatError = (e) => {
|
|
963
|
+
const err = e;
|
|
964
|
+
return formatApiErrorDetail(err?.response?.data?.detail) || err?.message || "";
|
|
965
|
+
};
|
|
966
|
+
return /* @__PURE__ */ jsx14(
|
|
967
|
+
FactoryReset,
|
|
968
|
+
{
|
|
969
|
+
client,
|
|
970
|
+
lang,
|
|
971
|
+
accountTo,
|
|
972
|
+
backupTo,
|
|
973
|
+
link: Link3,
|
|
974
|
+
notify: defaultNotify5,
|
|
975
|
+
formatError
|
|
976
|
+
}
|
|
977
|
+
);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// src/app-kit/ScalioRoleTenants.tsx
|
|
981
|
+
import { useCallback as useCallback3, useEffect as useEffect8, useState as useState7 } from "react";
|
|
982
|
+
import { toast as toast12 } from "sonner";
|
|
983
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
984
|
+
var defaultNotify6 = (text, tone) => {
|
|
985
|
+
if (tone === "error") toast12.error(text);
|
|
986
|
+
else toast12.success(text);
|
|
987
|
+
};
|
|
988
|
+
function ScalioRoleTenants({
|
|
989
|
+
api,
|
|
990
|
+
apiBaseUrl,
|
|
991
|
+
lang,
|
|
992
|
+
t,
|
|
993
|
+
confirm,
|
|
994
|
+
formatApiErrorDetail,
|
|
995
|
+
onChange
|
|
996
|
+
}) {
|
|
997
|
+
const [source, setSource] = useState7(null);
|
|
998
|
+
const [ssoOn, setSsoOn] = useState7(false);
|
|
999
|
+
const load = useCallback3(() => {
|
|
1000
|
+
api.get("/users/role-source").then((r) => setSource(r.data)).catch(() => setSource(null));
|
|
1001
|
+
api.get("/auth/scalio/status").then((r) => setSsoOn(Boolean(r.data?.enabled))).catch(() => setSsoOn(false));
|
|
1002
|
+
}, [api]);
|
|
1003
|
+
useEffect8(() => {
|
|
1004
|
+
load();
|
|
1005
|
+
}, [load]);
|
|
1006
|
+
if (!source) return null;
|
|
1007
|
+
const save = async ({ source: value, tenants }) => {
|
|
1008
|
+
await api.put("/users/role-source", { source: value, tenants });
|
|
1009
|
+
load();
|
|
1010
|
+
onChange?.();
|
|
1011
|
+
};
|
|
1012
|
+
const formatError = (e) => {
|
|
1013
|
+
const err = e;
|
|
1014
|
+
return err?.response?.data?.detail ? formatApiErrorDetail(err.response.data.detail) : t("The action failed.");
|
|
1015
|
+
};
|
|
1016
|
+
return /* @__PURE__ */ jsx15("div", { className: "bg-card border border-border rounded-sm px-4 py-3", "data-testid": "role-tenants", children: /* @__PURE__ */ jsx15(
|
|
1017
|
+
RoleSourceSettings,
|
|
1018
|
+
{
|
|
1019
|
+
lang,
|
|
1020
|
+
tenants: true,
|
|
1021
|
+
confirm,
|
|
1022
|
+
onSave: save,
|
|
1023
|
+
consentUrl: ssoOn ? `${apiBaseUrl}/auth/scalio/consent` : void 0,
|
|
1024
|
+
value: { source: source.source, values: source.values, tenants: source.tenants },
|
|
1025
|
+
notify: defaultNotify6,
|
|
1026
|
+
formatError
|
|
1027
|
+
}
|
|
1028
|
+
) });
|
|
1029
|
+
}
|
|
1030
|
+
export {
|
|
1031
|
+
ScalioAuditHeader,
|
|
1032
|
+
ScalioAuditPage,
|
|
1033
|
+
ScalioBackupSection,
|
|
1034
|
+
ScalioFactoryReset,
|
|
1035
|
+
ScalioInvitePage,
|
|
1036
|
+
ScalioJobsPage,
|
|
1037
|
+
ScalioLicensePanel,
|
|
1038
|
+
ScalioLoginPage,
|
|
1039
|
+
ScalioMailSettings,
|
|
1040
|
+
ScalioMaintenanceBanner,
|
|
1041
|
+
ScalioPasswordChangePage,
|
|
1042
|
+
ScalioProfilePage,
|
|
1043
|
+
ScalioRoleTenants,
|
|
1044
|
+
ScalioSaasUpdateBanner,
|
|
1045
|
+
ScalioSaasUpdatesSection,
|
|
1046
|
+
ScalioSecurityFactors,
|
|
1047
|
+
ScalioSelfTestPage,
|
|
1048
|
+
ScalioSupportCard,
|
|
1049
|
+
ScalioUsersPage
|
|
1050
|
+
};
|
|
1051
|
+
//# sourceMappingURL=index.mjs.map
|