@firecms/user_management 3.0.0-beta.10 → 3.0.0-beta.12
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/hooks/useBuildUserManagement.d.ts +5 -13
- package/dist/index.es.js +1786 -1166
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1784 -1165
- package/dist/index.umd.js.map +1 -1
- package/dist/types/user_management.d.ts +1 -13
- package/dist/useUserManagementPlugin.d.ts +5 -5
- package/dist/utils/permissions.d.ts +2 -2
- package/package.json +13 -11
- package/src/components/roles/RolesDetailsForm.tsx +12 -9
- package/src/components/roles/RolesView.tsx +9 -17
- package/src/components/users/UserDetailsForm.tsx +7 -10
- package/src/components/users/UsersTable.tsx +0 -2
- package/src/components/users/UsersView.tsx +1 -4
- package/src/hooks/useBuildUserManagement.tsx +75 -56
- package/src/types/user_management.tsx +2 -16
- package/src/useUserManagementPlugin.tsx +6 -6
- package/src/utils/permissions.ts +2 -2
package/dist/index.es.js
CHANGED
@@ -2,7 +2,8 @@ import React, { useEffect, useCallback, useContext, useState } from "react";
|
|
2
2
|
import equal from "react-fast-compare";
|
3
3
|
import { removeUndefined, useAuthController, toSnakeCase, FieldCaption, ConfirmationDialog, useNavigationController, useSnackbarController, useCustomizationController, defaultDateFormat } from "@firecms/core";
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
5
|
-
import {
|
5
|
+
import { c } from "react-compiler-runtime";
|
6
|
+
import { getColorSchemeForSeed, Chip, TextField, TableRow, TableCell, Checkbox, Tooltip, Button, Typography, DialogTitle, TableHeader, Paper, Table, TableBody, SelectItem, Select, DialogContent, CheckIcon, LoadingButton, DialogActions, Dialog, IconButton, DeleteIcon, CenteredView, AddIcon, Container, MultiSelectItem, MultiSelect } from "@firecms/ui";
|
6
7
|
import * as Yup from "yup";
|
7
8
|
import { useCreateFormex, getIn, Formex } from "@firecms/formex";
|
8
9
|
import { format } from "date-fns";
|
@@ -106,8 +107,8 @@ function parseJwt(token) {
|
|
106
107
|
}
|
107
108
|
const base64Url = token.split(".")[1];
|
108
109
|
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
109
|
-
const jsonPayload = decodeURIComponent(window.atob(base64).split("").map(function(
|
110
|
-
return "%" + ("00" +
|
110
|
+
const jsonPayload = decodeURIComponent(window.atob(base64).split("").map(function(c2) {
|
111
|
+
return "%" + ("00" + c2.charCodeAt(0).toString(16)).slice(-2);
|
111
112
|
}).join(""));
|
112
113
|
return JSON.parse(jsonPayload);
|
113
114
|
}
|
@@ -142,14 +143,16 @@ function hexToRgbaWithOpacity(hexColor, opacity = 10) {
|
|
142
143
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
143
144
|
}
|
144
145
|
function useBuildUserManagement({
|
146
|
+
authController,
|
145
147
|
dataSourceDelegate,
|
146
148
|
usersPath = "__FIRECMS/config/users",
|
147
149
|
rolesPath = "__FIRECMS/config/roles",
|
148
|
-
usersLimit,
|
149
|
-
canEditRoles = true,
|
150
150
|
allowDefaultRolesCreation,
|
151
151
|
includeCollectionConfigPermissions
|
152
152
|
}) {
|
153
|
+
if (!authController) {
|
154
|
+
throw Error("useBuildUserManagement: You need to provide an authController since version 3.0.0-beta.11. Check https://firecms.co/docs/pro/migrating_from_v3_beta");
|
155
|
+
}
|
153
156
|
const [rolesLoading, setRolesLoading] = React.useState(true);
|
154
157
|
const [usersLoading, setUsersLoading] = React.useState(true);
|
155
158
|
const [roles, setRoles] = React.useState([]);
|
@@ -160,14 +163,13 @@ function useBuildUserManagement({
|
|
160
163
|
}));
|
161
164
|
const [rolesError, setRolesError] = React.useState();
|
162
165
|
const [usersError, setUsersError] = React.useState();
|
163
|
-
const
|
166
|
+
const _usersLoading = usersLoading;
|
167
|
+
const _rolesLoading = rolesLoading;
|
168
|
+
const loading = _rolesLoading || _usersLoading;
|
164
169
|
useEffect(() => {
|
165
170
|
if (!dataSourceDelegate || !rolesPath) return;
|
166
171
|
if (dataSourceDelegate.initialised !== void 0 && !dataSourceDelegate.initialised) return;
|
167
|
-
if (
|
168
|
-
setRolesLoading(false);
|
169
|
-
return;
|
170
|
-
}
|
172
|
+
if (authController?.initialLoading) return;
|
171
173
|
setRolesLoading(true);
|
172
174
|
return dataSourceDelegate.listenCollection?.({
|
173
175
|
path: rolesPath,
|
@@ -175,8 +177,9 @@ function useBuildUserManagement({
|
|
175
177
|
setRolesError(void 0);
|
176
178
|
try {
|
177
179
|
const newRoles = entityToRoles(entities);
|
178
|
-
if (!equal(newRoles, roles))
|
180
|
+
if (!equal(newRoles, roles)) {
|
179
181
|
setRoles(newRoles);
|
182
|
+
}
|
180
183
|
} catch (e) {
|
181
184
|
setRoles([]);
|
182
185
|
console.error("Error loading roles", e);
|
@@ -184,53 +187,54 @@ function useBuildUserManagement({
|
|
184
187
|
}
|
185
188
|
setRolesLoading(false);
|
186
189
|
},
|
187
|
-
onError(
|
190
|
+
onError(e_0) {
|
188
191
|
setRoles([]);
|
189
|
-
console.error("Error loading roles",
|
190
|
-
setRolesError(
|
192
|
+
console.error("Error loading roles", e_0);
|
193
|
+
setRolesError(e_0);
|
191
194
|
setRolesLoading(false);
|
192
195
|
}
|
193
196
|
});
|
194
|
-
}, [dataSourceDelegate?.initialised,
|
197
|
+
}, [dataSourceDelegate?.initialised, authController?.initialLoading, authController?.user?.uid, rolesPath]);
|
195
198
|
useEffect(() => {
|
196
199
|
if (!dataSourceDelegate || !usersPath) return;
|
197
|
-
if (dataSourceDelegate.initialised !== void 0 && !dataSourceDelegate.initialised)
|
198
|
-
|
199
|
-
|
200
|
+
if (dataSourceDelegate.initialised !== void 0 && !dataSourceDelegate.initialised) {
|
201
|
+
return;
|
202
|
+
}
|
203
|
+
if (authController?.initialLoading) {
|
200
204
|
return;
|
201
205
|
}
|
202
206
|
setUsersLoading(true);
|
203
207
|
return dataSourceDelegate.listenCollection?.({
|
204
208
|
path: usersPath,
|
205
|
-
onUpdate(
|
209
|
+
onUpdate(entities_0) {
|
210
|
+
console.debug("Updating users", entities_0);
|
206
211
|
setUsersError(void 0);
|
207
212
|
try {
|
208
|
-
const newUsers = entitiesToUsers(
|
209
|
-
|
210
|
-
|
211
|
-
} catch (e) {
|
213
|
+
const newUsers = entitiesToUsers(entities_0);
|
214
|
+
setUsersWithRoleIds(newUsers);
|
215
|
+
} catch (e_1) {
|
212
216
|
setUsersWithRoleIds([]);
|
213
|
-
console.error("Error loading users",
|
214
|
-
setUsersError(
|
217
|
+
console.error("Error loading users", e_1);
|
218
|
+
setUsersError(e_1);
|
215
219
|
}
|
216
220
|
setUsersLoading(false);
|
217
221
|
},
|
218
|
-
onError(
|
222
|
+
onError(e_2) {
|
223
|
+
console.error("Error loading users", e_2);
|
219
224
|
setUsersWithRoleIds([]);
|
220
|
-
|
221
|
-
setUsersError(e);
|
225
|
+
setUsersError(e_2);
|
222
226
|
setUsersLoading(false);
|
223
227
|
}
|
224
228
|
});
|
225
|
-
}, [dataSourceDelegate?.initialised,
|
229
|
+
}, [dataSourceDelegate?.initialised, authController?.initialLoading, authController?.user?.uid, usersPath]);
|
226
230
|
const saveUser = useCallback(async (user) => {
|
227
231
|
if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
|
228
232
|
if (!usersPath) throw Error("useBuildUserManagement Firestore not initialised");
|
229
233
|
console.debug("Persisting user", user);
|
230
|
-
const roleIds = user.roles?.map((
|
234
|
+
const roleIds = user.roles?.map((r_0) => r_0.id);
|
231
235
|
const email = user.email?.toLowerCase().trim();
|
232
236
|
if (!email) throw Error("Email is required");
|
233
|
-
const userExists = users.find((
|
237
|
+
const userExists = users.find((u_0) => u_0.email?.toLowerCase() === email);
|
234
238
|
const data = {
|
235
239
|
...user,
|
236
240
|
roles: roleIds ?? []
|
@@ -262,58 +266,78 @@ function useBuildUserManagement({
|
|
262
266
|
return;
|
263
267
|
});
|
264
268
|
}, [rolesPath, dataSourceDelegate?.initialised]);
|
265
|
-
const deleteUser = useCallback(async (
|
269
|
+
const deleteUser = useCallback(async (user_0) => {
|
266
270
|
if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
|
267
271
|
if (!usersPath) throw Error("useBuildUserManagement Firestore not initialised");
|
268
|
-
console.debug("Deleting",
|
269
|
-
const {
|
272
|
+
console.debug("Deleting", user_0);
|
273
|
+
const {
|
274
|
+
uid
|
275
|
+
} = user_0;
|
270
276
|
const entity = {
|
271
277
|
path: usersPath,
|
272
278
|
id: uid,
|
273
279
|
values: {}
|
274
280
|
};
|
275
|
-
await dataSourceDelegate.deleteEntity({
|
281
|
+
await dataSourceDelegate.deleteEntity({
|
282
|
+
entity
|
283
|
+
});
|
276
284
|
}, [usersPath, dataSourceDelegate?.initialised]);
|
277
|
-
const deleteRole = useCallback(async (
|
285
|
+
const deleteRole = useCallback(async (role_0) => {
|
278
286
|
if (!dataSourceDelegate) throw Error("useBuildUserManagement Firebase not initialised");
|
279
287
|
if (!rolesPath) throw Error("useBuildUserManagement Firestore not initialised");
|
280
|
-
console.debug("Deleting",
|
281
|
-
const {
|
282
|
-
|
288
|
+
console.debug("Deleting", role_0);
|
289
|
+
const {
|
290
|
+
id: id_0
|
291
|
+
} = role_0;
|
292
|
+
const entity_0 = {
|
283
293
|
path: rolesPath,
|
284
|
-
id,
|
294
|
+
id: id_0,
|
285
295
|
values: {}
|
286
296
|
};
|
287
|
-
await dataSourceDelegate.deleteEntity({
|
297
|
+
await dataSourceDelegate.deleteEntity({
|
298
|
+
entity: entity_0
|
299
|
+
});
|
288
300
|
}, [rolesPath, dataSourceDelegate?.initialised]);
|
289
301
|
const collectionPermissions = useCallback(({
|
290
302
|
collection,
|
291
|
-
user
|
303
|
+
user: user_1
|
292
304
|
}) => resolveUserRolePermissions({
|
293
305
|
collection,
|
294
|
-
user
|
306
|
+
user: user_1
|
295
307
|
}), []);
|
296
|
-
const defineRolesFor = useCallback((
|
297
|
-
if (!
|
298
|
-
const
|
308
|
+
const defineRolesFor = useCallback((user_2) => {
|
309
|
+
if (!usersWithRoleIds) throw Error("Users not loaded");
|
310
|
+
const users_0 = usersWithRoleIds.map((u_1) => ({
|
311
|
+
...u_1,
|
312
|
+
roles: roles.filter((r_1) => u_1.roles?.includes(r_1.id))
|
313
|
+
}));
|
314
|
+
const mgmtUser = users_0.find((u_2) => u_2.email?.toLowerCase() === user_2?.email?.toLowerCase());
|
299
315
|
return mgmtUser?.roles;
|
300
|
-
}, [
|
301
|
-
const authenticator = useCallback(({
|
302
|
-
|
316
|
+
}, [roles, usersWithRoleIds]);
|
317
|
+
const authenticator = useCallback(({
|
318
|
+
user: user_3
|
319
|
+
}) => {
|
303
320
|
if (loading) {
|
304
|
-
console.warn("User management is still loading");
|
305
321
|
return false;
|
306
322
|
}
|
307
323
|
if (users.length === 0) {
|
324
|
+
console.warn("No users created yet");
|
308
325
|
return true;
|
309
326
|
}
|
310
|
-
const
|
311
|
-
if (
|
327
|
+
const mgmtUser_0 = users.find((u_3) => u_3.email?.toLowerCase() === user_3?.email?.toLowerCase());
|
328
|
+
if (mgmtUser_0) {
|
329
|
+
console.debug("User found in user management system", mgmtUser_0);
|
312
330
|
return true;
|
313
331
|
}
|
314
332
|
throw Error("Could not find a user with the provided email in the user management system.");
|
315
|
-
}, [loading, users
|
316
|
-
const
|
333
|
+
}, [loading, users]);
|
334
|
+
const userRoles = authController.user ? defineRolesFor(authController.user) : void 0;
|
335
|
+
const isAdmin = (userRoles ?? []).some((r_2) => r_2.id === "admin");
|
336
|
+
const userRoleIds = userRoles?.map((r_3) => r_3.id);
|
337
|
+
useEffect(() => {
|
338
|
+
console.debug("Setting roles", userRoles);
|
339
|
+
authController.setUserRoles?.(userRoles ?? []);
|
340
|
+
}, [userRoleIds]);
|
317
341
|
return {
|
318
342
|
loading,
|
319
343
|
roles,
|
@@ -323,15 +347,20 @@ function useBuildUserManagement({
|
|
323
347
|
rolesError,
|
324
348
|
deleteUser,
|
325
349
|
deleteRole,
|
326
|
-
usersLimit,
|
327
350
|
usersError,
|
328
351
|
isAdmin,
|
329
|
-
canEditRoles: canEditRoles === void 0 ? true : canEditRoles,
|
330
352
|
allowDefaultRolesCreation: allowDefaultRolesCreation === void 0 ? true : allowDefaultRolesCreation,
|
331
353
|
includeCollectionConfigPermissions: Boolean(includeCollectionConfigPermissions),
|
332
354
|
collectionPermissions,
|
333
355
|
defineRolesFor,
|
334
|
-
authenticator
|
356
|
+
authenticator,
|
357
|
+
...authController,
|
358
|
+
initialLoading: authController.initialLoading || loading,
|
359
|
+
userRoles,
|
360
|
+
user: authController.user ? {
|
361
|
+
...authController.user,
|
362
|
+
roles: userRoles
|
363
|
+
} : null
|
335
364
|
};
|
336
365
|
}
|
337
366
|
const entitiesToUsers = (docs) => {
|
@@ -353,32 +382,64 @@ const entityToRoles = (entities) => {
|
|
353
382
|
}));
|
354
383
|
};
|
355
384
|
const UserManagementContext = React.createContext({});
|
356
|
-
function UserManagementProvider({
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
385
|
+
function UserManagementProvider(t0) {
|
386
|
+
const $ = c(3);
|
387
|
+
const {
|
388
|
+
children,
|
389
|
+
userManagement
|
390
|
+
} = t0;
|
391
|
+
let t1;
|
392
|
+
if ($[0] !== children || $[1] !== userManagement) {
|
393
|
+
t1 = /* @__PURE__ */ jsx(UserManagementContext.Provider, { value: userManagement, children });
|
394
|
+
$[0] = children;
|
395
|
+
$[1] = userManagement;
|
396
|
+
$[2] = t1;
|
397
|
+
} else {
|
398
|
+
t1 = $[2];
|
399
|
+
}
|
400
|
+
return t1;
|
361
401
|
}
|
362
|
-
const useUserManagement = () =>
|
363
|
-
|
402
|
+
const useUserManagement = () => {
|
403
|
+
return useContext(UserManagementContext);
|
404
|
+
};
|
405
|
+
function RoleChip(t0) {
|
406
|
+
const $ = c(6);
|
407
|
+
const {
|
408
|
+
role
|
409
|
+
} = t0;
|
364
410
|
let colorScheme;
|
365
411
|
if (role.isAdmin) {
|
366
412
|
colorScheme = "blueDarker";
|
367
|
-
} else
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
413
|
+
} else {
|
414
|
+
if (role.id === "editor") {
|
415
|
+
colorScheme = "yellowLight";
|
416
|
+
} else {
|
417
|
+
if (role.id === "viewer") {
|
418
|
+
colorScheme = "grayLight";
|
419
|
+
} else {
|
420
|
+
let t12;
|
421
|
+
if ($[0] !== role.id) {
|
422
|
+
t12 = getColorSchemeForSeed(role.id);
|
423
|
+
$[0] = role.id;
|
424
|
+
$[1] = t12;
|
425
|
+
} else {
|
426
|
+
t12 = $[1];
|
427
|
+
}
|
428
|
+
colorScheme = t12;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
let t1;
|
433
|
+
if ($[2] !== colorScheme || $[3] !== role.id || $[4] !== role.name) {
|
434
|
+
t1 = /* @__PURE__ */ jsx(Chip, { colorScheme, children: role.name }, role.id);
|
435
|
+
$[2] = colorScheme;
|
436
|
+
$[3] = role.id;
|
437
|
+
$[4] = role.name;
|
438
|
+
$[5] = t1;
|
439
|
+
} else {
|
440
|
+
t1 = $[5];
|
441
|
+
}
|
442
|
+
return t1;
|
382
443
|
}
|
383
444
|
const RoleYupSchema = Yup.object().shape({
|
384
445
|
id: Yup.string().required("Required"),
|
@@ -391,559 +452,757 @@ function canRoleBeEdited(loggedUser) {
|
|
391
452
|
}
|
392
453
|
return true;
|
393
454
|
}
|
394
|
-
function RolesDetailsForm({
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
455
|
+
function RolesDetailsForm(t0) {
|
456
|
+
const $ = c(165);
|
457
|
+
const {
|
458
|
+
open,
|
459
|
+
role,
|
460
|
+
editable,
|
461
|
+
handleClose,
|
462
|
+
collections
|
463
|
+
} = t0;
|
464
|
+
const {
|
465
|
+
saveRole
|
466
|
+
} = useUserManagement();
|
402
467
|
const isNewRole = !role;
|
403
468
|
const {
|
404
469
|
user: loggedInUser
|
405
470
|
} = useAuthController();
|
406
471
|
const [savingError, setSavingError] = useState();
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
472
|
+
let t1;
|
473
|
+
if ($[0] !== loggedInUser || $[1] !== saveRole) {
|
474
|
+
t1 = (role_0) => {
|
475
|
+
setSavingError(void 0);
|
476
|
+
if (!loggedInUser) {
|
477
|
+
throw new Error("User not found");
|
478
|
+
}
|
479
|
+
canRoleBeEdited(loggedInUser);
|
480
|
+
return saveRole(role_0);
|
481
|
+
};
|
482
|
+
$[0] = loggedInUser;
|
483
|
+
$[1] = saveRole;
|
484
|
+
$[2] = t1;
|
485
|
+
} else {
|
486
|
+
t1 = $[2];
|
487
|
+
}
|
488
|
+
const onRoleUpdated = t1;
|
489
|
+
let t2;
|
490
|
+
if ($[3] !== role) {
|
491
|
+
t2 = role ?? {
|
415
492
|
name: ""
|
416
|
-
}
|
417
|
-
|
493
|
+
};
|
494
|
+
$[3] = role;
|
495
|
+
$[4] = t2;
|
496
|
+
} else {
|
497
|
+
t2 = $[4];
|
498
|
+
}
|
499
|
+
let t3;
|
500
|
+
if ($[5] !== handleClose || $[6] !== onRoleUpdated) {
|
501
|
+
t3 = (role_1, formexController) => {
|
418
502
|
try {
|
419
|
-
return onRoleUpdated(
|
503
|
+
return onRoleUpdated(role_1).then(() => {
|
420
504
|
formexController.resetForm({
|
421
|
-
values:
|
505
|
+
values: role_1
|
422
506
|
});
|
423
507
|
handleClose();
|
424
|
-
}).catch((
|
425
|
-
setSavingError(
|
508
|
+
}).catch((e_0) => {
|
509
|
+
setSavingError(e_0);
|
426
510
|
});
|
427
|
-
} catch (
|
511
|
+
} catch (t410) {
|
512
|
+
const e = t410;
|
428
513
|
setSavingError(e);
|
429
514
|
return Promise.resolve();
|
430
515
|
}
|
431
|
-
}
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
516
|
+
};
|
517
|
+
$[5] = handleClose;
|
518
|
+
$[6] = onRoleUpdated;
|
519
|
+
$[7] = t3;
|
520
|
+
} else {
|
521
|
+
t3 = $[7];
|
522
|
+
}
|
523
|
+
let t4;
|
524
|
+
if ($[8] !== t2 || $[9] !== t3) {
|
525
|
+
t4 = {
|
526
|
+
initialValues: t2,
|
527
|
+
onSubmit: t3,
|
528
|
+
validation: _temp3$1
|
529
|
+
};
|
530
|
+
$[8] = t2;
|
531
|
+
$[9] = t3;
|
532
|
+
$[10] = t4;
|
533
|
+
} else {
|
534
|
+
t4 = $[10];
|
535
|
+
}
|
536
|
+
const formex = useCreateFormex(t4);
|
442
537
|
const {
|
443
538
|
isSubmitting,
|
444
539
|
touched,
|
445
|
-
values,
|
446
|
-
errors,
|
540
|
+
values: values_0,
|
541
|
+
errors: errors_0,
|
447
542
|
handleChange,
|
448
543
|
setFieldValue,
|
449
544
|
dirty,
|
450
545
|
setFieldTouched
|
451
546
|
} = formex;
|
452
|
-
const isAdmin =
|
453
|
-
const defaultCreate =
|
454
|
-
const defaultRead =
|
455
|
-
const defaultEdit =
|
456
|
-
const defaultDelete =
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
547
|
+
const isAdmin = values_0.isAdmin ?? false;
|
548
|
+
const defaultCreate = values_0.defaultPermissions?.create ?? false;
|
549
|
+
const defaultRead = values_0.defaultPermissions?.read ?? false;
|
550
|
+
const defaultEdit = values_0.defaultPermissions?.edit ?? false;
|
551
|
+
const defaultDelete = values_0.defaultPermissions?.delete ?? false;
|
552
|
+
let t5;
|
553
|
+
if ($[11] !== setFieldValue || $[12] !== touched || $[13] !== values_0.name) {
|
554
|
+
t5 = () => {
|
555
|
+
const idTouched = getIn(touched, "id");
|
556
|
+
if (!idTouched && values_0.name) {
|
557
|
+
setFieldValue("id", toSnakeCase(values_0.name));
|
558
|
+
}
|
559
|
+
};
|
560
|
+
$[11] = setFieldValue;
|
561
|
+
$[12] = touched;
|
562
|
+
$[13] = values_0.name;
|
563
|
+
$[14] = t5;
|
564
|
+
} else {
|
565
|
+
t5 = $[14];
|
566
|
+
}
|
567
|
+
let t6;
|
568
|
+
if ($[15] !== touched || $[16] !== values_0.name) {
|
569
|
+
t6 = [touched, values_0.name];
|
570
|
+
$[15] = touched;
|
571
|
+
$[16] = values_0.name;
|
572
|
+
$[17] = t6;
|
573
|
+
} else {
|
574
|
+
t6 = $[17];
|
575
|
+
}
|
576
|
+
React.useEffect(t5, t6);
|
577
|
+
let t7;
|
578
|
+
let t8;
|
579
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
580
|
+
t7 = {
|
581
|
+
display: "flex",
|
582
|
+
flexDirection: "column",
|
583
|
+
position: "relative",
|
584
|
+
height: "100%"
|
585
|
+
};
|
586
|
+
t8 = /* @__PURE__ */ jsx(DialogTitle, { variant: "h4", gutterBottom: false, children: "Role" });
|
587
|
+
$[18] = t7;
|
588
|
+
$[19] = t8;
|
589
|
+
} else {
|
590
|
+
t7 = $[18];
|
591
|
+
t8 = $[19];
|
592
|
+
}
|
593
|
+
const t9 = touched.name && Boolean(errors_0.name);
|
594
|
+
const t10 = isAdmin || !editable;
|
595
|
+
let t11;
|
596
|
+
if ($[20] !== handleChange || $[21] !== t10 || $[22] !== t9 || $[23] !== values_0.name) {
|
597
|
+
t11 = /* @__PURE__ */ jsx(TextField, { name: "name", required: true, error: t9, value: values_0.name, disabled: t10, onChange: handleChange, "aria-describedby": "name-helper-text", label: "Name" });
|
598
|
+
$[20] = handleChange;
|
599
|
+
$[21] = t10;
|
600
|
+
$[22] = t9;
|
601
|
+
$[23] = values_0.name;
|
602
|
+
$[24] = t11;
|
603
|
+
} else {
|
604
|
+
t11 = $[24];
|
605
|
+
}
|
606
|
+
const t12 = touched.name && Boolean(errors_0.name) ? errors_0.name : "Name of this role";
|
607
|
+
let t13;
|
608
|
+
if ($[25] !== t12) {
|
609
|
+
t13 = /* @__PURE__ */ jsx(FieldCaption, { children: t12 });
|
610
|
+
$[25] = t12;
|
611
|
+
$[26] = t13;
|
612
|
+
} else {
|
613
|
+
t13 = $[26];
|
614
|
+
}
|
615
|
+
let t14;
|
616
|
+
if ($[27] !== t11 || $[28] !== t13) {
|
617
|
+
t14 = /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-8", children: [
|
618
|
+
t11,
|
619
|
+
t13
|
620
|
+
] });
|
621
|
+
$[27] = t11;
|
622
|
+
$[28] = t13;
|
623
|
+
$[29] = t14;
|
624
|
+
} else {
|
625
|
+
t14 = $[29];
|
626
|
+
}
|
627
|
+
const t15 = touched.id && Boolean(errors_0.id);
|
628
|
+
const t16 = !isNewRole || !editable;
|
629
|
+
let t17;
|
630
|
+
if ($[30] !== handleChange || $[31] !== setFieldTouched) {
|
631
|
+
t17 = (e_2) => {
|
632
|
+
handleChange(e_2);
|
633
|
+
setFieldTouched("id", true);
|
634
|
+
};
|
635
|
+
$[30] = handleChange;
|
636
|
+
$[31] = setFieldTouched;
|
637
|
+
$[32] = t17;
|
638
|
+
} else {
|
639
|
+
t17 = $[32];
|
640
|
+
}
|
641
|
+
let t18;
|
642
|
+
if ($[33] !== t15 || $[34] !== t16 || $[35] !== t17 || $[36] !== values_0.id) {
|
643
|
+
t18 = /* @__PURE__ */ jsx(TextField, { name: "id", required: true, error: t15, value: values_0.id, disabled: t16, onChange: t17, "aria-describedby": "id-helper-text", label: "ID" });
|
644
|
+
$[33] = t15;
|
645
|
+
$[34] = t16;
|
646
|
+
$[35] = t17;
|
647
|
+
$[36] = values_0.id;
|
648
|
+
$[37] = t18;
|
649
|
+
} else {
|
650
|
+
t18 = $[37];
|
651
|
+
}
|
652
|
+
const t19 = touched.id && Boolean(errors_0.id) ? errors_0.id : "ID of this role";
|
653
|
+
let t20;
|
654
|
+
if ($[38] !== t19) {
|
655
|
+
t20 = /* @__PURE__ */ jsx(FieldCaption, { children: t19 });
|
656
|
+
$[38] = t19;
|
657
|
+
$[39] = t20;
|
658
|
+
} else {
|
659
|
+
t20 = $[39];
|
660
|
+
}
|
661
|
+
let t21;
|
662
|
+
if ($[40] !== t18 || $[41] !== t20) {
|
663
|
+
t21 = /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
664
|
+
t18,
|
665
|
+
t20
|
666
|
+
] });
|
667
|
+
$[40] = t18;
|
668
|
+
$[41] = t20;
|
669
|
+
$[42] = t21;
|
670
|
+
} else {
|
671
|
+
t21 = $[42];
|
672
|
+
}
|
673
|
+
let t22;
|
674
|
+
if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
|
675
|
+
t22 = /* @__PURE__ */ jsxs(TableHeader, { className: "rounded-md", children: [
|
676
|
+
/* @__PURE__ */ jsx(TableCell, {}),
|
677
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center", children: "Create entities" }),
|
678
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center", children: "Read entities" }),
|
679
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center", children: "Update entities" }),
|
680
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center", children: "Delete entities" }),
|
681
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center" })
|
682
|
+
] });
|
683
|
+
$[43] = t22;
|
684
|
+
} else {
|
685
|
+
t22 = $[43];
|
686
|
+
}
|
687
|
+
let t23;
|
688
|
+
if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
|
689
|
+
t23 = /* @__PURE__ */ jsx(TableCell, { scope: "row", children: /* @__PURE__ */ jsx("strong", { children: "All collections" }) });
|
690
|
+
$[44] = t23;
|
691
|
+
} else {
|
692
|
+
t23 = $[44];
|
693
|
+
}
|
694
|
+
const t24 = isAdmin || !editable;
|
695
|
+
const t25 = (isAdmin || defaultCreate) ?? false;
|
696
|
+
let t26;
|
697
|
+
if ($[45] !== setFieldValue) {
|
698
|
+
t26 = (checked) => setFieldValue("defaultPermissions.create", checked);
|
699
|
+
$[45] = setFieldValue;
|
700
|
+
$[46] = t26;
|
701
|
+
} else {
|
702
|
+
t26 = $[46];
|
703
|
+
}
|
704
|
+
let t27;
|
705
|
+
if ($[47] !== t24 || $[48] !== t25 || $[49] !== t26) {
|
706
|
+
t27 = /* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(Tooltip, { title: "Create entities in collections", children: /* @__PURE__ */ jsx(Checkbox, { disabled: t24, checked: t25, onCheckedChange: t26 }) }) });
|
707
|
+
$[47] = t24;
|
708
|
+
$[48] = t25;
|
709
|
+
$[49] = t26;
|
710
|
+
$[50] = t27;
|
711
|
+
} else {
|
712
|
+
t27 = $[50];
|
713
|
+
}
|
714
|
+
const t28 = isAdmin || !editable;
|
715
|
+
const t29 = (isAdmin || defaultRead) ?? false;
|
716
|
+
let t30;
|
717
|
+
if ($[51] !== setFieldValue) {
|
718
|
+
t30 = (checked_0) => setFieldValue("defaultPermissions.read", checked_0);
|
719
|
+
$[51] = setFieldValue;
|
720
|
+
$[52] = t30;
|
721
|
+
} else {
|
722
|
+
t30 = $[52];
|
723
|
+
}
|
724
|
+
let t31;
|
725
|
+
if ($[53] !== t28 || $[54] !== t29 || $[55] !== t30) {
|
726
|
+
t31 = /* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(Tooltip, { title: "Access all data in every collection", children: /* @__PURE__ */ jsx(Checkbox, { disabled: t28, checked: t29, onCheckedChange: t30 }) }) });
|
727
|
+
$[53] = t28;
|
728
|
+
$[54] = t29;
|
729
|
+
$[55] = t30;
|
730
|
+
$[56] = t31;
|
731
|
+
} else {
|
732
|
+
t31 = $[56];
|
733
|
+
}
|
734
|
+
const t32 = isAdmin || !editable;
|
735
|
+
const t33 = (isAdmin || defaultEdit) ?? false;
|
736
|
+
let t34;
|
737
|
+
if ($[57] !== setFieldValue) {
|
738
|
+
t34 = (checked_1) => setFieldValue("defaultPermissions.edit", checked_1);
|
739
|
+
$[57] = setFieldValue;
|
740
|
+
$[58] = t34;
|
741
|
+
} else {
|
742
|
+
t34 = $[58];
|
743
|
+
}
|
744
|
+
let t35;
|
745
|
+
if ($[59] !== t32 || $[60] !== t33 || $[61] !== t34) {
|
746
|
+
t35 = /* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(Tooltip, { title: "Update data in any collection", children: /* @__PURE__ */ jsx(Checkbox, { disabled: t32, checked: t33, onCheckedChange: t34 }) }) });
|
747
|
+
$[59] = t32;
|
748
|
+
$[60] = t33;
|
749
|
+
$[61] = t34;
|
750
|
+
$[62] = t35;
|
751
|
+
} else {
|
752
|
+
t35 = $[62];
|
753
|
+
}
|
754
|
+
const t36 = isAdmin || !editable;
|
755
|
+
const t37 = (isAdmin || defaultDelete) ?? false;
|
756
|
+
let t38;
|
757
|
+
if ($[63] !== setFieldValue) {
|
758
|
+
t38 = (checked_2) => setFieldValue("defaultPermissions.delete", checked_2);
|
759
|
+
$[63] = setFieldValue;
|
760
|
+
$[64] = t38;
|
761
|
+
} else {
|
762
|
+
t38 = $[64];
|
763
|
+
}
|
764
|
+
let t39;
|
765
|
+
if ($[65] !== t36 || $[66] !== t37 || $[67] !== t38) {
|
766
|
+
t39 = /* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(Tooltip, { title: "Delete data in any collection", children: /* @__PURE__ */ jsx(Checkbox, { disabled: t36, checked: t37, onCheckedChange: t38 }) }) });
|
767
|
+
$[65] = t36;
|
768
|
+
$[66] = t37;
|
769
|
+
$[67] = t38;
|
770
|
+
$[68] = t39;
|
771
|
+
} else {
|
772
|
+
t39 = $[68];
|
773
|
+
}
|
774
|
+
let t40;
|
775
|
+
if ($[69] === Symbol.for("react.memo_cache_sentinel")) {
|
776
|
+
t40 = /* @__PURE__ */ jsx(TableCell, { align: "center" });
|
777
|
+
$[69] = t40;
|
778
|
+
} else {
|
779
|
+
t40 = $[69];
|
780
|
+
}
|
781
|
+
let t41;
|
782
|
+
if ($[70] !== t27 || $[71] !== t31 || $[72] !== t35 || $[73] !== t39) {
|
783
|
+
t41 = /* @__PURE__ */ jsxs(TableRow, { children: [
|
784
|
+
t23,
|
785
|
+
t27,
|
786
|
+
t31,
|
787
|
+
t35,
|
788
|
+
t39,
|
789
|
+
t40
|
790
|
+
] });
|
791
|
+
$[70] = t27;
|
792
|
+
$[71] = t31;
|
793
|
+
$[72] = t35;
|
794
|
+
$[73] = t39;
|
795
|
+
$[74] = t41;
|
796
|
+
} else {
|
797
|
+
t41 = $[74];
|
798
|
+
}
|
799
|
+
let t42;
|
800
|
+
if ($[75] !== collections || $[76] !== defaultCreate || $[77] !== defaultDelete || $[78] !== defaultEdit || $[79] !== defaultRead || $[80] !== editable || $[81] !== isAdmin || $[82] !== setFieldValue || $[83] !== values_0) {
|
801
|
+
t42 = collections && collections.map((col) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
802
|
+
/* @__PURE__ */ jsx(TableCell, { scope: "row", children: col.name }),
|
803
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(Checkbox, { disabled: isAdmin || defaultCreate || !editable, checked: (isAdmin || defaultCreate || getIn(values_0, `collectionPermissions.${col.id}.create`)) ?? false, onCheckedChange: (checked_3) => setFieldValue(`collectionPermissions.${col.id}.create`, checked_3) }) }),
|
804
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(Checkbox, { disabled: isAdmin || defaultRead || !editable, checked: (isAdmin || defaultRead || getIn(values_0, `collectionPermissions.${col.id}.read`)) ?? false, onCheckedChange: (checked_4) => setFieldValue(`collectionPermissions.${col.id}.read`, checked_4) }) }),
|
805
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(Checkbox, { disabled: isAdmin || defaultEdit || !editable, checked: (isAdmin || defaultEdit || getIn(values_0, `collectionPermissions.${col.id}.edit`)) ?? false, onCheckedChange: (checked_5) => setFieldValue(`collectionPermissions.${col.id}.edit`, checked_5) }) }),
|
806
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(Checkbox, { disabled: isAdmin || defaultDelete || !editable, checked: (isAdmin || defaultDelete || getIn(values_0, `collectionPermissions.${col.id}.delete`)) ?? false, onCheckedChange: (checked_6) => setFieldValue(`collectionPermissions.${col.id}.delete`, checked_6) }) }),
|
807
|
+
/* @__PURE__ */ jsx(TableCell, { align: "center", children: /* @__PURE__ */ jsx(Tooltip, { title: "Allow all permissions in this collections", children: /* @__PURE__ */ jsx(Button, { className: "color-inherit", onClick: () => {
|
808
|
+
setFieldValue(`collectionPermissions.${col.id}.create`, true);
|
809
|
+
setFieldValue(`collectionPermissions.${col.id}.read`, true);
|
810
|
+
setFieldValue(`collectionPermissions.${col.id}.edit`, true);
|
811
|
+
setFieldValue(`collectionPermissions.${col.id}.delete`, true);
|
812
|
+
}, disabled: isAdmin || !editable, variant: "text", children: "All" }) }) })
|
813
|
+
] }, col.name));
|
814
|
+
$[75] = collections;
|
815
|
+
$[76] = defaultCreate;
|
816
|
+
$[77] = defaultDelete;
|
817
|
+
$[78] = defaultEdit;
|
818
|
+
$[79] = defaultRead;
|
819
|
+
$[80] = editable;
|
820
|
+
$[81] = isAdmin;
|
821
|
+
$[82] = setFieldValue;
|
822
|
+
$[83] = values_0;
|
823
|
+
$[84] = t42;
|
824
|
+
} else {
|
825
|
+
t42 = $[84];
|
826
|
+
}
|
827
|
+
let t43;
|
828
|
+
if ($[85] !== t41 || $[86] !== t42) {
|
829
|
+
t43 = /* @__PURE__ */ jsx(Paper, { className: "bg-inherit overflow-hidden", children: /* @__PURE__ */ jsxs(Table, { className: "w-full rounded-md", children: [
|
830
|
+
t22,
|
831
|
+
/* @__PURE__ */ jsxs(TableBody, { children: [
|
832
|
+
t41,
|
833
|
+
t42
|
834
|
+
] })
|
835
|
+
] }) });
|
836
|
+
$[85] = t41;
|
837
|
+
$[86] = t42;
|
838
|
+
$[87] = t43;
|
839
|
+
} else {
|
840
|
+
t43 = $[87];
|
841
|
+
}
|
842
|
+
let t44;
|
843
|
+
if ($[88] === Symbol.for("react.memo_cache_sentinel")) {
|
844
|
+
t44 = /* @__PURE__ */ jsx(FieldCaption, { children: "You can customise the permissions that the users related to this role can perform in the entities of each collection" });
|
845
|
+
$[88] = t44;
|
846
|
+
} else {
|
847
|
+
t44 = $[88];
|
848
|
+
}
|
849
|
+
let t45;
|
850
|
+
if ($[89] !== t43) {
|
851
|
+
t45 = /* @__PURE__ */ jsxs("div", { className: "col-span-12", children: [
|
852
|
+
t43,
|
853
|
+
t44
|
854
|
+
] });
|
855
|
+
$[89] = t43;
|
856
|
+
$[90] = t45;
|
857
|
+
} else {
|
858
|
+
t45 = $[90];
|
859
|
+
}
|
860
|
+
const t46 = touched.config && Boolean(errors_0.config);
|
861
|
+
const t47 = isAdmin || !editable;
|
862
|
+
let t48;
|
863
|
+
if ($[91] !== setFieldValue) {
|
864
|
+
t48 = (event) => setFieldValue("config.createCollections", event.target.value === "true");
|
865
|
+
$[91] = setFieldValue;
|
866
|
+
$[92] = t48;
|
867
|
+
} else {
|
868
|
+
t48 = $[92];
|
869
|
+
}
|
870
|
+
const t49 = isAdmin || values_0.config?.createCollections ? "true" : "false";
|
871
|
+
let t50;
|
872
|
+
let t51;
|
873
|
+
if ($[93] === Symbol.for("react.memo_cache_sentinel")) {
|
874
|
+
t50 = /* @__PURE__ */ jsx(SelectItem, { value: "true", children: " Yes " });
|
875
|
+
t51 = /* @__PURE__ */ jsx(SelectItem, { value: "false", children: " No " });
|
876
|
+
$[93] = t50;
|
877
|
+
$[94] = t51;
|
878
|
+
} else {
|
879
|
+
t50 = $[93];
|
880
|
+
t51 = $[94];
|
881
|
+
}
|
882
|
+
let t52;
|
883
|
+
if ($[95] !== t46 || $[96] !== t47 || $[97] !== t48 || $[98] !== t49) {
|
884
|
+
t52 = /* @__PURE__ */ jsxs(Select, { error: t46, size: "large", fullWidth: true, id: "createCollections", name: "createCollections", label: "Create collections", position: "item-aligned", disabled: t47, onChange: t48, value: t49, renderValue: _temp4$1, children: [
|
885
|
+
t50,
|
886
|
+
t51
|
887
|
+
] });
|
888
|
+
$[95] = t46;
|
889
|
+
$[96] = t47;
|
890
|
+
$[97] = t48;
|
891
|
+
$[98] = t49;
|
892
|
+
$[99] = t52;
|
893
|
+
} else {
|
894
|
+
t52 = $[99];
|
895
|
+
}
|
896
|
+
const t53 = touched.config && Boolean(errors_0.config) ? errors_0.config : "Can the user create collections";
|
897
|
+
let t54;
|
898
|
+
if ($[100] !== t53) {
|
899
|
+
t54 = /* @__PURE__ */ jsx(FieldCaption, { children: t53 });
|
900
|
+
$[100] = t53;
|
901
|
+
$[101] = t54;
|
902
|
+
} else {
|
903
|
+
t54 = $[101];
|
904
|
+
}
|
905
|
+
let t55;
|
906
|
+
if ($[102] !== t52 || $[103] !== t54) {
|
907
|
+
t55 = /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
908
|
+
t52,
|
909
|
+
t54
|
910
|
+
] });
|
911
|
+
$[102] = t52;
|
912
|
+
$[103] = t54;
|
913
|
+
$[104] = t55;
|
914
|
+
} else {
|
915
|
+
t55 = $[104];
|
916
|
+
}
|
917
|
+
const t56 = touched.config && Boolean(errors_0.config);
|
918
|
+
const t57 = isAdmin || !editable;
|
919
|
+
let t58;
|
920
|
+
if ($[105] !== setFieldValue) {
|
921
|
+
t58 = (event_0) => setFieldValue("config.editCollections", event_0.target.value === "own" ? "own" : event_0.target.value === "true");
|
922
|
+
$[105] = setFieldValue;
|
923
|
+
$[106] = t58;
|
924
|
+
} else {
|
925
|
+
t58 = $[106];
|
926
|
+
}
|
927
|
+
const t59 = isAdmin ? "true" : values_0.config?.editCollections === "own" ? "own" : values_0.config?.editCollections ? "true" : "false";
|
928
|
+
let t60;
|
929
|
+
let t61;
|
930
|
+
let t62;
|
931
|
+
if ($[107] === Symbol.for("react.memo_cache_sentinel")) {
|
932
|
+
t60 = /* @__PURE__ */ jsx(SelectItem, { value: "true", children: " Yes " });
|
933
|
+
t61 = /* @__PURE__ */ jsx(SelectItem, { value: "false", children: " No " });
|
934
|
+
t62 = /* @__PURE__ */ jsx(SelectItem, { value: "own", children: " Only his/her own " });
|
935
|
+
$[107] = t60;
|
936
|
+
$[108] = t61;
|
937
|
+
$[109] = t62;
|
938
|
+
} else {
|
939
|
+
t60 = $[107];
|
940
|
+
t61 = $[108];
|
941
|
+
t62 = $[109];
|
942
|
+
}
|
943
|
+
let t63;
|
944
|
+
if ($[110] !== t56 || $[111] !== t57 || $[112] !== t58 || $[113] !== t59) {
|
945
|
+
t63 = /* @__PURE__ */ jsxs(Select, { size: "large", fullWidth: true, error: t56, id: "editCollections", name: "editCollections", label: "Edit collections", disabled: t57, position: "item-aligned", onChange: t58, value: t59, renderValue: _temp5$1, children: [
|
946
|
+
t60,
|
947
|
+
t61,
|
948
|
+
t62
|
949
|
+
] });
|
950
|
+
$[110] = t56;
|
951
|
+
$[111] = t57;
|
952
|
+
$[112] = t58;
|
953
|
+
$[113] = t59;
|
954
|
+
$[114] = t63;
|
955
|
+
} else {
|
956
|
+
t63 = $[114];
|
957
|
+
}
|
958
|
+
const t64 = touched.config && Boolean(errors_0.config) ? errors_0.config : "Can the user edit collections";
|
959
|
+
let t65;
|
960
|
+
if ($[115] !== t64) {
|
961
|
+
t65 = /* @__PURE__ */ jsx(FieldCaption, { children: t64 });
|
962
|
+
$[115] = t64;
|
963
|
+
$[116] = t65;
|
964
|
+
} else {
|
965
|
+
t65 = $[116];
|
966
|
+
}
|
967
|
+
let t66;
|
968
|
+
if ($[117] !== t63 || $[118] !== t65) {
|
969
|
+
t66 = /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
970
|
+
t63,
|
971
|
+
t65
|
972
|
+
] });
|
973
|
+
$[117] = t63;
|
974
|
+
$[118] = t65;
|
975
|
+
$[119] = t66;
|
976
|
+
} else {
|
977
|
+
t66 = $[119];
|
978
|
+
}
|
979
|
+
const t67 = touched.config && Boolean(errors_0.config);
|
980
|
+
const t68 = isAdmin || !editable;
|
981
|
+
let t69;
|
982
|
+
if ($[120] !== setFieldValue) {
|
983
|
+
t69 = (event_1) => setFieldValue("config.deleteCollections", event_1.target.value === "own" ? "own" : event_1.target.value === "true");
|
984
|
+
$[120] = setFieldValue;
|
985
|
+
$[121] = t69;
|
986
|
+
} else {
|
987
|
+
t69 = $[121];
|
988
|
+
}
|
989
|
+
const t70 = isAdmin ? "true" : values_0.config?.deleteCollections === "own" ? "own" : values_0.config?.deleteCollections ? "true" : "false";
|
990
|
+
let t71;
|
991
|
+
let t72;
|
992
|
+
let t73;
|
993
|
+
if ($[122] === Symbol.for("react.memo_cache_sentinel")) {
|
994
|
+
t71 = /* @__PURE__ */ jsx(SelectItem, { value: "true", children: " Yes " });
|
995
|
+
t72 = /* @__PURE__ */ jsx(SelectItem, { value: "false", children: " No " });
|
996
|
+
t73 = /* @__PURE__ */ jsx(SelectItem, { value: "own", children: " Only his/her own " });
|
997
|
+
$[122] = t71;
|
998
|
+
$[123] = t72;
|
999
|
+
$[124] = t73;
|
1000
|
+
} else {
|
1001
|
+
t71 = $[122];
|
1002
|
+
t72 = $[123];
|
1003
|
+
t73 = $[124];
|
1004
|
+
}
|
1005
|
+
let t74;
|
1006
|
+
if ($[125] !== t67 || $[126] !== t68 || $[127] !== t69 || $[128] !== t70) {
|
1007
|
+
t74 = /* @__PURE__ */ jsxs(Select, { size: "large", fullWidth: true, error: t67, id: "deleteCollections", name: "deleteCollections", label: "Delete collections", disabled: t68, position: "item-aligned", onChange: t69, value: t70, renderValue: _temp6$1, children: [
|
1008
|
+
t71,
|
1009
|
+
t72,
|
1010
|
+
t73
|
1011
|
+
] });
|
1012
|
+
$[125] = t67;
|
1013
|
+
$[126] = t68;
|
1014
|
+
$[127] = t69;
|
1015
|
+
$[128] = t70;
|
1016
|
+
$[129] = t74;
|
1017
|
+
} else {
|
1018
|
+
t74 = $[129];
|
1019
|
+
}
|
1020
|
+
const t75 = touched.config && Boolean(errors_0.config) ? errors_0.config : "Can the user delete collections";
|
1021
|
+
let t76;
|
1022
|
+
if ($[130] !== t75) {
|
1023
|
+
t76 = /* @__PURE__ */ jsx(FieldCaption, { children: t75 });
|
1024
|
+
$[130] = t75;
|
1025
|
+
$[131] = t76;
|
1026
|
+
} else {
|
1027
|
+
t76 = $[131];
|
1028
|
+
}
|
1029
|
+
let t77;
|
1030
|
+
if ($[132] !== t74 || $[133] !== t76) {
|
1031
|
+
t77 = /* @__PURE__ */ jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
1032
|
+
t74,
|
1033
|
+
t76
|
1034
|
+
] });
|
1035
|
+
$[132] = t74;
|
1036
|
+
$[133] = t76;
|
1037
|
+
$[134] = t77;
|
1038
|
+
} else {
|
1039
|
+
t77 = $[134];
|
1040
|
+
}
|
1041
|
+
let t78;
|
1042
|
+
if ($[135] !== t14 || $[136] !== t21 || $[137] !== t45 || $[138] !== t55 || $[139] !== t66 || $[140] !== t77) {
|
1043
|
+
t78 = /* @__PURE__ */ jsx(DialogContent, { className: "flex-grow", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 gap-8", children: [
|
1044
|
+
t14,
|
1045
|
+
t21,
|
1046
|
+
t45,
|
1047
|
+
t55,
|
1048
|
+
t66,
|
1049
|
+
t77
|
1050
|
+
] }) });
|
1051
|
+
$[135] = t14;
|
1052
|
+
$[136] = t21;
|
1053
|
+
$[137] = t45;
|
1054
|
+
$[138] = t55;
|
1055
|
+
$[139] = t66;
|
1056
|
+
$[140] = t77;
|
1057
|
+
$[141] = t78;
|
1058
|
+
} else {
|
1059
|
+
t78 = $[141];
|
1060
|
+
}
|
1061
|
+
let t79;
|
1062
|
+
if ($[142] !== savingError) {
|
1063
|
+
t79 = savingError && /* @__PURE__ */ jsx(Typography, { className: "text-red-500 dark:text-red-500", children: savingError.message ?? "There was an error saving this role" });
|
1064
|
+
$[142] = savingError;
|
1065
|
+
$[143] = t79;
|
1066
|
+
} else {
|
1067
|
+
t79 = $[143];
|
1068
|
+
}
|
1069
|
+
let t80;
|
1070
|
+
if ($[144] !== handleClose) {
|
1071
|
+
t80 = /* @__PURE__ */ jsx(Button, { variant: "text", onClick: () => {
|
1072
|
+
handleClose();
|
1073
|
+
}, children: "Cancel" });
|
1074
|
+
$[144] = handleClose;
|
1075
|
+
$[145] = t80;
|
1076
|
+
} else {
|
1077
|
+
t80 = $[145];
|
1078
|
+
}
|
1079
|
+
const t81 = !dirty;
|
1080
|
+
let t82;
|
1081
|
+
if ($[146] === Symbol.for("react.memo_cache_sentinel")) {
|
1082
|
+
t82 = /* @__PURE__ */ jsx(CheckIcon, {});
|
1083
|
+
$[146] = t82;
|
1084
|
+
} else {
|
1085
|
+
t82 = $[146];
|
1086
|
+
}
|
1087
|
+
const t83 = isNewRole ? "Create role" : "Update";
|
1088
|
+
let t84;
|
1089
|
+
if ($[147] !== isSubmitting || $[148] !== t81 || $[149] !== t83) {
|
1090
|
+
t84 = /* @__PURE__ */ jsx(LoadingButton, { variant: "filled", color: "primary", type: "submit", disabled: t81, loading: isSubmitting, startIcon: t82, children: t83 });
|
1091
|
+
$[147] = isSubmitting;
|
1092
|
+
$[148] = t81;
|
1093
|
+
$[149] = t83;
|
1094
|
+
$[150] = t84;
|
1095
|
+
} else {
|
1096
|
+
t84 = $[150];
|
1097
|
+
}
|
1098
|
+
let t85;
|
1099
|
+
if ($[151] !== t79 || $[152] !== t80 || $[153] !== t84) {
|
1100
|
+
t85 = /* @__PURE__ */ jsxs(DialogActions, { position: "sticky", children: [
|
1101
|
+
t79,
|
1102
|
+
t80,
|
1103
|
+
t84
|
1104
|
+
] });
|
1105
|
+
$[151] = t79;
|
1106
|
+
$[152] = t80;
|
1107
|
+
$[153] = t84;
|
1108
|
+
$[154] = t85;
|
1109
|
+
} else {
|
1110
|
+
t85 = $[154];
|
1111
|
+
}
|
1112
|
+
let t86;
|
1113
|
+
if ($[155] !== formex.handleSubmit || $[156] !== t78 || $[157] !== t85) {
|
1114
|
+
t86 = /* @__PURE__ */ jsxs("form", { noValidate: true, autoComplete: "off", onSubmit: formex.handleSubmit, style: t7, children: [
|
1115
|
+
t8,
|
1116
|
+
t78,
|
1117
|
+
t85
|
1118
|
+
] });
|
1119
|
+
$[155] = formex.handleSubmit;
|
1120
|
+
$[156] = t78;
|
1121
|
+
$[157] = t85;
|
1122
|
+
$[158] = t86;
|
1123
|
+
} else {
|
1124
|
+
t86 = $[158];
|
1125
|
+
}
|
1126
|
+
let t87;
|
1127
|
+
if ($[159] !== formex || $[160] !== t86) {
|
1128
|
+
t87 = /* @__PURE__ */ jsx(Formex, { value: formex, children: t86 });
|
1129
|
+
$[159] = formex;
|
1130
|
+
$[160] = t86;
|
1131
|
+
$[161] = t87;
|
1132
|
+
} else {
|
1133
|
+
t87 = $[161];
|
1134
|
+
}
|
1135
|
+
let t88;
|
1136
|
+
if ($[162] !== open || $[163] !== t87) {
|
1137
|
+
t88 = /* @__PURE__ */ jsx(Dialog, { open, maxWidth: "4xl", children: t87 });
|
1138
|
+
$[162] = open;
|
1139
|
+
$[163] = t87;
|
1140
|
+
$[164] = t88;
|
1141
|
+
} else {
|
1142
|
+
t88 = $[164];
|
1143
|
+
}
|
1144
|
+
return t88;
|
908
1145
|
}
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
1146
|
+
function _temp6$1(value_1) {
|
1147
|
+
return value_1 === "own" ? "Own" : value_1 === "true" ? "Yes" : "No";
|
1148
|
+
}
|
1149
|
+
function _temp5$1(value_0) {
|
1150
|
+
return value_0 === "own" ? "Own" : value_0 === "true" ? "Yes" : "No";
|
1151
|
+
}
|
1152
|
+
function _temp4$1(value) {
|
1153
|
+
return value === "true" ? "Yes" : "No";
|
1154
|
+
}
|
1155
|
+
function _temp3$1(values) {
|
1156
|
+
return RoleYupSchema.validate(values, {
|
1157
|
+
abortEarly: false
|
1158
|
+
}).then(_temp$2).catch(_temp2$1);
|
1159
|
+
}
|
1160
|
+
function _temp2$1(e_1) {
|
1161
|
+
const errors = {};
|
1162
|
+
e_1.inner.forEach((error) => {
|
1163
|
+
errors[error.path] = error.message;
|
1164
|
+
});
|
1165
|
+
return errors;
|
1166
|
+
}
|
1167
|
+
function _temp$2() {
|
1168
|
+
return {};
|
1169
|
+
}
|
1170
|
+
const DEFAULT_ROLES = [{
|
1171
|
+
id: "admin",
|
1172
|
+
name: "Admin",
|
1173
|
+
isAdmin: true
|
1174
|
+
}, {
|
1175
|
+
id: "editor",
|
1176
|
+
name: "Editor",
|
1177
|
+
isAdmin: false,
|
1178
|
+
defaultPermissions: {
|
1179
|
+
read: true,
|
1180
|
+
create: true,
|
1181
|
+
edit: true,
|
1182
|
+
delete: true
|
930
1183
|
},
|
931
|
-
{
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
defaultPermissions: {
|
936
|
-
read: true,
|
937
|
-
create: false,
|
938
|
-
edit: false,
|
939
|
-
delete: false
|
940
|
-
}
|
1184
|
+
config: {
|
1185
|
+
createCollections: true,
|
1186
|
+
editCollections: "own",
|
1187
|
+
deleteCollections: "own"
|
941
1188
|
}
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
1189
|
+
}, {
|
1190
|
+
id: "viewer",
|
1191
|
+
name: "Viewer",
|
1192
|
+
isAdmin: false,
|
1193
|
+
defaultPermissions: {
|
1194
|
+
read: true,
|
1195
|
+
create: false,
|
1196
|
+
edit: false,
|
1197
|
+
delete: false
|
1198
|
+
}
|
1199
|
+
}];
|
1200
|
+
function RolesTable(t0) {
|
1201
|
+
const $ = c(25);
|
1202
|
+
const {
|
1203
|
+
onRoleClicked,
|
1204
|
+
editable
|
1205
|
+
} = t0;
|
947
1206
|
const {
|
948
1207
|
roles,
|
949
1208
|
saveRole,
|
@@ -952,166 +1211,224 @@ function RolesTable({
|
|
952
1211
|
} = useUserManagement();
|
953
1212
|
const [roleToBeDeleted, setRoleToBeDeleted] = useState(void 0);
|
954
1213
|
const [deleteInProgress, setDeleteInProgress] = useState(false);
|
955
|
-
|
956
|
-
|
957
|
-
{
|
958
|
-
className: "w-
|
959
|
-
children:
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1214
|
+
let t1;
|
1215
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
1216
|
+
t1 = /* @__PURE__ */ jsxs(TableHeader, { children: [
|
1217
|
+
/* @__PURE__ */ jsx(TableCell, { header: true, className: "w-16" }),
|
1218
|
+
/* @__PURE__ */ jsx(TableCell, { header: true, children: "Role" }),
|
1219
|
+
/* @__PURE__ */ jsx(TableCell, { header: true, className: "items-center", children: "Is Admin" }),
|
1220
|
+
/* @__PURE__ */ jsx(TableCell, { header: true, children: "Default permissions" })
|
1221
|
+
] });
|
1222
|
+
$[0] = t1;
|
1223
|
+
} else {
|
1224
|
+
t1 = $[0];
|
1225
|
+
}
|
1226
|
+
let t2;
|
1227
|
+
if ($[1] !== editable || $[2] !== onRoleClicked || $[3] !== roles) {
|
1228
|
+
t2 = roles && roles.map((role) => {
|
1229
|
+
const canCreateAll = role.isAdmin || role.defaultPermissions?.create;
|
1230
|
+
const canReadAll = role.isAdmin || role.defaultPermissions?.read;
|
1231
|
+
const canUpdateAll = role.isAdmin || role.defaultPermissions?.edit;
|
1232
|
+
const canDeleteAll = role.isAdmin || role.defaultPermissions?.delete;
|
1233
|
+
return /* @__PURE__ */ jsxs(TableRow, { onClick: () => {
|
1234
|
+
onRoleClicked(role);
|
1235
|
+
}, children: [
|
1236
|
+
/* @__PURE__ */ jsx(TableCell, { style: {
|
1237
|
+
width: "64px"
|
1238
|
+
}, children: !role.isAdmin && /* @__PURE__ */ jsx(Tooltip, { asChild: true, title: "Delete this role", children: /* @__PURE__ */ jsx(IconButton, { size: "small", disabled: !editable, onClick: (event) => {
|
1239
|
+
event.stopPropagation();
|
1240
|
+
return setRoleToBeDeleted(role);
|
1241
|
+
}, children: /* @__PURE__ */ jsx(DeleteIcon, {}) }) }) }),
|
1242
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(RoleChip, { role }) }),
|
1243
|
+
/* @__PURE__ */ jsx(TableCell, { className: "items-center", children: /* @__PURE__ */ jsx(Checkbox, { checked: role.isAdmin ?? false }) }),
|
1244
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs("ul", { children: [
|
1245
|
+
canCreateAll && /* @__PURE__ */ jsx("li", { children: "Create" }),
|
1246
|
+
canReadAll && /* @__PURE__ */ jsx("li", { children: "Read" }),
|
1247
|
+
canUpdateAll && /* @__PURE__ */ jsx("li", { children: "Update" }),
|
1248
|
+
canDeleteAll && /* @__PURE__ */ jsx("li", { children: "Delete" })
|
1249
|
+
] }) })
|
1250
|
+
] }, role.name);
|
1251
|
+
});
|
1252
|
+
$[1] = editable;
|
1253
|
+
$[2] = onRoleClicked;
|
1254
|
+
$[3] = roles;
|
1255
|
+
$[4] = t2;
|
1256
|
+
} else {
|
1257
|
+
t2 = $[4];
|
1258
|
+
}
|
1259
|
+
let t3;
|
1260
|
+
if ($[5] !== allowDefaultRolesCreation || $[6] !== roles || $[7] !== saveRole) {
|
1261
|
+
t3 = (!roles || roles.length === 0) && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colspan: 4, children: /* @__PURE__ */ jsxs(CenteredView, { className: "flex flex-col gap-4 my-8 items-center", children: [
|
1262
|
+
/* @__PURE__ */ jsx(Typography, { variant: "label", children: "You don't have any roles yet." }),
|
1263
|
+
allowDefaultRolesCreation && /* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: () => {
|
1264
|
+
DEFAULT_ROLES.forEach((role_0) => {
|
1265
|
+
saveRole(role_0);
|
1266
|
+
});
|
1267
|
+
}, children: "Create default roles" })
|
1268
|
+
] }) }) });
|
1269
|
+
$[5] = allowDefaultRolesCreation;
|
1270
|
+
$[6] = roles;
|
1271
|
+
$[7] = saveRole;
|
1272
|
+
$[8] = t3;
|
1273
|
+
} else {
|
1274
|
+
t3 = $[8];
|
1275
|
+
}
|
1276
|
+
let t4;
|
1277
|
+
if ($[9] !== t2 || $[10] !== t3) {
|
1278
|
+
t4 = /* @__PURE__ */ jsxs(Table, { className: "w-full", children: [
|
1279
|
+
t1,
|
1280
|
+
/* @__PURE__ */ jsxs(TableBody, { children: [
|
1281
|
+
t2,
|
1282
|
+
t3
|
1283
|
+
] })
|
1284
|
+
] });
|
1285
|
+
$[9] = t2;
|
1286
|
+
$[10] = t3;
|
1287
|
+
$[11] = t4;
|
1288
|
+
} else {
|
1289
|
+
t4 = $[11];
|
1290
|
+
}
|
1291
|
+
const t5 = Boolean(roleToBeDeleted);
|
1292
|
+
let t6;
|
1293
|
+
if ($[12] !== deleteRole || $[13] !== roleToBeDeleted) {
|
1294
|
+
t6 = () => {
|
1295
|
+
if (roleToBeDeleted) {
|
1296
|
+
setDeleteInProgress(true);
|
1297
|
+
deleteRole(roleToBeDeleted).then(() => {
|
1298
|
+
setRoleToBeDeleted(void 0);
|
1299
|
+
}).finally(() => {
|
1300
|
+
setDeleteInProgress(false);
|
1301
|
+
});
|
1302
|
+
}
|
1303
|
+
};
|
1304
|
+
$[12] = deleteRole;
|
1305
|
+
$[13] = roleToBeDeleted;
|
1306
|
+
$[14] = t6;
|
1307
|
+
} else {
|
1308
|
+
t6 = $[14];
|
1309
|
+
}
|
1310
|
+
let t7;
|
1311
|
+
let t8;
|
1312
|
+
let t9;
|
1313
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
1314
|
+
t7 = () => {
|
1315
|
+
setRoleToBeDeleted(void 0);
|
1316
|
+
};
|
1317
|
+
t8 = /* @__PURE__ */ jsx(Fragment, { children: "Delete?" });
|
1318
|
+
t9 = /* @__PURE__ */ jsx(Fragment, { children: "Are you sure you want to delete this role?" });
|
1319
|
+
$[15] = t7;
|
1320
|
+
$[16] = t8;
|
1321
|
+
$[17] = t9;
|
1322
|
+
} else {
|
1323
|
+
t7 = $[15];
|
1324
|
+
t8 = $[16];
|
1325
|
+
t9 = $[17];
|
1326
|
+
}
|
1327
|
+
let t10;
|
1328
|
+
if ($[18] !== deleteInProgress || $[19] !== t5 || $[20] !== t6) {
|
1329
|
+
t10 = /* @__PURE__ */ jsx(ConfirmationDialog, { open: t5, loading: deleteInProgress, onAccept: t6, onCancel: t7, title: t8, body: t9 });
|
1330
|
+
$[18] = deleteInProgress;
|
1331
|
+
$[19] = t5;
|
1332
|
+
$[20] = t6;
|
1333
|
+
$[21] = t10;
|
1334
|
+
} else {
|
1335
|
+
t10 = $[21];
|
1336
|
+
}
|
1337
|
+
let t11;
|
1338
|
+
if ($[22] !== t10 || $[23] !== t4) {
|
1339
|
+
t11 = /* @__PURE__ */ jsxs("div", { className: "w-full overflow-auto", children: [
|
1340
|
+
t4,
|
1341
|
+
t10
|
1342
|
+
] });
|
1343
|
+
$[22] = t10;
|
1344
|
+
$[23] = t4;
|
1345
|
+
$[24] = t11;
|
1346
|
+
} else {
|
1347
|
+
t11 = $[24];
|
1348
|
+
}
|
1349
|
+
return t11;
|
1054
1350
|
}
|
1055
|
-
const RolesView = React.memo(
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1351
|
+
const RolesView = React.memo(function RolesView2(t0) {
|
1352
|
+
const $ = c(13);
|
1353
|
+
const {
|
1354
|
+
children
|
1355
|
+
} = t0;
|
1356
|
+
const {
|
1357
|
+
collections
|
1358
|
+
} = useNavigationController();
|
1359
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
1360
|
+
const [selectedRole, setSelectedRole] = useState();
|
1361
|
+
let t1;
|
1362
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
1363
|
+
t1 = (user) => {
|
1062
1364
|
setDialogOpen(true);
|
1063
1365
|
setSelectedRole(user);
|
1064
|
-
}
|
1065
|
-
|
1366
|
+
};
|
1367
|
+
$[0] = t1;
|
1368
|
+
} else {
|
1369
|
+
t1 = $[0];
|
1370
|
+
}
|
1371
|
+
const onRoleClicked = t1;
|
1372
|
+
let t2;
|
1373
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
1374
|
+
t2 = () => {
|
1066
1375
|
setSelectedRole(void 0);
|
1067
1376
|
setDialogOpen(false);
|
1068
1377
|
};
|
1069
|
-
|
1378
|
+
$[1] = t2;
|
1379
|
+
} else {
|
1380
|
+
t2 = $[1];
|
1381
|
+
}
|
1382
|
+
const handleClose = t2;
|
1383
|
+
let t3;
|
1384
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
1385
|
+
t3 = /* @__PURE__ */ jsx(Typography, { gutterBottom: true, variant: "h4", className: "flex-grow", component: "h4", children: "Roles" });
|
1386
|
+
$[2] = t3;
|
1387
|
+
} else {
|
1388
|
+
t3 = $[2];
|
1389
|
+
}
|
1390
|
+
let t4;
|
1391
|
+
let t5;
|
1392
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
1393
|
+
t4 = /* @__PURE__ */ jsxs("div", { className: "flex items-center mt-12", children: [
|
1394
|
+
t3,
|
1395
|
+
/* @__PURE__ */ jsx(Button, { size: "large", startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: () => setDialogOpen(true), children: "Add role" })
|
1396
|
+
] });
|
1397
|
+
t5 = /* @__PURE__ */ jsx(RolesTable, { onRoleClicked, editable: true });
|
1398
|
+
$[3] = t4;
|
1399
|
+
$[4] = t5;
|
1400
|
+
} else {
|
1401
|
+
t4 = $[3];
|
1402
|
+
t5 = $[4];
|
1403
|
+
}
|
1404
|
+
const t6 = selectedRole?.id ?? "new";
|
1405
|
+
let t7;
|
1406
|
+
if ($[5] !== collections || $[6] !== dialogOpen || $[7] !== selectedRole || $[8] !== t6) {
|
1407
|
+
t7 = /* @__PURE__ */ jsx(RolesDetailsForm, { open: dialogOpen, role: selectedRole, editable: true, collections, handleClose }, t6);
|
1408
|
+
$[5] = collections;
|
1409
|
+
$[6] = dialogOpen;
|
1410
|
+
$[7] = selectedRole;
|
1411
|
+
$[8] = t6;
|
1412
|
+
$[9] = t7;
|
1413
|
+
} else {
|
1414
|
+
t7 = $[9];
|
1415
|
+
}
|
1416
|
+
let t8;
|
1417
|
+
if ($[10] !== children || $[11] !== t7) {
|
1418
|
+
t8 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
|
1070
1419
|
children,
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
{
|
1075
|
-
gutterBottom: true,
|
1076
|
-
variant: "h4",
|
1077
|
-
className: "flex-grow",
|
1078
|
-
component: "h4",
|
1079
|
-
children: "Roles"
|
1080
|
-
}
|
1081
|
-
),
|
1082
|
-
/* @__PURE__ */ jsx(
|
1083
|
-
Tooltip,
|
1084
|
-
{
|
1085
|
-
asChild: true,
|
1086
|
-
title: !canEditRoles ? "Update plans to customise roles" : void 0,
|
1087
|
-
children: /* @__PURE__ */ jsx(
|
1088
|
-
Button,
|
1089
|
-
{
|
1090
|
-
size: "large",
|
1091
|
-
disabled: !canEditRoles,
|
1092
|
-
startIcon: /* @__PURE__ */ jsx(AddIcon, {}),
|
1093
|
-
onClick: () => setDialogOpen(true),
|
1094
|
-
children: "Add role"
|
1095
|
-
}
|
1096
|
-
)
|
1097
|
-
}
|
1098
|
-
)
|
1099
|
-
] }),
|
1100
|
-
/* @__PURE__ */ jsx(RolesTable, { onRoleClicked, editable: Boolean(canEditRoles) }),
|
1101
|
-
/* @__PURE__ */ jsx(
|
1102
|
-
RolesDetailsForm,
|
1103
|
-
{
|
1104
|
-
open: dialogOpen,
|
1105
|
-
role: selectedRole,
|
1106
|
-
editable: canEditRoles,
|
1107
|
-
collections,
|
1108
|
-
handleClose
|
1109
|
-
},
|
1110
|
-
selectedRole?.id ?? "new"
|
1111
|
-
)
|
1420
|
+
t4,
|
1421
|
+
t5,
|
1422
|
+
t7
|
1112
1423
|
] });
|
1424
|
+
$[10] = children;
|
1425
|
+
$[11] = t7;
|
1426
|
+
$[12] = t8;
|
1427
|
+
} else {
|
1428
|
+
t8 = $[12];
|
1113
1429
|
}
|
1114
|
-
|
1430
|
+
return t8;
|
1431
|
+
});
|
1115
1432
|
const UserYupSchema = Yup.object().shape({
|
1116
1433
|
displayName: Yup.string().required("Required"),
|
1117
1434
|
email: Yup.string().email().required("Required"),
|
@@ -1130,11 +1447,13 @@ function canUserBeEdited(loggedUser, user, users, roles, prevUser) {
|
|
1130
1447
|
}
|
1131
1448
|
return true;
|
1132
1449
|
}
|
1133
|
-
function UserDetailsForm({
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1450
|
+
function UserDetailsForm(t0) {
|
1451
|
+
const $ = c(74);
|
1452
|
+
const {
|
1453
|
+
open,
|
1454
|
+
user: userProp,
|
1455
|
+
handleClose
|
1456
|
+
} = t0;
|
1138
1457
|
const snackbarController = useSnackbarController();
|
1139
1458
|
const {
|
1140
1459
|
user: loggedInUser
|
@@ -1145,173 +1464,331 @@ function UserDetailsForm({
|
|
1145
1464
|
roles
|
1146
1465
|
} = useUserManagement();
|
1147
1466
|
const isNewUser = !userProp;
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1467
|
+
let t1;
|
1468
|
+
if ($[0] !== loggedInUser || $[1] !== roles || $[2] !== saveUser || $[3] !== userProp || $[4] !== users) {
|
1469
|
+
t1 = (savedUser) => {
|
1470
|
+
if (!loggedInUser) {
|
1471
|
+
throw new Error("Logged user not found");
|
1472
|
+
}
|
1473
|
+
try {
|
1474
|
+
canUserBeEdited(loggedInUser, savedUser, users, roles, userProp);
|
1475
|
+
return saveUser(savedUser);
|
1476
|
+
} catch (t210) {
|
1477
|
+
const e = t210;
|
1478
|
+
return Promise.reject(e);
|
1479
|
+
}
|
1480
|
+
};
|
1481
|
+
$[0] = loggedInUser;
|
1482
|
+
$[1] = roles;
|
1483
|
+
$[2] = saveUser;
|
1484
|
+
$[3] = userProp;
|
1485
|
+
$[4] = users;
|
1486
|
+
$[5] = t1;
|
1487
|
+
} else {
|
1488
|
+
t1 = $[5];
|
1489
|
+
}
|
1490
|
+
const onUserUpdated = t1;
|
1491
|
+
let t2;
|
1492
|
+
if ($[6] !== roles || $[7] !== userProp) {
|
1493
|
+
t2 = userProp ?? {
|
1161
1494
|
displayName: "",
|
1162
1495
|
email: "",
|
1163
|
-
roles: roles.filter(
|
1164
|
-
}
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1496
|
+
roles: roles.filter(_temp$1)
|
1497
|
+
};
|
1498
|
+
$[6] = roles;
|
1499
|
+
$[7] = userProp;
|
1500
|
+
$[8] = t2;
|
1501
|
+
} else {
|
1502
|
+
t2 = $[8];
|
1503
|
+
}
|
1504
|
+
let t3;
|
1505
|
+
if ($[9] !== handleClose || $[10] !== onUserUpdated || $[11] !== snackbarController) {
|
1506
|
+
t3 = (user, formexController) => onUserUpdated(user).then(() => {
|
1507
|
+
handleClose();
|
1508
|
+
formexController.resetForm({
|
1509
|
+
values: user
|
1173
1510
|
});
|
1174
|
-
}
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
formexController.resetForm({
|
1179
|
-
values: user
|
1180
|
-
});
|
1181
|
-
}).catch((e) => {
|
1182
|
-
snackbarController.open({
|
1183
|
-
type: "error",
|
1184
|
-
message: e.message
|
1185
|
-
});
|
1511
|
+
}).catch((e_1) => {
|
1512
|
+
snackbarController.open({
|
1513
|
+
type: "error",
|
1514
|
+
message: e_1.message
|
1186
1515
|
});
|
1187
|
-
}
|
1188
|
-
|
1516
|
+
});
|
1517
|
+
$[9] = handleClose;
|
1518
|
+
$[10] = onUserUpdated;
|
1519
|
+
$[11] = snackbarController;
|
1520
|
+
$[12] = t3;
|
1521
|
+
} else {
|
1522
|
+
t3 = $[12];
|
1523
|
+
}
|
1524
|
+
let t4;
|
1525
|
+
if ($[13] !== t2 || $[14] !== t3) {
|
1526
|
+
t4 = {
|
1527
|
+
initialValues: t2,
|
1528
|
+
validation: _temp5,
|
1529
|
+
onSubmit: t3
|
1530
|
+
};
|
1531
|
+
$[13] = t2;
|
1532
|
+
$[14] = t3;
|
1533
|
+
$[15] = t4;
|
1534
|
+
} else {
|
1535
|
+
t4 = $[15];
|
1536
|
+
}
|
1537
|
+
const formex = useCreateFormex(t4);
|
1189
1538
|
const {
|
1190
1539
|
isSubmitting,
|
1191
|
-
touched,
|
1192
1540
|
handleChange,
|
1193
|
-
values,
|
1541
|
+
values: values_0,
|
1194
1542
|
errors,
|
1195
1543
|
setFieldValue,
|
1196
1544
|
dirty,
|
1197
1545
|
handleSubmit,
|
1198
1546
|
submitCount
|
1199
1547
|
} = formex;
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1548
|
+
let t5;
|
1549
|
+
if ($[16] !== handleClose) {
|
1550
|
+
t5 = (open_0) => !open_0 ? handleClose() : void 0;
|
1551
|
+
$[16] = handleClose;
|
1552
|
+
$[17] = t5;
|
1553
|
+
} else {
|
1554
|
+
t5 = $[17];
|
1555
|
+
}
|
1556
|
+
let t6;
|
1557
|
+
let t7;
|
1558
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
1559
|
+
t6 = {
|
1560
|
+
display: "flex",
|
1561
|
+
flexDirection: "column",
|
1562
|
+
position: "relative",
|
1563
|
+
height: "100%"
|
1564
|
+
};
|
1565
|
+
t7 = /* @__PURE__ */ jsx(DialogTitle, { variant: "h4", gutterBottom: false, children: "User" });
|
1566
|
+
$[18] = t6;
|
1567
|
+
$[19] = t7;
|
1568
|
+
} else {
|
1569
|
+
t6 = $[18];
|
1570
|
+
t7 = $[19];
|
1571
|
+
}
|
1572
|
+
const t8 = submitCount > 0 && Boolean(errors.displayName);
|
1573
|
+
const t9 = values_0.displayName ?? "";
|
1574
|
+
let t10;
|
1575
|
+
if ($[20] !== handleChange || $[21] !== t8 || $[22] !== t9) {
|
1576
|
+
t10 = /* @__PURE__ */ jsx(TextField, { name: "displayName", required: true, error: t8, value: t9, onChange: handleChange, "aria-describedby": "name-helper-text", label: "Name" });
|
1577
|
+
$[20] = handleChange;
|
1578
|
+
$[21] = t8;
|
1579
|
+
$[22] = t9;
|
1580
|
+
$[23] = t10;
|
1581
|
+
} else {
|
1582
|
+
t10 = $[23];
|
1583
|
+
}
|
1584
|
+
const t11 = submitCount > 0 && Boolean(errors.displayName) ? errors.displayName : "Name of this user";
|
1585
|
+
let t12;
|
1586
|
+
if ($[24] !== t11) {
|
1587
|
+
t12 = /* @__PURE__ */ jsx(FieldCaption, { children: t11 });
|
1588
|
+
$[24] = t11;
|
1589
|
+
$[25] = t12;
|
1590
|
+
} else {
|
1591
|
+
t12 = $[25];
|
1592
|
+
}
|
1593
|
+
let t13;
|
1594
|
+
if ($[26] !== t10 || $[27] !== t12) {
|
1595
|
+
t13 = /* @__PURE__ */ jsxs("div", { className: "col-span-12", children: [
|
1596
|
+
t10,
|
1597
|
+
t12
|
1598
|
+
] });
|
1599
|
+
$[26] = t10;
|
1600
|
+
$[27] = t12;
|
1601
|
+
$[28] = t13;
|
1602
|
+
} else {
|
1603
|
+
t13 = $[28];
|
1604
|
+
}
|
1605
|
+
const t14 = submitCount > 0 && Boolean(errors.email);
|
1606
|
+
const t15 = values_0.email ?? "";
|
1607
|
+
let t16;
|
1608
|
+
if ($[29] !== handleChange || $[30] !== t14 || $[31] !== t15) {
|
1609
|
+
t16 = /* @__PURE__ */ jsx(TextField, { required: true, error: t14, name: "email", value: t15, onChange: handleChange, "aria-describedby": "email-helper-text", label: "Email" });
|
1610
|
+
$[29] = handleChange;
|
1611
|
+
$[30] = t14;
|
1612
|
+
$[31] = t15;
|
1613
|
+
$[32] = t16;
|
1614
|
+
} else {
|
1615
|
+
t16 = $[32];
|
1616
|
+
}
|
1617
|
+
const t17 = submitCount > 0 && Boolean(errors.email) ? errors.email : "Email of this user";
|
1618
|
+
let t18;
|
1619
|
+
if ($[33] !== t17) {
|
1620
|
+
t18 = /* @__PURE__ */ jsx(FieldCaption, { children: t17 });
|
1621
|
+
$[33] = t17;
|
1622
|
+
$[34] = t18;
|
1623
|
+
} else {
|
1624
|
+
t18 = $[34];
|
1625
|
+
}
|
1626
|
+
let t19;
|
1627
|
+
if ($[35] !== t16 || $[36] !== t18) {
|
1628
|
+
t19 = /* @__PURE__ */ jsxs("div", { className: "col-span-12", children: [
|
1629
|
+
t16,
|
1630
|
+
t18
|
1631
|
+
] });
|
1632
|
+
$[35] = t16;
|
1633
|
+
$[36] = t18;
|
1634
|
+
$[37] = t19;
|
1635
|
+
} else {
|
1636
|
+
t19 = $[37];
|
1637
|
+
}
|
1638
|
+
let t20;
|
1639
|
+
if ($[38] !== values_0.roles) {
|
1640
|
+
t20 = values_0.roles?.map(_temp6) ?? [];
|
1641
|
+
$[38] = values_0.roles;
|
1642
|
+
$[39] = t20;
|
1643
|
+
} else {
|
1644
|
+
t20 = $[39];
|
1645
|
+
}
|
1646
|
+
let t21;
|
1647
|
+
if ($[40] !== roles || $[41] !== setFieldValue) {
|
1648
|
+
t21 = (value) => setFieldValue("roles", value.map((id) => roles.find((r_1) => r_1.id === id)));
|
1649
|
+
$[40] = roles;
|
1650
|
+
$[41] = setFieldValue;
|
1651
|
+
$[42] = t21;
|
1652
|
+
} else {
|
1653
|
+
t21 = $[42];
|
1654
|
+
}
|
1655
|
+
let t22;
|
1656
|
+
if ($[43] !== roles) {
|
1657
|
+
t22 = roles.map(_temp7);
|
1658
|
+
$[43] = roles;
|
1659
|
+
$[44] = t22;
|
1660
|
+
} else {
|
1661
|
+
t22 = $[44];
|
1662
|
+
}
|
1663
|
+
let t23;
|
1664
|
+
if ($[45] !== t20 || $[46] !== t21 || $[47] !== t22) {
|
1665
|
+
t23 = /* @__PURE__ */ jsx("div", { className: "col-span-12", children: /* @__PURE__ */ jsx(MultiSelect, { className: "w-full", label: "Roles", value: t20, onValueChange: t21, children: t22 }) });
|
1666
|
+
$[45] = t20;
|
1667
|
+
$[46] = t21;
|
1668
|
+
$[47] = t22;
|
1669
|
+
$[48] = t23;
|
1670
|
+
} else {
|
1671
|
+
t23 = $[48];
|
1672
|
+
}
|
1673
|
+
let t24;
|
1674
|
+
if ($[49] !== t13 || $[50] !== t19 || $[51] !== t23) {
|
1675
|
+
t24 = /* @__PURE__ */ jsx(DialogContent, { className: "h-full flex-grow", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 gap-8", children: [
|
1676
|
+
t13,
|
1677
|
+
t19,
|
1678
|
+
t23
|
1679
|
+
] }) });
|
1680
|
+
$[49] = t13;
|
1681
|
+
$[50] = t19;
|
1682
|
+
$[51] = t23;
|
1683
|
+
$[52] = t24;
|
1684
|
+
} else {
|
1685
|
+
t24 = $[52];
|
1686
|
+
}
|
1687
|
+
let t25;
|
1688
|
+
if ($[53] !== handleClose) {
|
1689
|
+
t25 = /* @__PURE__ */ jsx(Button, { variant: "text", onClick: () => {
|
1690
|
+
handleClose();
|
1691
|
+
}, children: "Cancel" });
|
1692
|
+
$[53] = handleClose;
|
1693
|
+
$[54] = t25;
|
1694
|
+
} else {
|
1695
|
+
t25 = $[54];
|
1696
|
+
}
|
1697
|
+
const t26 = !dirty;
|
1698
|
+
let t27;
|
1699
|
+
if ($[55] === Symbol.for("react.memo_cache_sentinel")) {
|
1700
|
+
t27 = /* @__PURE__ */ jsx(CheckIcon, {});
|
1701
|
+
$[55] = t27;
|
1702
|
+
} else {
|
1703
|
+
t27 = $[55];
|
1704
|
+
}
|
1705
|
+
const t28 = isNewUser ? "Create user" : "Update";
|
1706
|
+
let t29;
|
1707
|
+
if ($[56] !== isSubmitting || $[57] !== t26 || $[58] !== t28) {
|
1708
|
+
t29 = /* @__PURE__ */ jsx(LoadingButton, { variant: "filled", color: "primary", type: "submit", disabled: t26, loading: isSubmitting, startIcon: t27, children: t28 });
|
1709
|
+
$[56] = isSubmitting;
|
1710
|
+
$[57] = t26;
|
1711
|
+
$[58] = t28;
|
1712
|
+
$[59] = t29;
|
1713
|
+
} else {
|
1714
|
+
t29 = $[59];
|
1715
|
+
}
|
1716
|
+
let t30;
|
1717
|
+
if ($[60] !== t25 || $[61] !== t29) {
|
1718
|
+
t30 = /* @__PURE__ */ jsxs(DialogActions, { children: [
|
1719
|
+
t25,
|
1720
|
+
t29
|
1721
|
+
] });
|
1722
|
+
$[60] = t25;
|
1723
|
+
$[61] = t29;
|
1724
|
+
$[62] = t30;
|
1725
|
+
} else {
|
1726
|
+
t30 = $[62];
|
1727
|
+
}
|
1728
|
+
let t31;
|
1729
|
+
if ($[63] !== handleSubmit || $[64] !== t24 || $[65] !== t30) {
|
1730
|
+
t31 = /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, autoComplete: "off", noValidate: true, style: t6, children: [
|
1731
|
+
t7,
|
1732
|
+
t24,
|
1733
|
+
t30
|
1734
|
+
] });
|
1735
|
+
$[63] = handleSubmit;
|
1736
|
+
$[64] = t24;
|
1737
|
+
$[65] = t30;
|
1738
|
+
$[66] = t31;
|
1739
|
+
} else {
|
1740
|
+
t31 = $[66];
|
1741
|
+
}
|
1742
|
+
let t32;
|
1743
|
+
if ($[67] !== formex || $[68] !== t31) {
|
1744
|
+
t32 = /* @__PURE__ */ jsx(Formex, { value: formex, children: t31 });
|
1745
|
+
$[67] = formex;
|
1746
|
+
$[68] = t31;
|
1747
|
+
$[69] = t32;
|
1748
|
+
} else {
|
1749
|
+
t32 = $[69];
|
1750
|
+
}
|
1751
|
+
let t33;
|
1752
|
+
if ($[70] !== open || $[71] !== t32 || $[72] !== t5) {
|
1753
|
+
t33 = /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: t5, maxWidth: "4xl", children: t32 });
|
1754
|
+
$[70] = open;
|
1755
|
+
$[71] = t32;
|
1756
|
+
$[72] = t5;
|
1757
|
+
$[73] = t33;
|
1758
|
+
} else {
|
1759
|
+
t33 = $[73];
|
1760
|
+
}
|
1761
|
+
return t33;
|
1762
|
+
}
|
1763
|
+
function _temp7(userRole) {
|
1764
|
+
return /* @__PURE__ */ jsx(MultiSelectItem, { value: userRole.id, children: /* @__PURE__ */ jsx(RoleChip, { role: userRole }, userRole?.id) }, userRole.id);
|
1765
|
+
}
|
1766
|
+
function _temp6(r_0) {
|
1767
|
+
return r_0.id;
|
1768
|
+
}
|
1769
|
+
function _temp5(values) {
|
1770
|
+
return UserYupSchema.validate(values, {
|
1771
|
+
abortEarly: false
|
1772
|
+
}).then(_temp2).catch(_temp4);
|
1773
|
+
}
|
1774
|
+
function _temp4(e_0) {
|
1775
|
+
return e_0.inner.reduce(_temp3, {});
|
1776
|
+
}
|
1777
|
+
function _temp3(acc, error) {
|
1778
|
+
acc[error.path] = error.message;
|
1779
|
+
return acc;
|
1780
|
+
}
|
1781
|
+
function _temp2() {
|
1782
|
+
return {};
|
1313
1783
|
}
|
1314
|
-
function
|
1784
|
+
function _temp$1(r) {
|
1785
|
+
return r.id === "editor";
|
1786
|
+
}
|
1787
|
+
function UsersTable(t0) {
|
1788
|
+
const $ = c(28);
|
1789
|
+
const {
|
1790
|
+
onUserClicked
|
1791
|
+
} = t0;
|
1315
1792
|
const {
|
1316
1793
|
users,
|
1317
1794
|
saveUser,
|
@@ -1324,275 +1801,418 @@ function UsersTable({ onUserClicked }) {
|
|
1324
1801
|
const dateFormat = customizationController?.dateTimeFormat ?? defaultDateFormat;
|
1325
1802
|
const [userToBeDeleted, setUserToBeDeleted] = useState(void 0);
|
1326
1803
|
const [deleteInProgress, setDeleteInProgress] = useState(false);
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1804
|
+
let t1;
|
1805
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
1806
|
+
t1 = /* @__PURE__ */ jsxs(TableHeader, { children: [
|
1807
|
+
/* @__PURE__ */ jsx(TableCell, { className: "truncate w-16" }),
|
1808
|
+
/* @__PURE__ */ jsx(TableCell, { children: "Email" }),
|
1809
|
+
/* @__PURE__ */ jsx(TableCell, { children: "Name" }),
|
1810
|
+
/* @__PURE__ */ jsx(TableCell, { children: "Roles" }),
|
1811
|
+
/* @__PURE__ */ jsx(TableCell, { children: "Created on" })
|
1812
|
+
] });
|
1813
|
+
$[0] = t1;
|
1814
|
+
} else {
|
1815
|
+
t1 = $[0];
|
1816
|
+
}
|
1817
|
+
let t2;
|
1818
|
+
if ($[1] !== dateFormat || $[2] !== dateUtilsLocale || $[3] !== onUserClicked || $[4] !== users) {
|
1819
|
+
t2 = users && users.map((user) => {
|
1820
|
+
const userRoles = user.roles;
|
1821
|
+
const formattedDate = user.created_on ? format(user.created_on, dateFormat, {
|
1822
|
+
locale: dateUtilsLocale
|
1823
|
+
}) : "";
|
1824
|
+
return /* @__PURE__ */ jsxs(TableRow, { onClick: () => {
|
1825
|
+
onUserClicked(user);
|
1826
|
+
}, children: [
|
1827
|
+
/* @__PURE__ */ jsx(TableCell, { className: "w-10", children: /* @__PURE__ */ jsx(Tooltip, { asChild: true, title: "Delete this user", children: /* @__PURE__ */ jsx(IconButton, { size: "small", onClick: (event) => {
|
1828
|
+
event.stopPropagation();
|
1829
|
+
return setUserToBeDeleted(user);
|
1830
|
+
}, children: /* @__PURE__ */ jsx(DeleteIcon, {}) }) }) }),
|
1831
|
+
/* @__PURE__ */ jsx(TableCell, { children: user.email }),
|
1832
|
+
/* @__PURE__ */ jsx(TableCell, { className: "font-medium align-left", children: user.displayName }),
|
1833
|
+
/* @__PURE__ */ jsx(TableCell, { className: "align-left", children: userRoles ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: userRoles.map(_temp) }) : null }),
|
1834
|
+
/* @__PURE__ */ jsx(TableCell, { children: formattedDate })
|
1835
|
+
] }, "row_" + user.uid);
|
1836
|
+
});
|
1837
|
+
$[1] = dateFormat;
|
1838
|
+
$[2] = dateUtilsLocale;
|
1839
|
+
$[3] = onUserClicked;
|
1840
|
+
$[4] = users;
|
1841
|
+
$[5] = t2;
|
1842
|
+
} else {
|
1843
|
+
t2 = $[5];
|
1844
|
+
}
|
1845
|
+
let t3;
|
1846
|
+
if ($[6] !== authController || $[7] !== saveUser || $[8] !== snackbarController || $[9] !== users) {
|
1847
|
+
t3 = (!users || users.length === 0) && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colspan: 6, children: /* @__PURE__ */ jsxs(CenteredView, { className: "flex flex-col gap-4 my-8 items-center", children: [
|
1848
|
+
/* @__PURE__ */ jsx(Typography, { variant: "label", children: "There are no users yet" }),
|
1849
|
+
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: () => {
|
1850
|
+
if (!authController.user?.uid) {
|
1851
|
+
throw Error("UsersTable, authController misconfiguration");
|
1852
|
+
}
|
1853
|
+
saveUser({
|
1854
|
+
uid: authController.user?.uid,
|
1855
|
+
email: authController.user?.email,
|
1856
|
+
displayName: authController.user?.displayName,
|
1857
|
+
photoURL: authController.user?.photoURL,
|
1858
|
+
providerId: authController.user?.providerId,
|
1859
|
+
isAnonymous: authController.user?.isAnonymous,
|
1860
|
+
roles: [{
|
1861
|
+
id: "admin",
|
1862
|
+
name: "Admin"
|
1863
|
+
}],
|
1864
|
+
created_on: /* @__PURE__ */ new Date()
|
1865
|
+
}).then(() => {
|
1866
|
+
snackbarController.open({
|
1867
|
+
type: "success",
|
1868
|
+
message: "User added successfully"
|
1869
|
+
});
|
1870
|
+
}).catch((error) => {
|
1871
|
+
snackbarController.open({
|
1872
|
+
type: "error",
|
1873
|
+
message: "Error adding user: " + error.message
|
1874
|
+
});
|
1875
|
+
});
|
1876
|
+
}, children: "Add the logged user as an admin" })
|
1877
|
+
] }) }) });
|
1878
|
+
$[6] = authController;
|
1879
|
+
$[7] = saveUser;
|
1880
|
+
$[8] = snackbarController;
|
1881
|
+
$[9] = users;
|
1882
|
+
$[10] = t3;
|
1883
|
+
} else {
|
1884
|
+
t3 = $[10];
|
1885
|
+
}
|
1886
|
+
let t4;
|
1887
|
+
if ($[11] !== t2 || $[12] !== t3) {
|
1888
|
+
t4 = /* @__PURE__ */ jsxs(Table, { className: "w-full", children: [
|
1889
|
+
t1,
|
1337
1890
|
/* @__PURE__ */ jsxs(TableBody, { children: [
|
1338
|
-
|
1339
|
-
|
1340
|
-
const formattedDate = user.created_on ? format(user.created_on, dateFormat, { locale: dateUtilsLocale }) : "";
|
1341
|
-
return /* @__PURE__ */ jsxs(
|
1342
|
-
TableRow,
|
1343
|
-
{
|
1344
|
-
onClick: () => {
|
1345
|
-
onUserClicked(user);
|
1346
|
-
},
|
1347
|
-
children: [
|
1348
|
-
/* @__PURE__ */ jsx(TableCell, { className: "w-10", children: /* @__PURE__ */ jsx(
|
1349
|
-
Tooltip,
|
1350
|
-
{
|
1351
|
-
asChild: true,
|
1352
|
-
title: "Delete this user",
|
1353
|
-
children: /* @__PURE__ */ jsx(
|
1354
|
-
IconButton,
|
1355
|
-
{
|
1356
|
-
size: "small",
|
1357
|
-
onClick: (event) => {
|
1358
|
-
event.stopPropagation();
|
1359
|
-
return setUserToBeDeleted(user);
|
1360
|
-
},
|
1361
|
-
children: /* @__PURE__ */ jsx(DeleteIcon, {})
|
1362
|
-
}
|
1363
|
-
)
|
1364
|
-
}
|
1365
|
-
) }),
|
1366
|
-
/* @__PURE__ */ jsx(TableCell, { children: user.uid }),
|
1367
|
-
/* @__PURE__ */ jsx(TableCell, { children: user.email }),
|
1368
|
-
/* @__PURE__ */ jsx(TableCell, { className: "font-medium align-left", children: user.displayName }),
|
1369
|
-
/* @__PURE__ */ jsx(TableCell, { className: "align-left", children: userRoles ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: userRoles.map(
|
1370
|
-
(userRole) => /* @__PURE__ */ jsx(RoleChip, { role: userRole }, userRole?.id)
|
1371
|
-
) }) : null }),
|
1372
|
-
/* @__PURE__ */ jsx(TableCell, { children: formattedDate })
|
1373
|
-
]
|
1374
|
-
},
|
1375
|
-
"row_" + user.uid
|
1376
|
-
);
|
1377
|
-
}),
|
1378
|
-
(!users || users.length === 0) && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colspan: 6, children: /* @__PURE__ */ jsxs(CenteredView, { className: "flex flex-col gap-4 my-8 items-center", children: [
|
1379
|
-
/* @__PURE__ */ jsx(Typography, { variant: "label", children: "There are no users yet" }),
|
1380
|
-
/* @__PURE__ */ jsx(
|
1381
|
-
Button,
|
1382
|
-
{
|
1383
|
-
variant: "outlined",
|
1384
|
-
onClick: () => {
|
1385
|
-
if (!authController.user?.uid) {
|
1386
|
-
throw Error("UsersTable, authController misconfiguration");
|
1387
|
-
}
|
1388
|
-
saveUser({
|
1389
|
-
uid: authController.user?.uid,
|
1390
|
-
email: authController.user?.email,
|
1391
|
-
displayName: authController.user?.displayName,
|
1392
|
-
photoURL: authController.user?.photoURL,
|
1393
|
-
providerId: authController.user?.providerId,
|
1394
|
-
isAnonymous: authController.user?.isAnonymous,
|
1395
|
-
roles: [{ id: "admin", name: "Admin" }],
|
1396
|
-
created_on: /* @__PURE__ */ new Date()
|
1397
|
-
}).then(() => {
|
1398
|
-
snackbarController.open({
|
1399
|
-
type: "success",
|
1400
|
-
message: "User added successfully"
|
1401
|
-
});
|
1402
|
-
}).catch((error) => {
|
1403
|
-
snackbarController.open({
|
1404
|
-
type: "error",
|
1405
|
-
message: "Error adding user: " + error.message
|
1406
|
-
});
|
1407
|
-
});
|
1408
|
-
},
|
1409
|
-
children: "Add the logged user as an admin"
|
1410
|
-
}
|
1411
|
-
)
|
1412
|
-
] }) }) })
|
1891
|
+
t2,
|
1892
|
+
t3
|
1413
1893
|
] })
|
1414
|
-
] })
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
message: "Error deleting user: " + error.message
|
1429
|
-
});
|
1430
|
-
}).finally(() => {
|
1431
|
-
setDeleteInProgress(false);
|
1432
|
-
});
|
1433
|
-
}
|
1434
|
-
},
|
1435
|
-
onCancel: () => {
|
1894
|
+
] });
|
1895
|
+
$[11] = t2;
|
1896
|
+
$[12] = t3;
|
1897
|
+
$[13] = t4;
|
1898
|
+
} else {
|
1899
|
+
t4 = $[13];
|
1900
|
+
}
|
1901
|
+
const t5 = Boolean(userToBeDeleted);
|
1902
|
+
let t6;
|
1903
|
+
if ($[14] !== deleteUser || $[15] !== snackbarController || $[16] !== userToBeDeleted) {
|
1904
|
+
t6 = () => {
|
1905
|
+
if (userToBeDeleted) {
|
1906
|
+
setDeleteInProgress(true);
|
1907
|
+
deleteUser(userToBeDeleted).then(() => {
|
1436
1908
|
setUserToBeDeleted(void 0);
|
1437
|
-
}
|
1438
|
-
|
1439
|
-
|
1909
|
+
}).catch((error_0) => {
|
1910
|
+
snackbarController.open({
|
1911
|
+
type: "error",
|
1912
|
+
message: "Error deleting user: " + error_0.message
|
1913
|
+
});
|
1914
|
+
}).finally(() => {
|
1915
|
+
setDeleteInProgress(false);
|
1916
|
+
});
|
1440
1917
|
}
|
1441
|
-
|
1442
|
-
|
1918
|
+
};
|
1919
|
+
$[14] = deleteUser;
|
1920
|
+
$[15] = snackbarController;
|
1921
|
+
$[16] = userToBeDeleted;
|
1922
|
+
$[17] = t6;
|
1923
|
+
} else {
|
1924
|
+
t6 = $[17];
|
1925
|
+
}
|
1926
|
+
let t7;
|
1927
|
+
let t8;
|
1928
|
+
let t9;
|
1929
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
1930
|
+
t7 = () => {
|
1931
|
+
setUserToBeDeleted(void 0);
|
1932
|
+
};
|
1933
|
+
t8 = /* @__PURE__ */ jsx(Fragment, { children: "Delete?" });
|
1934
|
+
t9 = /* @__PURE__ */ jsx(Fragment, { children: "Are you sure you want to delete this user?" });
|
1935
|
+
$[18] = t7;
|
1936
|
+
$[19] = t8;
|
1937
|
+
$[20] = t9;
|
1938
|
+
} else {
|
1939
|
+
t7 = $[18];
|
1940
|
+
t8 = $[19];
|
1941
|
+
t9 = $[20];
|
1942
|
+
}
|
1943
|
+
let t10;
|
1944
|
+
if ($[21] !== deleteInProgress || $[22] !== t5 || $[23] !== t6) {
|
1945
|
+
t10 = /* @__PURE__ */ jsx(ConfirmationDialog, { open: t5, loading: deleteInProgress, onAccept: t6, onCancel: t7, title: t8, body: t9 });
|
1946
|
+
$[21] = deleteInProgress;
|
1947
|
+
$[22] = t5;
|
1948
|
+
$[23] = t6;
|
1949
|
+
$[24] = t10;
|
1950
|
+
} else {
|
1951
|
+
t10 = $[24];
|
1952
|
+
}
|
1953
|
+
let t11;
|
1954
|
+
if ($[25] !== t10 || $[26] !== t4) {
|
1955
|
+
t11 = /* @__PURE__ */ jsxs("div", { className: "overflow-auto", children: [
|
1956
|
+
t4,
|
1957
|
+
t10
|
1958
|
+
] });
|
1959
|
+
$[25] = t10;
|
1960
|
+
$[26] = t4;
|
1961
|
+
$[27] = t11;
|
1962
|
+
} else {
|
1963
|
+
t11 = $[27];
|
1964
|
+
}
|
1965
|
+
return t11;
|
1966
|
+
}
|
1967
|
+
function _temp(userRole) {
|
1968
|
+
return /* @__PURE__ */ jsx(RoleChip, { role: userRole }, userRole?.id);
|
1443
1969
|
}
|
1444
|
-
const UsersView = function UsersView2(
|
1970
|
+
const UsersView = function UsersView2(t0) {
|
1971
|
+
const $ = c(12);
|
1972
|
+
const {
|
1973
|
+
children
|
1974
|
+
} = t0;
|
1445
1975
|
const [dialogOpen, setDialogOpen] = useState();
|
1446
1976
|
const [selectedUser, setSelectedUser] = useState();
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1977
|
+
useUserManagement();
|
1978
|
+
let t1;
|
1979
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
1980
|
+
t1 = (user) => {
|
1981
|
+
setSelectedUser(user);
|
1982
|
+
setDialogOpen(true);
|
1983
|
+
};
|
1984
|
+
$[0] = t1;
|
1985
|
+
} else {
|
1986
|
+
t1 = $[0];
|
1987
|
+
}
|
1988
|
+
const onUserClicked = t1;
|
1989
|
+
let t2;
|
1990
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
1991
|
+
t2 = () => {
|
1992
|
+
setDialogOpen(false);
|
1993
|
+
setSelectedUser(void 0);
|
1994
|
+
};
|
1995
|
+
$[1] = t2;
|
1996
|
+
} else {
|
1997
|
+
t2 = $[1];
|
1998
|
+
}
|
1999
|
+
const handleClose = t2;
|
2000
|
+
let t3;
|
2001
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
2002
|
+
t3 = /* @__PURE__ */ jsx(Typography, { gutterBottom: true, variant: "h4", className: "flex-grow", component: "h4", children: "Users" });
|
2003
|
+
$[2] = t3;
|
2004
|
+
} else {
|
2005
|
+
t3 = $[2];
|
2006
|
+
}
|
2007
|
+
let t4;
|
2008
|
+
let t5;
|
2009
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
2010
|
+
t4 = /* @__PURE__ */ jsxs("div", { className: "flex items-center mt-12", children: [
|
2011
|
+
t3,
|
2012
|
+
/* @__PURE__ */ jsx(Button, { size: "large", startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: () => setDialogOpen(true), children: "Add user" })
|
2013
|
+
] });
|
2014
|
+
t5 = /* @__PURE__ */ jsx(UsersTable, { onUserClicked });
|
2015
|
+
$[3] = t4;
|
2016
|
+
$[4] = t5;
|
2017
|
+
} else {
|
2018
|
+
t4 = $[3];
|
2019
|
+
t5 = $[4];
|
2020
|
+
}
|
2021
|
+
const t6 = selectedUser?.uid ?? "new";
|
2022
|
+
const t7 = dialogOpen ?? false;
|
2023
|
+
let t8;
|
2024
|
+
if ($[5] !== selectedUser || $[6] !== t6 || $[7] !== t7) {
|
2025
|
+
t8 = /* @__PURE__ */ jsx(UserDetailsForm, { open: t7, user: selectedUser, handleClose }, t6);
|
2026
|
+
$[5] = selectedUser;
|
2027
|
+
$[6] = t6;
|
2028
|
+
$[7] = t7;
|
2029
|
+
$[8] = t8;
|
2030
|
+
} else {
|
2031
|
+
t8 = $[8];
|
2032
|
+
}
|
2033
|
+
let t9;
|
2034
|
+
if ($[9] !== children || $[10] !== t8) {
|
2035
|
+
t9 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
|
2036
|
+
children,
|
2037
|
+
t4,
|
2038
|
+
t5,
|
2039
|
+
t8
|
2040
|
+
] });
|
2041
|
+
$[9] = children;
|
2042
|
+
$[10] = t8;
|
2043
|
+
$[11] = t9;
|
2044
|
+
} else {
|
2045
|
+
t9 = $[11];
|
2046
|
+
}
|
2047
|
+
return t9;
|
1498
2048
|
};
|
1499
|
-
function useUserManagementPlugin(
|
2049
|
+
function useUserManagementPlugin(t0) {
|
2050
|
+
const $ = c(12);
|
2051
|
+
const {
|
2052
|
+
userManagement
|
2053
|
+
} = t0;
|
1500
2054
|
const noUsers = userManagement.users.length === 0;
|
1501
2055
|
const noRoles = userManagement.roles.length === 0;
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
2056
|
+
let t1;
|
2057
|
+
if ($[0] !== noRoles || $[1] !== noUsers || $[2] !== userManagement) {
|
2058
|
+
t1 = noUsers || noRoles ? /* @__PURE__ */ jsx(IntroWidget, { noUsers, noRoles, userManagement }) : void 0;
|
2059
|
+
$[0] = noRoles;
|
2060
|
+
$[1] = noUsers;
|
2061
|
+
$[2] = userManagement;
|
2062
|
+
$[3] = t1;
|
2063
|
+
} else {
|
2064
|
+
t1 = $[3];
|
2065
|
+
}
|
2066
|
+
let t2;
|
2067
|
+
if ($[4] !== t1) {
|
2068
|
+
t2 = {
|
2069
|
+
additionalChildrenStart: t1
|
2070
|
+
};
|
2071
|
+
$[4] = t1;
|
2072
|
+
$[5] = t2;
|
2073
|
+
} else {
|
2074
|
+
t2 = $[5];
|
2075
|
+
}
|
2076
|
+
let t3;
|
2077
|
+
if ($[6] !== userManagement) {
|
2078
|
+
t3 = {
|
1516
2079
|
Component: UserManagementProvider,
|
1517
2080
|
props: {
|
1518
2081
|
userManagement
|
1519
2082
|
}
|
1520
|
-
}
|
1521
|
-
|
2083
|
+
};
|
2084
|
+
$[6] = userManagement;
|
2085
|
+
$[7] = t3;
|
2086
|
+
} else {
|
2087
|
+
t3 = $[7];
|
2088
|
+
}
|
2089
|
+
let t4;
|
2090
|
+
if ($[8] !== t2 || $[9] !== t3 || $[10] !== userManagement.loading) {
|
2091
|
+
t4 = {
|
2092
|
+
key: "user_management",
|
2093
|
+
loading: userManagement.loading,
|
2094
|
+
homePage: t2,
|
2095
|
+
provider: t3
|
2096
|
+
};
|
2097
|
+
$[8] = t2;
|
2098
|
+
$[9] = t3;
|
2099
|
+
$[10] = userManagement.loading;
|
2100
|
+
$[11] = t4;
|
2101
|
+
} else {
|
2102
|
+
t4 = $[11];
|
2103
|
+
}
|
2104
|
+
return t4;
|
1522
2105
|
}
|
1523
|
-
function IntroWidget({
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
2106
|
+
function IntroWidget(t0) {
|
2107
|
+
const $ = c(17);
|
2108
|
+
const {
|
2109
|
+
noUsers,
|
2110
|
+
noRoles,
|
2111
|
+
userManagement
|
2112
|
+
} = t0;
|
1528
2113
|
const authController = useAuthController();
|
1529
2114
|
const snackbarController = useSnackbarController();
|
1530
2115
|
const buttonLabel = noUsers && noRoles ? "Create default roles and add current user as admin" : noUsers ? "Add current user as admin" : noRoles ? "Create default roles" : void 0;
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
2116
|
+
let t1;
|
2117
|
+
let t2;
|
2118
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
2119
|
+
t1 = /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "uppercase", children: "Create your users and roles" });
|
2120
|
+
t2 = /* @__PURE__ */ jsx(Typography, { children: "You have no users or roles defined. You can create default roles and add the current user as admin." });
|
2121
|
+
$[0] = t1;
|
2122
|
+
$[1] = t2;
|
2123
|
+
} else {
|
2124
|
+
t1 = $[0];
|
2125
|
+
t2 = $[1];
|
2126
|
+
}
|
2127
|
+
let t3;
|
2128
|
+
if ($[2] !== authController.user?.displayName || $[3] !== authController.user?.email || $[4] !== authController.user?.isAnonymous || $[5] !== authController.user?.photoURL || $[6] !== authController.user?.providerId || $[7] !== authController.user?.uid || $[8] !== noRoles || $[9] !== noUsers || $[10] !== snackbarController || $[11] !== userManagement) {
|
2129
|
+
t3 = () => {
|
2130
|
+
if (!authController.user?.uid) {
|
2131
|
+
throw Error("UsersTable, authController misconfiguration");
|
2132
|
+
}
|
2133
|
+
if (noUsers) {
|
2134
|
+
userManagement.saveUser({
|
2135
|
+
uid: authController.user?.uid,
|
2136
|
+
email: authController.user?.email,
|
2137
|
+
displayName: authController.user?.displayName,
|
2138
|
+
photoURL: authController.user?.photoURL,
|
2139
|
+
providerId: authController.user?.providerId,
|
2140
|
+
isAnonymous: authController.user?.isAnonymous,
|
2141
|
+
roles: [{
|
2142
|
+
id: "admin",
|
2143
|
+
name: "Admin"
|
2144
|
+
}],
|
2145
|
+
created_on: /* @__PURE__ */ new Date()
|
2146
|
+
}).then(() => {
|
2147
|
+
snackbarController.open({
|
2148
|
+
type: "success",
|
2149
|
+
message: "User added successfully"
|
2150
|
+
});
|
2151
|
+
}).catch((error) => {
|
2152
|
+
snackbarController.open({
|
2153
|
+
type: "error",
|
2154
|
+
message: "Error adding user: " + error.message
|
2155
|
+
});
|
2156
|
+
});
|
2157
|
+
}
|
2158
|
+
if (noRoles) {
|
2159
|
+
DEFAULT_ROLES.forEach((role) => {
|
2160
|
+
userManagement.saveRole(role);
|
2161
|
+
});
|
2162
|
+
}
|
2163
|
+
};
|
2164
|
+
$[2] = authController.user?.displayName;
|
2165
|
+
$[3] = authController.user?.email;
|
2166
|
+
$[4] = authController.user?.isAnonymous;
|
2167
|
+
$[5] = authController.user?.photoURL;
|
2168
|
+
$[6] = authController.user?.providerId;
|
2169
|
+
$[7] = authController.user?.uid;
|
2170
|
+
$[8] = noRoles;
|
2171
|
+
$[9] = noUsers;
|
2172
|
+
$[10] = snackbarController;
|
2173
|
+
$[11] = userManagement;
|
2174
|
+
$[12] = t3;
|
2175
|
+
} else {
|
2176
|
+
t3 = $[12];
|
2177
|
+
}
|
2178
|
+
let t4;
|
2179
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
2180
|
+
t4 = /* @__PURE__ */ jsx(AddIcon, {});
|
2181
|
+
$[13] = t4;
|
2182
|
+
} else {
|
2183
|
+
t4 = $[13];
|
2184
|
+
}
|
2185
|
+
let t5;
|
2186
|
+
if ($[14] !== buttonLabel || $[15] !== t3) {
|
2187
|
+
t5 = /* @__PURE__ */ jsxs(Paper, { className: "my-4 flex flex-col px-4 py-6 bg-white dark:bg-surface-accent-800 gap-2", children: [
|
2188
|
+
t1,
|
2189
|
+
t2,
|
2190
|
+
/* @__PURE__ */ jsxs(Button, { onClick: t3, children: [
|
2191
|
+
t4,
|
2192
|
+
buttonLabel
|
2193
|
+
] })
|
2194
|
+
] });
|
2195
|
+
$[14] = buttonLabel;
|
2196
|
+
$[15] = t3;
|
2197
|
+
$[16] = t5;
|
2198
|
+
} else {
|
2199
|
+
t5 = $[16];
|
2200
|
+
}
|
2201
|
+
return t5;
|
1579
2202
|
}
|
1580
|
-
const userManagementAdminViews = [
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
view: /* @__PURE__ */ jsx(RolesView, {})
|
1594
|
-
}
|
1595
|
-
];
|
2203
|
+
const userManagementAdminViews = [{
|
2204
|
+
path: "users",
|
2205
|
+
name: "CMS Users",
|
2206
|
+
group: "Admin",
|
2207
|
+
icon: "face",
|
2208
|
+
view: /* @__PURE__ */ jsx(UsersView, {})
|
2209
|
+
}, {
|
2210
|
+
path: "roles",
|
2211
|
+
name: "Roles",
|
2212
|
+
group: "Admin",
|
2213
|
+
icon: "gpp_good",
|
2214
|
+
view: /* @__PURE__ */ jsx(RolesView, {})
|
2215
|
+
}];
|
1596
2216
|
export {
|
1597
2217
|
IntroWidget,
|
1598
2218
|
RESERVED_GROUPS,
|