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