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