@firecms/user_management 3.0.0-3.0.0-canary.8.0 → 3.0.0-3.0.0-canary.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +113 -21
- package/dist/UserManagementProvider.d.ts +4 -3
- package/dist/components/roles/RoleChip.d.ts +1 -1
- package/dist/components/roles/RolesDetailsForm.d.ts +1 -2
- package/dist/components/roles/RolesTable.d.ts +1 -1
- package/dist/components/roles/default_roles.d.ts +1 -1
- package/dist/components/users/UserDetailsForm.d.ts +2 -2
- package/dist/components/users/UsersTable.d.ts +2 -2
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/{useBuildFirestoreUserManagement.d.ts → useFirestoreUserManagement.d.ts} +7 -3
- package/dist/hooks/useUserManagement.d.ts +3 -2
- package/dist/index.es.js +559 -472
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/persisted_user.d.ts +5 -0
- package/dist/types/user_management.d.ts +14 -10
- package/dist/useUserManagementPlugin.d.ts +6 -1
- package/dist/utils/permissions.d.ts +3 -4
- package/package.json +12 -15
- package/src/UserManagementProvider.tsx +4 -3
- package/src/components/roles/RoleChip.tsx +1 -1
- package/src/components/roles/RolesDetailsForm.tsx +1 -2
- package/src/components/roles/RolesTable.tsx +1 -2
- package/src/components/roles/RolesView.tsx +1 -2
- package/src/components/roles/default_roles.tsx +1 -1
- package/src/components/users/UserDetailsForm.tsx +14 -13
- package/src/components/users/UsersTable.tsx +6 -6
- package/src/components/users/UsersView.tsx +3 -3
- package/src/hooks/index.ts +1 -1
- package/src/hooks/{useBuildFirestoreUserManagement.tsx → useFirestoreUserManagement.tsx} +87 -54
- package/src/hooks/useUserManagement.tsx +3 -3
- package/src/types/index.ts +1 -2
- package/src/types/persisted_user.ts +6 -0
- package/src/types/user_management.tsx +17 -11
- package/src/useUserManagementPlugin.tsx +89 -3
- package/src/utils/permissions.ts +7 -5
- package/dist/types/firecms_user.d.ts +0 -7
- package/dist/types/roles.d.ts +0 -31
- package/src/types/firecms_user.ts +0 -8
- package/src/types/roles.ts +0 -41
- package/tailwind.config.js +0 -68
package/dist/index.es.js
CHANGED
@@ -1,22 +1,25 @@
|
|
1
|
-
import
|
2
|
-
import { getFirestore as
|
3
|
-
import { jsx as e, jsxs as s, Fragment as
|
4
|
-
import { getColorSchemeForSeed as
|
5
|
-
import * as
|
6
|
-
import { toSnakeCase as
|
7
|
-
import { useCreateFormex as
|
1
|
+
import F, { useEffect as ce, useCallback as k, useContext as Ie, useState as P } from "react";
|
2
|
+
import { getFirestore as Y, onSnapshot as ue, collection as ee, setDoc as me, doc as H, addDoc as Fe, deleteDoc as he } from "firebase/firestore";
|
3
|
+
import { jsx as e, jsxs as s, Fragment as K } from "react/jsx-runtime";
|
4
|
+
import { getColorSchemeForSeed as Pe, Chip as Ae, Dialog as fe, DialogContent as ge, Typography as A, TextField as Q, Paper as pe, Table as re, TableHeader as ie, TableCell as d, TableBody as oe, TableRow as W, Tooltip as V, Checkbox as I, Select as ne, SelectItem as L, DialogActions as Ce, Button as O, LoadingButton as ve, DoneIcon as we, IconButton as ye, DeleteIcon as be, CenteredView as Ne, Container as Ue, AddIcon as le, MultiSelect as Te, MultiSelectItem as Le } from "@firecms/ui";
|
5
|
+
import * as M from "yup";
|
6
|
+
import { toSnakeCase as Be, FieldCaption as B, DeleteConfirmationDialog as xe, useNavigationController as _e, useSnackbarController as se, useAuthController as ae, useCustomizationController as Ve, defaultDateFormat as Me } from "@firecms/core";
|
7
|
+
import { useCreateFormex as Re, getIn as J, Formex as De } from "@firecms/formex";
|
8
8
|
import { format as Oe } from "date-fns";
|
9
9
|
import * as $e from "date-fns/locale";
|
10
|
-
const
|
10
|
+
const fn = ["Admin"], qe = {
|
11
11
|
read: !1,
|
12
12
|
edit: !1,
|
13
13
|
create: !1,
|
14
14
|
delete: !1
|
15
15
|
};
|
16
|
-
function
|
17
|
-
|
16
|
+
function Ye({
|
17
|
+
collection: t,
|
18
|
+
user: r
|
19
|
+
}) {
|
20
|
+
const n = r?.roles;
|
18
21
|
if (n) {
|
19
|
-
if (t.ownerId ===
|
22
|
+
if (t.ownerId === r?.uid)
|
20
23
|
return {
|
21
24
|
read: !0,
|
22
25
|
create: !0,
|
@@ -24,277 +27,299 @@ function qe({ collection: t, user: i }) {
|
|
24
27
|
delete: !0
|
25
28
|
};
|
26
29
|
{
|
27
|
-
const
|
30
|
+
const l = {
|
28
31
|
read: !1,
|
29
32
|
create: !1,
|
30
33
|
edit: !1,
|
31
34
|
delete: !1
|
32
35
|
};
|
33
|
-
return n.map((
|
36
|
+
return n.map((i) => We(i, t.id)).reduce(te, l);
|
34
37
|
}
|
35
38
|
} else
|
36
|
-
return
|
39
|
+
return qe;
|
37
40
|
}
|
38
|
-
function
|
41
|
+
function We(t, r) {
|
39
42
|
const n = {
|
40
43
|
read: t.isAdmin || t.defaultPermissions?.read,
|
41
44
|
create: t.isAdmin || t.defaultPermissions?.create,
|
42
45
|
edit: t.isAdmin || t.defaultPermissions?.edit,
|
43
46
|
delete: t.isAdmin || t.defaultPermissions?.delete
|
44
47
|
};
|
45
|
-
return t.collectionPermissions && t.collectionPermissions[
|
48
|
+
return t.collectionPermissions && t.collectionPermissions[r] ? te(t.collectionPermissions[r], n) : t.defaultPermissions ? te(t.defaultPermissions, n) : n;
|
46
49
|
}
|
47
|
-
const te = (t,
|
48
|
-
read: t.read ||
|
49
|
-
create: t.create ||
|
50
|
-
edit: t.edit ||
|
51
|
-
delete: t.delete ||
|
50
|
+
const te = (t, r) => ({
|
51
|
+
read: t.read || r.read,
|
52
|
+
create: t.create || r.create,
|
53
|
+
edit: t.edit || r.edit,
|
54
|
+
delete: t.delete || r.delete
|
52
55
|
});
|
53
|
-
function
|
54
|
-
return t ?
|
56
|
+
function gn(t, r) {
|
57
|
+
return t ? r.roles ? r.roles.map((n) => t.find((l) => l.id === n.id)).filter(Boolean) : [] : void 0;
|
55
58
|
}
|
56
|
-
const
|
57
|
-
const n = t.map((
|
58
|
-
return n.length ===
|
59
|
+
const je = (t, r) => {
|
60
|
+
const n = t.map((i) => i.id), l = r.map((i) => i.id);
|
61
|
+
return n.length === r.length && n.every((i) => l.includes(i));
|
59
62
|
};
|
60
|
-
function
|
61
|
-
if (!
|
63
|
+
function pn(t, r) {
|
64
|
+
if (!r)
|
62
65
|
return;
|
63
|
-
const n =
|
66
|
+
const n = ze(r), l = new Date(n.exp * 1e3);
|
64
67
|
localStorage.setItem(`auth_token::${t}`, JSON.stringify({
|
65
|
-
token:
|
66
|
-
expiry:
|
68
|
+
token: r,
|
69
|
+
expiry: l
|
67
70
|
}));
|
68
71
|
}
|
69
|
-
function
|
70
|
-
const
|
71
|
-
if (
|
72
|
-
const n = JSON.parse(
|
72
|
+
function Cn(t) {
|
73
|
+
const r = localStorage.getItem(`auth_token::${t}`);
|
74
|
+
if (r) {
|
75
|
+
const n = JSON.parse(r);
|
73
76
|
if (n.expiry = new Date(n.expiry), n.expiry > /* @__PURE__ */ new Date())
|
74
77
|
return n.token;
|
75
78
|
}
|
76
79
|
}
|
77
|
-
function
|
80
|
+
function vn() {
|
78
81
|
for (let t = 0; t < localStorage.length; t++) {
|
79
|
-
const
|
80
|
-
|
82
|
+
const r = localStorage.key(t);
|
83
|
+
r?.startsWith("auth_token::") && localStorage.removeItem(r);
|
81
84
|
}
|
82
85
|
}
|
83
|
-
function
|
86
|
+
function ze(t) {
|
84
87
|
if (!t)
|
85
88
|
throw new Error("No JWT token");
|
86
|
-
const n = t.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"),
|
87
|
-
return "%" + ("00" +
|
89
|
+
const n = t.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), l = decodeURIComponent(window.atob(n).split("").map(function(i) {
|
90
|
+
return "%" + ("00" + i.charCodeAt(0).toString(16)).slice(-2);
|
88
91
|
}).join(""));
|
89
|
-
return JSON.parse(
|
92
|
+
return JSON.parse(l);
|
90
93
|
}
|
91
|
-
function
|
94
|
+
function wn(t, r = 10) {
|
92
95
|
if (!/^#([0-9A-Fa-f]{3}){1,2}$/.test(t))
|
93
96
|
throw new Error("Invalid color format");
|
94
97
|
let n = t.substring(1).split("");
|
95
98
|
n.length === 3 && (n = [n[0], n[0], n[1], n[1], n[2], n[2]]);
|
96
|
-
let
|
97
|
-
return
|
99
|
+
let l = parseInt(n[0] + n[1], 16), i = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16);
|
100
|
+
return l = Math.floor(l * (1 - r / 100)), i = Math.floor(i * (1 - r / 100)), m = Math.floor(m * (1 - r / 100)), "#" + (l < 16 ? "0" : "") + l.toString(16) + (i < 16 ? "0" : "") + i.toString(16) + (m < 16 ? "0" : "") + m.toString(16);
|
98
101
|
}
|
99
|
-
function
|
102
|
+
function yn(t, r = 10) {
|
100
103
|
if (!/^#([0-9A-Fa-f]{3}){1,2}$/.test(t))
|
101
104
|
throw new Error("Invalid color format");
|
102
105
|
let n = t.substring(1).split("");
|
103
106
|
n.length === 3 && (n = [n[0], n[0], n[1], n[1], n[2], n[2]]);
|
104
|
-
const
|
105
|
-
return `rgba(${
|
107
|
+
const l = parseInt(n[0] + n[1], 16), i = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16), f = r / 100;
|
108
|
+
return `rgba(${l}, ${i}, ${m}, ${f})`;
|
106
109
|
}
|
107
|
-
function
|
110
|
+
function bn({
|
108
111
|
firebaseApp: t,
|
109
|
-
usersPath:
|
112
|
+
usersPath: r = "__FIRECMS/config/users",
|
110
113
|
rolesPath: n = "__FIRECMS/config/roles",
|
111
|
-
usersLimit:
|
112
|
-
canEditRoles:
|
113
|
-
|
114
|
-
|
115
|
-
includeCollectionConfigPermissions: p
|
114
|
+
usersLimit: l,
|
115
|
+
canEditRoles: i = !0,
|
116
|
+
allowDefaultRolesCreation: m,
|
117
|
+
includeCollectionConfigPermissions: f
|
116
118
|
}) {
|
117
|
-
const
|
118
|
-
...
|
119
|
-
roles:
|
120
|
-
})), [
|
121
|
-
|
122
|
-
t && (N.current = ee(t));
|
123
|
-
}, [t]), Z(() => {
|
119
|
+
const [v, R] = F.useState(!0), [w, c] = F.useState(!0), [S, U] = F.useState([]), [a, C] = F.useState([]), y = a.map((g) => ({
|
120
|
+
...g,
|
121
|
+
roles: S.filter((p) => g.roles?.includes(p.id))
|
122
|
+
})), [b, _] = F.useState(), [z, u] = F.useState(), h = v || w;
|
123
|
+
ce(() => {
|
124
124
|
if (!t || !n)
|
125
125
|
return;
|
126
|
-
const
|
127
|
-
return
|
128
|
-
|
126
|
+
const g = Y(t);
|
127
|
+
return ue(
|
128
|
+
ee(g, n),
|
129
129
|
{
|
130
|
-
next: (
|
131
|
-
|
130
|
+
next: (p) => {
|
131
|
+
_(void 0);
|
132
132
|
try {
|
133
|
-
const
|
134
|
-
|
135
|
-
} catch (
|
136
|
-
|
133
|
+
const N = Ge(p.docs);
|
134
|
+
U(N);
|
135
|
+
} catch (N) {
|
136
|
+
console.error("Error loading roles", N), _(N);
|
137
137
|
}
|
138
|
-
|
138
|
+
R(!1);
|
139
139
|
},
|
140
|
-
error: (
|
141
|
-
|
140
|
+
error: (p) => {
|
141
|
+
console.error("Error loading roles", p), _(p), R(!1);
|
142
142
|
}
|
143
143
|
}
|
144
144
|
);
|
145
|
-
}, [t, n]),
|
146
|
-
if (!t || !
|
145
|
+
}, [t, n]), ce(() => {
|
146
|
+
if (!t || !r)
|
147
147
|
return;
|
148
|
-
const
|
149
|
-
return
|
150
|
-
|
148
|
+
const g = Y(t);
|
149
|
+
return ue(
|
150
|
+
ee(g, r),
|
151
151
|
{
|
152
|
-
next: (
|
153
|
-
|
152
|
+
next: (p) => {
|
153
|
+
u(void 0);
|
154
154
|
try {
|
155
|
-
const
|
156
|
-
|
157
|
-
} catch (
|
158
|
-
|
155
|
+
const N = Je(p.docs);
|
156
|
+
C(N);
|
157
|
+
} catch (N) {
|
158
|
+
console.error("Error loading users", N), u(N);
|
159
159
|
}
|
160
|
-
|
160
|
+
c(!1);
|
161
161
|
},
|
162
|
-
error: (
|
163
|
-
|
162
|
+
error: (p) => {
|
163
|
+
console.error("Error loading users", p), u(p), c(!1);
|
164
164
|
}
|
165
165
|
}
|
166
166
|
);
|
167
|
-
}, [t,
|
168
|
-
const
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
167
|
+
}, [t, r]);
|
168
|
+
const x = k(async (g) => {
|
169
|
+
if (!t)
|
170
|
+
throw Error("useFirestoreUserManagement Firebase not initialised");
|
171
|
+
const p = Y(t);
|
172
|
+
if (!p || !r)
|
173
|
+
throw Error("useFirestoreUserManagement Firestore not initialised");
|
174
|
+
console.debug("Persisting user", g);
|
175
|
+
const N = g.roles?.map((ke) => ke.id), {
|
176
|
+
uid: q,
|
177
|
+
...Z
|
178
|
+
} = g, de = {
|
179
|
+
...Z,
|
180
|
+
roles: N
|
181
|
+
};
|
182
|
+
return q ? me(H(p, r, q), de, { merge: !0 }).then(() => g) : Fe(ee(p, r), de).then(() => g);
|
183
|
+
}, [r, t]), D = k((g) => {
|
184
|
+
if (!t)
|
185
|
+
throw Error("useFirestoreUserManagement Firebase not initialised");
|
186
|
+
const p = Y(t);
|
187
|
+
if (!p || !n)
|
188
|
+
throw Error("useFirestoreUserManagement Firestore not initialised");
|
189
|
+
console.debug("Persisting role", g);
|
183
190
|
const {
|
184
|
-
id:
|
185
|
-
...
|
186
|
-
} =
|
187
|
-
return
|
188
|
-
}, [n]),
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
const
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
191
|
+
id: N,
|
192
|
+
...q
|
193
|
+
} = g, Z = H(p, n, N);
|
194
|
+
return me(Z, q, { merge: !0 });
|
195
|
+
}, [n, t]), T = k(async (g) => {
|
196
|
+
if (!t)
|
197
|
+
throw Error("useFirestoreUserManagement Firebase not initialised");
|
198
|
+
const p = Y(t);
|
199
|
+
if (!p || !r)
|
200
|
+
throw Error("useFirestoreUserManagement Firestore not initialised");
|
201
|
+
console.debug("Deleting", g);
|
202
|
+
const { uid: N } = g;
|
203
|
+
return he(H(p, r, N));
|
204
|
+
}, [r, t]), o = k((g) => {
|
205
|
+
if (!t)
|
206
|
+
throw Error("useFirestoreUserManagement Firebase not initialised");
|
207
|
+
const p = Y(t);
|
208
|
+
if (!p || !n)
|
209
|
+
throw Error("useFirestoreUserManagement Firestore not initialised");
|
210
|
+
console.debug("Deleting", g);
|
211
|
+
const { id: N } = g, q = H(p, n, N);
|
212
|
+
return he(q);
|
213
|
+
}, [n, t]), E = k(({
|
214
|
+
collection: g,
|
215
|
+
user: p
|
216
|
+
}) => Ye({
|
217
|
+
collection: g,
|
218
|
+
user: p
|
219
|
+
}), []), $ = k((g) => {
|
220
|
+
if (!y)
|
221
|
+
throw Error("Users not loaded");
|
222
|
+
return y.find((N) => N.email?.toLowerCase() === g?.email?.toLowerCase())?.roles;
|
223
|
+
}, [y]), G = k(({ user: g }) => {
|
224
|
+
if (console.debug("Authenticating user", g), h)
|
225
|
+
return console.warn("User management is still loading"), !1;
|
226
|
+
if (y.length === 0 || y.find((N) => N.email?.toLowerCase() === g?.email?.toLowerCase()))
|
227
|
+
return !0;
|
228
|
+
throw Error("Could not find a user with the provided email in the user management system.");
|
229
|
+
}, [h, y]);
|
208
230
|
return {
|
209
|
-
loading:
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
deleteUser:
|
216
|
-
deleteRole:
|
217
|
-
usersLimit:
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
231
|
+
loading: h,
|
232
|
+
roles: S,
|
233
|
+
users: y,
|
234
|
+
saveUser: x,
|
235
|
+
saveRole: D,
|
236
|
+
rolesError: b,
|
237
|
+
deleteUser: T,
|
238
|
+
deleteRole: o,
|
239
|
+
usersLimit: l,
|
240
|
+
usersError: z,
|
241
|
+
canEditRoles: i === void 0 ? !0 : i,
|
242
|
+
allowDefaultRolesCreation: m === void 0 ? !0 : m,
|
243
|
+
includeCollectionConfigPermissions: !!f,
|
244
|
+
collectionPermissions: E,
|
245
|
+
defineRolesFor: $,
|
246
|
+
authenticator: G
|
222
247
|
};
|
223
248
|
}
|
224
|
-
const
|
225
|
-
const n =
|
249
|
+
const Je = (t) => t.map((r) => {
|
250
|
+
const n = r.data();
|
226
251
|
return {
|
227
|
-
uid:
|
252
|
+
uid: r.id,
|
228
253
|
...n,
|
229
254
|
created_on: n?.created_on?.toDate(),
|
230
255
|
updated_on: n?.updated_on?.toDate()
|
231
256
|
};
|
232
|
-
}),
|
233
|
-
id:
|
234
|
-
...
|
235
|
-
})),
|
236
|
-
function
|
257
|
+
}), Ge = (t) => t.map((r) => ({
|
258
|
+
id: r.id,
|
259
|
+
...r.data()
|
260
|
+
})), Ee = F.createContext({});
|
261
|
+
function He({
|
237
262
|
children: t,
|
238
|
-
userManagement:
|
263
|
+
userManagement: r
|
239
264
|
}) {
|
240
|
-
return /* @__PURE__ */ e(
|
265
|
+
return /* @__PURE__ */ e(Ee.Provider, { value: r, children: t });
|
241
266
|
}
|
242
|
-
const
|
243
|
-
function
|
244
|
-
let
|
245
|
-
return t.isAdmin ?
|
246
|
-
|
267
|
+
const j = () => Ie(Ee);
|
268
|
+
function X({ role: t }) {
|
269
|
+
let r;
|
270
|
+
return t.isAdmin ? r = "blueDarker" : t.id === "editor" ? r = "yellowLight" : t.id === "viewer" ? r = "grayLight" : r = Pe(t.id), /* @__PURE__ */ e(
|
271
|
+
Ae,
|
247
272
|
{
|
248
|
-
colorScheme:
|
273
|
+
colorScheme: r,
|
249
274
|
children: t.name
|
250
275
|
},
|
251
276
|
t.id
|
252
277
|
);
|
253
278
|
}
|
254
|
-
const
|
255
|
-
id:
|
256
|
-
name:
|
279
|
+
const Ke = M.object().shape({
|
280
|
+
id: M.string().required("Required"),
|
281
|
+
name: M.string().required("Required")
|
257
282
|
});
|
258
|
-
function
|
283
|
+
function Qe({
|
259
284
|
open: t,
|
260
|
-
role:
|
285
|
+
role: r,
|
261
286
|
editable: n,
|
262
|
-
handleClose:
|
263
|
-
collections:
|
287
|
+
handleClose: l,
|
288
|
+
collections: i
|
264
289
|
}) {
|
265
|
-
const { saveRole: m } =
|
266
|
-
initialValues:
|
290
|
+
const { saveRole: m } = j(), f = !r, [v, R] = P(), w = k((o) => (R(void 0), m(o)), [m]), c = Re({
|
291
|
+
initialValues: r ?? {
|
267
292
|
name: ""
|
268
293
|
},
|
269
|
-
onSubmit: (o,
|
270
|
-
|
294
|
+
onSubmit: (o, E) => w(o).then(() => {
|
295
|
+
E.resetForm({
|
271
296
|
values: o
|
272
|
-
}),
|
273
|
-
}).catch(($) =>
|
274
|
-
validation: (o) =>
|
297
|
+
}), l();
|
298
|
+
}).catch(($) => R($)),
|
299
|
+
validation: (o) => Ke.validate(o, { abortEarly: !1 }).then(() => ({})).catch((E) => {
|
275
300
|
const $ = {};
|
276
|
-
return
|
277
|
-
$[
|
301
|
+
return E.inner.forEach((G) => {
|
302
|
+
$[G.path] = G.message;
|
278
303
|
}), $;
|
279
304
|
})
|
280
305
|
}), {
|
281
|
-
isSubmitting:
|
282
|
-
touched:
|
283
|
-
values:
|
284
|
-
errors:
|
285
|
-
handleChange:
|
286
|
-
setFieldValue:
|
287
|
-
dirty:
|
306
|
+
isSubmitting: S,
|
307
|
+
touched: U,
|
308
|
+
values: a,
|
309
|
+
errors: C,
|
310
|
+
handleChange: y,
|
311
|
+
setFieldValue: b,
|
312
|
+
dirty: _,
|
288
313
|
setFieldTouched: z
|
289
|
-
} = c, u =
|
290
|
-
return
|
291
|
-
!
|
292
|
-
}, [
|
293
|
-
|
314
|
+
} = c, u = a.isAdmin ?? !1, h = a.defaultPermissions?.create ?? !1, x = a.defaultPermissions?.read ?? !1, D = a.defaultPermissions?.edit ?? !1, T = a.defaultPermissions?.delete ?? !1;
|
315
|
+
return F.useEffect(() => {
|
316
|
+
!J(U, "id") && a.name && b("id", Be(a.name));
|
317
|
+
}, [U, a.name]), /* @__PURE__ */ e(
|
318
|
+
fe,
|
294
319
|
{
|
295
320
|
open: t,
|
296
321
|
maxWidth: "4xl",
|
297
|
-
children: /* @__PURE__ */ e(
|
322
|
+
children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ s(
|
298
323
|
"form",
|
299
324
|
{
|
300
325
|
noValidate: !0,
|
@@ -307,13 +332,13 @@ function Ke({
|
|
307
332
|
height: "100%"
|
308
333
|
},
|
309
334
|
children: [
|
310
|
-
/* @__PURE__ */ s(
|
335
|
+
/* @__PURE__ */ s(ge, { className: "flex-grow", children: [
|
311
336
|
/* @__PURE__ */ e(
|
312
337
|
"div",
|
313
338
|
{
|
314
339
|
className: "flex flex-row pt-12 pb-8",
|
315
340
|
children: /* @__PURE__ */ e(
|
316
|
-
|
341
|
+
A,
|
317
342
|
{
|
318
343
|
variant: "h4",
|
319
344
|
className: "flex-grow",
|
@@ -325,69 +350,69 @@ function Ke({
|
|
325
350
|
/* @__PURE__ */ s("div", { className: "grid grid-cols-12 gap-8", children: [
|
326
351
|
/* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-8", children: [
|
327
352
|
/* @__PURE__ */ e(
|
328
|
-
|
353
|
+
Q,
|
329
354
|
{
|
330
355
|
name: "name",
|
331
356
|
required: !0,
|
332
|
-
error:
|
333
|
-
value:
|
357
|
+
error: U.name && !!C.name,
|
358
|
+
value: a.name,
|
334
359
|
disabled: u || !n,
|
335
|
-
onChange:
|
360
|
+
onChange: y,
|
336
361
|
"aria-describedby": "name-helper-text",
|
337
362
|
label: "Name"
|
338
363
|
}
|
339
364
|
),
|
340
|
-
/* @__PURE__ */ e(B, { children:
|
365
|
+
/* @__PURE__ */ e(B, { children: U.name && C.name ? C.name : "Name of this role" })
|
341
366
|
] }),
|
342
367
|
/* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
|
343
368
|
/* @__PURE__ */ e(
|
344
|
-
|
369
|
+
Q,
|
345
370
|
{
|
346
371
|
name: "id",
|
347
372
|
required: !0,
|
348
|
-
error:
|
349
|
-
value:
|
373
|
+
error: U.id && !!C.id,
|
374
|
+
value: a.id,
|
350
375
|
disabled: !f || !n,
|
351
376
|
onChange: (o) => {
|
352
|
-
|
377
|
+
y(o), z("id", !0);
|
353
378
|
},
|
354
379
|
"aria-describedby": "id-helper-text",
|
355
380
|
label: "ID"
|
356
381
|
}
|
357
382
|
),
|
358
|
-
/* @__PURE__ */ e(B, { children:
|
383
|
+
/* @__PURE__ */ e(B, { children: U.id && C.id ? C.id : "ID of this role" })
|
359
384
|
] }),
|
360
385
|
/* @__PURE__ */ s("div", { className: "col-span-12", children: [
|
361
386
|
/* @__PURE__ */ e(
|
362
|
-
|
387
|
+
pe,
|
363
388
|
{
|
364
389
|
className: "bg-inherit",
|
365
|
-
children: /* @__PURE__ */ s(
|
366
|
-
/* @__PURE__ */ s(
|
367
|
-
/* @__PURE__ */ e(
|
390
|
+
children: /* @__PURE__ */ s(re, { children: [
|
391
|
+
/* @__PURE__ */ s(ie, { children: [
|
392
|
+
/* @__PURE__ */ e(d, {}),
|
368
393
|
/* @__PURE__ */ e(
|
369
|
-
|
394
|
+
d,
|
370
395
|
{
|
371
396
|
align: "center",
|
372
397
|
children: "Create entities"
|
373
398
|
}
|
374
399
|
),
|
375
400
|
/* @__PURE__ */ e(
|
376
|
-
|
401
|
+
d,
|
377
402
|
{
|
378
403
|
align: "center",
|
379
404
|
children: "Read entities"
|
380
405
|
}
|
381
406
|
),
|
382
407
|
/* @__PURE__ */ e(
|
383
|
-
|
408
|
+
d,
|
384
409
|
{
|
385
410
|
align: "center",
|
386
411
|
children: "Update entities"
|
387
412
|
}
|
388
413
|
),
|
389
414
|
/* @__PURE__ */ e(
|
390
|
-
|
415
|
+
d,
|
391
416
|
{
|
392
417
|
align: "center",
|
393
418
|
children: "Delete entities"
|
@@ -395,28 +420,28 @@ function Ke({
|
|
395
420
|
)
|
396
421
|
] }),
|
397
422
|
/* @__PURE__ */ s(oe, { children: [
|
398
|
-
/* @__PURE__ */ s(
|
423
|
+
/* @__PURE__ */ s(W, { children: [
|
399
424
|
/* @__PURE__ */ e(
|
400
|
-
|
425
|
+
d,
|
401
426
|
{
|
402
427
|
scope: "row",
|
403
428
|
children: /* @__PURE__ */ e("strong", { children: "All collections" })
|
404
429
|
}
|
405
430
|
),
|
406
431
|
/* @__PURE__ */ e(
|
407
|
-
|
432
|
+
d,
|
408
433
|
{
|
409
434
|
align: "center",
|
410
435
|
children: /* @__PURE__ */ e(
|
411
|
-
|
436
|
+
V,
|
412
437
|
{
|
413
438
|
title: "Create entities in collections",
|
414
439
|
children: /* @__PURE__ */ e(
|
415
|
-
|
440
|
+
I,
|
416
441
|
{
|
417
442
|
disabled: u || !n,
|
418
443
|
checked: (u || h) ?? !1,
|
419
|
-
onCheckedChange: (o) =>
|
444
|
+
onCheckedChange: (o) => b("defaultPermissions.create", o)
|
420
445
|
}
|
421
446
|
)
|
422
447
|
}
|
@@ -424,19 +449,19 @@ function Ke({
|
|
424
449
|
}
|
425
450
|
),
|
426
451
|
/* @__PURE__ */ e(
|
427
|
-
|
452
|
+
d,
|
428
453
|
{
|
429
454
|
align: "center",
|
430
455
|
children: /* @__PURE__ */ e(
|
431
|
-
|
456
|
+
V,
|
432
457
|
{
|
433
458
|
title: "Access all data in every collection",
|
434
459
|
children: /* @__PURE__ */ e(
|
435
|
-
|
460
|
+
I,
|
436
461
|
{
|
437
462
|
disabled: u || !n,
|
438
463
|
checked: (u || x) ?? !1,
|
439
|
-
onCheckedChange: (o) =>
|
464
|
+
onCheckedChange: (o) => b("defaultPermissions.read", o)
|
440
465
|
}
|
441
466
|
)
|
442
467
|
}
|
@@ -444,19 +469,19 @@ function Ke({
|
|
444
469
|
}
|
445
470
|
),
|
446
471
|
/* @__PURE__ */ e(
|
447
|
-
|
472
|
+
d,
|
448
473
|
{
|
449
474
|
align: "center",
|
450
475
|
children: /* @__PURE__ */ e(
|
451
|
-
|
476
|
+
V,
|
452
477
|
{
|
453
478
|
title: "Update data in any collection",
|
454
479
|
children: /* @__PURE__ */ e(
|
455
|
-
|
480
|
+
I,
|
456
481
|
{
|
457
482
|
disabled: u || !n,
|
458
|
-
checked: (u ||
|
459
|
-
onCheckedChange: (o) =>
|
483
|
+
checked: (u || D) ?? !1,
|
484
|
+
onCheckedChange: (o) => b("defaultPermissions.edit", o)
|
460
485
|
}
|
461
486
|
)
|
462
487
|
}
|
@@ -464,19 +489,19 @@ function Ke({
|
|
464
489
|
}
|
465
490
|
),
|
466
491
|
/* @__PURE__ */ e(
|
467
|
-
|
492
|
+
d,
|
468
493
|
{
|
469
494
|
align: "center",
|
470
495
|
children: /* @__PURE__ */ e(
|
471
|
-
|
496
|
+
V,
|
472
497
|
{
|
473
498
|
title: "Delete data in any collection",
|
474
499
|
children: /* @__PURE__ */ e(
|
475
|
-
|
500
|
+
I,
|
476
501
|
{
|
477
502
|
disabled: u || !n,
|
478
|
-
checked: (u ||
|
479
|
-
onCheckedChange: (o) =>
|
503
|
+
checked: (u || T) ?? !1,
|
504
|
+
onCheckedChange: (o) => b("defaultPermissions.delete", o)
|
480
505
|
}
|
481
506
|
)
|
482
507
|
}
|
@@ -484,66 +509,66 @@ function Ke({
|
|
484
509
|
}
|
485
510
|
)
|
486
511
|
] }),
|
487
|
-
|
512
|
+
i && i.map((o) => /* @__PURE__ */ s(W, { children: [
|
488
513
|
/* @__PURE__ */ e(
|
489
|
-
|
514
|
+
d,
|
490
515
|
{
|
491
516
|
scope: "row",
|
492
517
|
children: o.name
|
493
518
|
}
|
494
519
|
),
|
495
520
|
/* @__PURE__ */ e(
|
496
|
-
|
521
|
+
d,
|
497
522
|
{
|
498
523
|
align: "center",
|
499
524
|
children: /* @__PURE__ */ e(
|
500
|
-
|
525
|
+
I,
|
501
526
|
{
|
502
527
|
disabled: u || h || !n,
|
503
|
-
checked: (u || h ||
|
504
|
-
onCheckedChange: (
|
528
|
+
checked: (u || h || J(a, `collectionPermissions.${o.path}.create`)) ?? !1,
|
529
|
+
onCheckedChange: (E) => b(`collectionPermissions.${o.path}.create`, E)
|
505
530
|
}
|
506
531
|
)
|
507
532
|
}
|
508
533
|
),
|
509
534
|
/* @__PURE__ */ e(
|
510
|
-
|
535
|
+
d,
|
511
536
|
{
|
512
537
|
align: "center",
|
513
538
|
children: /* @__PURE__ */ e(
|
514
|
-
|
539
|
+
I,
|
515
540
|
{
|
516
541
|
disabled: u || x || !n,
|
517
|
-
checked: (u || x ||
|
518
|
-
onCheckedChange: (
|
542
|
+
checked: (u || x || J(a, `collectionPermissions.${o.path}.read`)) ?? !1,
|
543
|
+
onCheckedChange: (E) => b(`collectionPermissions.${o.path}.read`, E)
|
519
544
|
}
|
520
545
|
)
|
521
546
|
}
|
522
547
|
),
|
523
548
|
/* @__PURE__ */ e(
|
524
|
-
|
549
|
+
d,
|
525
550
|
{
|
526
551
|
align: "center",
|
527
552
|
children: /* @__PURE__ */ e(
|
528
|
-
|
553
|
+
I,
|
529
554
|
{
|
530
|
-
disabled: u ||
|
531
|
-
checked: (u ||
|
532
|
-
onCheckedChange: (
|
555
|
+
disabled: u || D || !n,
|
556
|
+
checked: (u || D || J(a, `collectionPermissions.${o.path}.edit`)) ?? !1,
|
557
|
+
onCheckedChange: (E) => b(`collectionPermissions.${o.path}.edit`, E)
|
533
558
|
}
|
534
559
|
)
|
535
560
|
}
|
536
561
|
),
|
537
562
|
/* @__PURE__ */ e(
|
538
|
-
|
563
|
+
d,
|
539
564
|
{
|
540
565
|
align: "center",
|
541
566
|
children: /* @__PURE__ */ e(
|
542
|
-
|
567
|
+
I,
|
543
568
|
{
|
544
|
-
disabled: u ||
|
545
|
-
checked: (u ||
|
546
|
-
onCheckedChange: (
|
569
|
+
disabled: u || T || !n,
|
570
|
+
checked: (u || T || J(a, `collectionPermissions.${o.path}.delete`)) ?? !1,
|
571
|
+
onCheckedChange: (E) => b(`collectionPermissions.${o.path}.delete`, E)
|
547
572
|
}
|
548
573
|
)
|
549
574
|
}
|
@@ -559,25 +584,25 @@ function Ke({
|
|
559
584
|
/* @__PURE__ */ s(
|
560
585
|
ne,
|
561
586
|
{
|
562
|
-
error:
|
587
|
+
error: U.config && !!C.config,
|
563
588
|
id: "createCollections",
|
564
589
|
name: "createCollections",
|
565
590
|
label: "Create collections",
|
566
591
|
position: "item-aligned",
|
567
592
|
disabled: u || !n,
|
568
|
-
onChange: (o) =>
|
569
|
-
value: u ||
|
593
|
+
onChange: (o) => b("config.createCollections", o.target.value === "true"),
|
594
|
+
value: u || a.config?.createCollections ? "true" : "false",
|
570
595
|
renderValue: (o) => o === "true" ? "Yes" : "No",
|
571
596
|
children: [
|
572
597
|
/* @__PURE__ */ e(
|
573
|
-
|
598
|
+
L,
|
574
599
|
{
|
575
600
|
value: "true",
|
576
601
|
children: " Yes "
|
577
602
|
}
|
578
603
|
),
|
579
604
|
/* @__PURE__ */ e(
|
580
|
-
|
605
|
+
L,
|
581
606
|
{
|
582
607
|
value: "false",
|
583
608
|
children: " No "
|
@@ -586,38 +611,38 @@ function Ke({
|
|
586
611
|
]
|
587
612
|
}
|
588
613
|
),
|
589
|
-
/* @__PURE__ */ e(B, { children:
|
614
|
+
/* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user create collections" })
|
590
615
|
] }),
|
591
616
|
/* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
|
592
617
|
/* @__PURE__ */ s(
|
593
618
|
ne,
|
594
619
|
{
|
595
|
-
error:
|
620
|
+
error: U.config && !!C.config,
|
596
621
|
id: "editCollections",
|
597
622
|
name: "editCollections",
|
598
623
|
label: "Edit collections",
|
599
624
|
disabled: u || !n,
|
600
625
|
position: "item-aligned",
|
601
|
-
onChange: (o) =>
|
602
|
-
value: u ? "true" :
|
626
|
+
onChange: (o) => b("config.editCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
|
627
|
+
value: u ? "true" : a.config?.editCollections === "own" ? "own" : a.config?.editCollections ? "true" : "false",
|
603
628
|
renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
|
604
629
|
children: [
|
605
630
|
/* @__PURE__ */ e(
|
606
|
-
|
631
|
+
L,
|
607
632
|
{
|
608
633
|
value: "true",
|
609
634
|
children: " Yes "
|
610
635
|
}
|
611
636
|
),
|
612
637
|
/* @__PURE__ */ e(
|
613
|
-
|
638
|
+
L,
|
614
639
|
{
|
615
640
|
value: "false",
|
616
641
|
children: " No "
|
617
642
|
}
|
618
643
|
),
|
619
644
|
/* @__PURE__ */ e(
|
620
|
-
|
645
|
+
L,
|
621
646
|
{
|
622
647
|
value: "own",
|
623
648
|
children: " Only his/her own "
|
@@ -626,38 +651,38 @@ function Ke({
|
|
626
651
|
]
|
627
652
|
}
|
628
653
|
),
|
629
|
-
/* @__PURE__ */ e(B, { children:
|
654
|
+
/* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user edit collections" })
|
630
655
|
] }),
|
631
656
|
/* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
|
632
657
|
/* @__PURE__ */ s(
|
633
658
|
ne,
|
634
659
|
{
|
635
|
-
error:
|
660
|
+
error: U.config && !!C.config,
|
636
661
|
id: "deleteCollections",
|
637
662
|
name: "deleteCollections",
|
638
663
|
label: "Delete collections",
|
639
664
|
disabled: u || !n,
|
640
665
|
position: "item-aligned",
|
641
|
-
onChange: (o) =>
|
642
|
-
value: u ? "true" :
|
666
|
+
onChange: (o) => b("config.deleteCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
|
667
|
+
value: u ? "true" : a.config?.deleteCollections === "own" ? "own" : a.config?.deleteCollections ? "true" : "false",
|
643
668
|
renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
|
644
669
|
children: [
|
645
670
|
/* @__PURE__ */ e(
|
646
|
-
|
671
|
+
L,
|
647
672
|
{
|
648
673
|
value: "true",
|
649
674
|
children: " Yes "
|
650
675
|
}
|
651
676
|
),
|
652
677
|
/* @__PURE__ */ e(
|
653
|
-
|
678
|
+
L,
|
654
679
|
{
|
655
680
|
value: "false",
|
656
681
|
children: " No "
|
657
682
|
}
|
658
683
|
),
|
659
684
|
/* @__PURE__ */ e(
|
660
|
-
|
685
|
+
L,
|
661
686
|
{
|
662
687
|
value: "own",
|
663
688
|
children: " Only his/her own "
|
@@ -666,31 +691,31 @@ function Ke({
|
|
666
691
|
]
|
667
692
|
}
|
668
693
|
),
|
669
|
-
/* @__PURE__ */ e(B, { children:
|
694
|
+
/* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user delete collections" })
|
670
695
|
] })
|
671
696
|
] })
|
672
697
|
] }),
|
673
|
-
/* @__PURE__ */ s(
|
674
|
-
|
698
|
+
/* @__PURE__ */ s(Ce, { position: "sticky", children: [
|
699
|
+
v && /* @__PURE__ */ e(A, { className: "text-red-500", children: "There was an error saving this role" }),
|
675
700
|
/* @__PURE__ */ e(
|
676
|
-
|
701
|
+
O,
|
677
702
|
{
|
678
703
|
variant: "text",
|
679
704
|
onClick: () => {
|
680
|
-
|
705
|
+
l();
|
681
706
|
},
|
682
707
|
children: "Cancel"
|
683
708
|
}
|
684
709
|
),
|
685
710
|
/* @__PURE__ */ e(
|
686
|
-
|
711
|
+
ve,
|
687
712
|
{
|
688
713
|
variant: "filled",
|
689
714
|
color: "primary",
|
690
715
|
type: "submit",
|
691
|
-
disabled: !
|
692
|
-
loading:
|
693
|
-
startIcon: /* @__PURE__ */ e(
|
716
|
+
disabled: !_,
|
717
|
+
loading: S,
|
718
|
+
startIcon: /* @__PURE__ */ e(we, {}),
|
694
719
|
children: f ? "Create role" : "Update"
|
695
720
|
}
|
696
721
|
)
|
@@ -701,7 +726,7 @@ function Ke({
|
|
701
726
|
}
|
702
727
|
);
|
703
728
|
}
|
704
|
-
const
|
729
|
+
const Se = [
|
705
730
|
{
|
706
731
|
id: "admin",
|
707
732
|
name: "Admin",
|
@@ -737,67 +762,67 @@ const Qe = [
|
|
737
762
|
];
|
738
763
|
function Xe({
|
739
764
|
onRoleClicked: t,
|
740
|
-
editable:
|
765
|
+
editable: r
|
741
766
|
}) {
|
742
767
|
const {
|
743
768
|
roles: n,
|
744
|
-
saveRole:
|
745
|
-
deleteRole:
|
769
|
+
saveRole: l,
|
770
|
+
deleteRole: i,
|
746
771
|
allowDefaultRolesCreation: m
|
747
|
-
} =
|
772
|
+
} = j(), [f, v] = P(void 0), [R, w] = P(!1);
|
748
773
|
return /* @__PURE__ */ s(
|
749
774
|
"div",
|
750
775
|
{
|
751
776
|
className: "w-full overflow-auto",
|
752
777
|
children: [
|
753
|
-
/* @__PURE__ */ s(
|
754
|
-
/* @__PURE__ */ s(
|
755
|
-
/* @__PURE__ */ e(
|
756
|
-
/* @__PURE__ */ e(
|
757
|
-
/* @__PURE__ */ e(
|
758
|
-
/* @__PURE__ */ e(
|
778
|
+
/* @__PURE__ */ s(re, { children: [
|
779
|
+
/* @__PURE__ */ s(ie, { children: [
|
780
|
+
/* @__PURE__ */ e(d, { header: !0, className: "w-16" }),
|
781
|
+
/* @__PURE__ */ e(d, { header: !0, children: "Role" }),
|
782
|
+
/* @__PURE__ */ e(d, { header: !0, className: "items-center", children: "Is Admin" }),
|
783
|
+
/* @__PURE__ */ e(d, { header: !0, children: "Default permissions" })
|
759
784
|
] }),
|
760
785
|
/* @__PURE__ */ s(oe, { children: [
|
761
786
|
n && n.map((c) => {
|
762
|
-
const
|
787
|
+
const S = c.isAdmin || c.defaultPermissions?.create, U = c.isAdmin || c.defaultPermissions?.read, a = c.isAdmin || c.defaultPermissions?.edit, C = c.isAdmin || c.defaultPermissions?.delete;
|
763
788
|
return /* @__PURE__ */ s(
|
764
|
-
|
789
|
+
W,
|
765
790
|
{
|
766
791
|
onClick: () => {
|
767
792
|
t(c);
|
768
793
|
},
|
769
794
|
children: [
|
770
|
-
/* @__PURE__ */ e(
|
771
|
-
|
795
|
+
/* @__PURE__ */ e(d, { style: { width: "64px" }, children: !c.isAdmin && /* @__PURE__ */ e(V, { title: "Delete this role", children: /* @__PURE__ */ e(
|
796
|
+
ye,
|
772
797
|
{
|
773
798
|
size: "small",
|
774
|
-
disabled: !
|
775
|
-
onClick: (
|
776
|
-
children: /* @__PURE__ */ e(
|
799
|
+
disabled: !r,
|
800
|
+
onClick: (y) => (y.stopPropagation(), v(c)),
|
801
|
+
children: /* @__PURE__ */ e(be, {})
|
777
802
|
}
|
778
803
|
) }) }),
|
779
|
-
/* @__PURE__ */ e(
|
780
|
-
/* @__PURE__ */ e(
|
781
|
-
/* @__PURE__ */ e(
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
804
|
+
/* @__PURE__ */ e(d, { children: /* @__PURE__ */ e(X, { role: c }) }),
|
805
|
+
/* @__PURE__ */ e(d, { className: "items-center", children: /* @__PURE__ */ e(I, { checked: c.isAdmin ?? !1 }) }),
|
806
|
+
/* @__PURE__ */ e(d, { children: /* @__PURE__ */ s("ul", { children: [
|
807
|
+
S && /* @__PURE__ */ e("li", { children: "Create" }),
|
808
|
+
U && /* @__PURE__ */ e("li", { children: "Read" }),
|
809
|
+
a && /* @__PURE__ */ e("li", { children: "Update" }),
|
810
|
+
C && /* @__PURE__ */ e("li", { children: "Delete" })
|
786
811
|
] }) })
|
787
812
|
]
|
788
813
|
},
|
789
814
|
c.name
|
790
815
|
);
|
791
816
|
}),
|
792
|
-
(!n || n.length === 0) && /* @__PURE__ */ e(
|
793
|
-
/* @__PURE__ */ e(
|
817
|
+
(!n || n.length === 0) && /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(d, { colspan: 4, children: /* @__PURE__ */ s(Ne, { className: "flex flex-col gap-4 my-8 items-center", children: [
|
818
|
+
/* @__PURE__ */ e(A, { variant: "label", children: "You don't have any roles yet." }),
|
794
819
|
m && /* @__PURE__ */ e(
|
795
|
-
|
820
|
+
O,
|
796
821
|
{
|
797
822
|
variant: "outlined",
|
798
823
|
onClick: () => {
|
799
|
-
|
800
|
-
|
824
|
+
Se.forEach((c) => {
|
825
|
+
l(c);
|
801
826
|
});
|
802
827
|
},
|
803
828
|
children: "Create default roles"
|
@@ -807,38 +832,38 @@ function Xe({
|
|
807
832
|
] })
|
808
833
|
] }),
|
809
834
|
/* @__PURE__ */ e(
|
810
|
-
|
835
|
+
xe,
|
811
836
|
{
|
812
837
|
open: !!f,
|
813
|
-
loading:
|
838
|
+
loading: R,
|
814
839
|
onAccept: () => {
|
815
|
-
f && (
|
816
|
-
|
840
|
+
f && (w(!0), i(f).then(() => {
|
841
|
+
v(void 0);
|
817
842
|
}).finally(() => {
|
818
|
-
|
843
|
+
w(!1);
|
819
844
|
}));
|
820
845
|
},
|
821
846
|
onCancel: () => {
|
822
|
-
|
847
|
+
v(void 0);
|
823
848
|
},
|
824
|
-
title: /* @__PURE__ */ e(
|
825
|
-
body: /* @__PURE__ */ e(
|
849
|
+
title: /* @__PURE__ */ e(K, { children: "Delete?" }),
|
850
|
+
body: /* @__PURE__ */ e(K, { children: "Are you sure you want to delete this role?" })
|
826
851
|
}
|
827
852
|
)
|
828
853
|
]
|
829
854
|
}
|
830
855
|
);
|
831
856
|
}
|
832
|
-
const Ze =
|
833
|
-
function({ children:
|
834
|
-
const { collections: n } =
|
835
|
-
|
857
|
+
const Ze = F.memo(
|
858
|
+
function({ children: r }) {
|
859
|
+
const { collections: n } = _e(), [l, i] = P(!1), [m, f] = P(), { canEditRoles: v } = j(), R = k((c) => {
|
860
|
+
i(!0), f(c);
|
836
861
|
}, []);
|
837
|
-
return /* @__PURE__ */ s(
|
838
|
-
|
862
|
+
return /* @__PURE__ */ s(Ue, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
|
863
|
+
r,
|
839
864
|
/* @__PURE__ */ s("div", { className: "flex items-center mt-12", children: [
|
840
865
|
/* @__PURE__ */ e(
|
841
|
-
|
866
|
+
A,
|
842
867
|
{
|
843
868
|
gutterBottom: !0,
|
844
869
|
variant: "h4",
|
@@ -847,99 +872,100 @@ const Ze = A.memo(
|
|
847
872
|
children: "Roles"
|
848
873
|
}
|
849
874
|
),
|
850
|
-
/* @__PURE__ */ e(
|
851
|
-
|
875
|
+
/* @__PURE__ */ e(V, { title: v ? void 0 : "Update plans to customise roles", children: /* @__PURE__ */ e(
|
876
|
+
O,
|
852
877
|
{
|
853
878
|
size: "large",
|
854
|
-
disabled: !
|
855
|
-
startIcon: /* @__PURE__ */ e(
|
856
|
-
onClick: () =>
|
879
|
+
disabled: !v,
|
880
|
+
startIcon: /* @__PURE__ */ e(le, {}),
|
881
|
+
onClick: () => i(!0),
|
857
882
|
children: "Add role"
|
858
883
|
}
|
859
884
|
) })
|
860
885
|
] }),
|
861
|
-
/* @__PURE__ */ e(Xe, { onRoleClicked:
|
886
|
+
/* @__PURE__ */ e(Xe, { onRoleClicked: R, editable: !!v }),
|
862
887
|
/* @__PURE__ */ e(
|
863
|
-
|
888
|
+
Qe,
|
864
889
|
{
|
865
|
-
open:
|
890
|
+
open: l,
|
866
891
|
role: m,
|
867
|
-
editable:
|
892
|
+
editable: v,
|
868
893
|
collections: n,
|
869
894
|
handleClose: () => {
|
870
|
-
f(void 0),
|
895
|
+
f(void 0), i(!1);
|
871
896
|
}
|
872
897
|
},
|
873
898
|
m?.id ?? "new"
|
874
899
|
)
|
875
900
|
] });
|
876
901
|
}
|
877
|
-
), en =
|
878
|
-
displayName:
|
879
|
-
email:
|
880
|
-
roles:
|
902
|
+
), en = M.object().shape({
|
903
|
+
displayName: M.string().required("Required"),
|
904
|
+
email: M.string().email().required("Required"),
|
905
|
+
roles: M.array().min(1)
|
881
906
|
});
|
882
|
-
function nn(t,
|
883
|
-
const m = n.filter((
|
884
|
-
if ((!
|
907
|
+
function nn(t, r, n, l, i) {
|
908
|
+
const m = n.filter((w) => w.roles?.map((c) => c.id).includes("admin")), f = t.roles?.map((w) => w.id).includes("admin");
|
909
|
+
if ((!i || !je(i.roles ?? [], r.roles ?? [])) && !f)
|
885
910
|
throw new Error("Only admins can change roles");
|
886
|
-
if (
|
911
|
+
if (i && i.roles?.map((w) => w.id).includes("admin") && !r.roles?.map((w) => w.id).includes("admin") && m.length === 1)
|
887
912
|
throw new Error("There must be at least one admin");
|
888
913
|
return !0;
|
889
914
|
}
|
890
915
|
function tn({
|
891
916
|
open: t,
|
892
|
-
user:
|
917
|
+
user: r,
|
893
918
|
handleClose: n
|
894
919
|
}) {
|
895
|
-
const
|
896
|
-
|
920
|
+
const l = se(), {
|
921
|
+
user: i
|
922
|
+
} = ae(), {
|
897
923
|
saveUser: m,
|
898
924
|
users: f,
|
899
|
-
roles:
|
900
|
-
} =
|
901
|
-
if (!
|
925
|
+
roles: v
|
926
|
+
} = j(), R = !r, w = k((h) => {
|
927
|
+
if (!i)
|
902
928
|
throw new Error("Logged user not found");
|
903
929
|
try {
|
904
|
-
return nn(
|
930
|
+
return nn(i, h, f, v, r), m(h);
|
905
931
|
} catch (x) {
|
906
932
|
return Promise.reject(x);
|
907
933
|
}
|
908
|
-
}, [
|
909
|
-
initialValues:
|
934
|
+
}, [v, m, r, f, i]), c = Re({
|
935
|
+
initialValues: r ?? {
|
910
936
|
displayName: "",
|
911
937
|
email: "",
|
912
|
-
roles:
|
938
|
+
roles: v.filter((h) => h.id === "editor")
|
913
939
|
},
|
914
|
-
validation: (h) => en.validate(h, { abortEarly: !1 }).then(() => ({})).catch((x) => x.inner.reduce((
|
915
|
-
onSubmit: (h, x) =>
|
940
|
+
validation: (h) => en.validate(h, { abortEarly: !1 }).then(() => ({})).catch((x) => x.inner.reduce((D, T) => (D[T.path] = T.message, D), {})),
|
941
|
+
onSubmit: (h, x) => w(h).then(() => {
|
916
942
|
n(), x.resetForm({
|
917
943
|
values: h
|
918
944
|
});
|
919
|
-
}).catch((
|
920
|
-
|
945
|
+
}).catch((D) => {
|
946
|
+
l.open({
|
921
947
|
type: "error",
|
922
|
-
message:
|
948
|
+
message: D.message
|
923
949
|
});
|
924
950
|
})
|
925
951
|
}), {
|
926
|
-
isSubmitting:
|
927
|
-
touched:
|
928
|
-
handleChange:
|
929
|
-
values:
|
930
|
-
errors:
|
931
|
-
setFieldValue:
|
932
|
-
dirty:
|
952
|
+
isSubmitting: S,
|
953
|
+
touched: U,
|
954
|
+
handleChange: a,
|
955
|
+
values: C,
|
956
|
+
errors: y,
|
957
|
+
setFieldValue: b,
|
958
|
+
dirty: _,
|
933
959
|
handleSubmit: z,
|
934
960
|
submitCount: u
|
935
961
|
} = c;
|
936
962
|
return /* @__PURE__ */ e(
|
937
|
-
|
963
|
+
fe,
|
938
964
|
{
|
939
965
|
open: t,
|
940
966
|
onOpenChange: (h) => h ? void 0 : n(),
|
941
967
|
maxWidth: "4xl",
|
942
|
-
children: /* @__PURE__ */ e(
|
968
|
+
children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ s(
|
943
969
|
"form",
|
944
970
|
{
|
945
971
|
onSubmit: z,
|
@@ -952,13 +978,13 @@ function tn({
|
|
952
978
|
height: "100%"
|
953
979
|
},
|
954
980
|
children: [
|
955
|
-
/* @__PURE__ */ s(
|
981
|
+
/* @__PURE__ */ s(ge, { className: "h-full flex-grow", children: [
|
956
982
|
/* @__PURE__ */ e(
|
957
983
|
"div",
|
958
984
|
{
|
959
985
|
className: "flex flex-row pt-4 pb-4",
|
960
986
|
children: /* @__PURE__ */ e(
|
961
|
-
|
987
|
+
A,
|
962
988
|
{
|
963
989
|
variant: "h4",
|
964
990
|
className: "flex-grow",
|
@@ -970,49 +996,49 @@ function tn({
|
|
970
996
|
/* @__PURE__ */ s("div", { className: "grid grid-cols-12 gap-8", children: [
|
971
997
|
/* @__PURE__ */ s("div", { className: "col-span-12", children: [
|
972
998
|
/* @__PURE__ */ e(
|
973
|
-
|
999
|
+
Q,
|
974
1000
|
{
|
975
1001
|
name: "displayName",
|
976
1002
|
required: !0,
|
977
|
-
error: u > 0 && !!
|
978
|
-
value:
|
979
|
-
onChange:
|
1003
|
+
error: u > 0 && !!y.displayName,
|
1004
|
+
value: C.displayName ?? "",
|
1005
|
+
onChange: a,
|
980
1006
|
"aria-describedby": "name-helper-text",
|
981
1007
|
label: "Name"
|
982
1008
|
}
|
983
1009
|
),
|
984
|
-
/* @__PURE__ */ e(B, { children: u > 0 &&
|
1010
|
+
/* @__PURE__ */ e(B, { children: u > 0 && y.displayName ? y.displayName : "Name of this user" })
|
985
1011
|
] }),
|
986
1012
|
/* @__PURE__ */ s("div", { className: "col-span-12", children: [
|
987
1013
|
/* @__PURE__ */ e(
|
988
|
-
|
1014
|
+
Q,
|
989
1015
|
{
|
990
1016
|
required: !0,
|
991
|
-
error: u > 0 && !!
|
1017
|
+
error: u > 0 && !!y.email,
|
992
1018
|
name: "email",
|
993
|
-
value:
|
994
|
-
onChange:
|
1019
|
+
value: C.email ?? "",
|
1020
|
+
onChange: a,
|
995
1021
|
"aria-describedby": "email-helper-text",
|
996
1022
|
label: "Email"
|
997
1023
|
}
|
998
1024
|
),
|
999
|
-
/* @__PURE__ */ e(B, { children: u > 0 &&
|
1025
|
+
/* @__PURE__ */ e(B, { children: u > 0 && y.email ? y.email : "Email of this user" })
|
1000
1026
|
] }),
|
1001
1027
|
/* @__PURE__ */ e("div", { className: "col-span-12", children: /* @__PURE__ */ e(
|
1002
|
-
|
1028
|
+
Te,
|
1003
1029
|
{
|
1004
1030
|
label: "Roles",
|
1005
|
-
value:
|
1006
|
-
onMultiValueChange: (h) =>
|
1031
|
+
value: C.roles?.map((h) => h.id) ?? [],
|
1032
|
+
onMultiValueChange: (h) => b("roles", h.map((x) => v.find((D) => D.id === x))),
|
1007
1033
|
renderValue: (h) => {
|
1008
|
-
const x =
|
1009
|
-
return x ? /* @__PURE__ */ e("div", { className: "flex flex-wrap space-x-2 space-y-2", children: /* @__PURE__ */ e(
|
1034
|
+
const x = v.find((D) => D.id === h);
|
1035
|
+
return x ? /* @__PURE__ */ e("div", { className: "flex flex-wrap space-x-2 space-y-2", children: /* @__PURE__ */ e(X, { role: x }, x?.id) }) : null;
|
1010
1036
|
},
|
1011
|
-
children:
|
1012
|
-
|
1037
|
+
children: v.map((h) => /* @__PURE__ */ e(
|
1038
|
+
Le,
|
1013
1039
|
{
|
1014
1040
|
value: h.id,
|
1015
|
-
children: /* @__PURE__ */ e(
|
1041
|
+
children: /* @__PURE__ */ e(X, { role: h }, h?.id)
|
1016
1042
|
},
|
1017
1043
|
h.id
|
1018
1044
|
))
|
@@ -1020,9 +1046,9 @@ function tn({
|
|
1020
1046
|
) })
|
1021
1047
|
] })
|
1022
1048
|
] }),
|
1023
|
-
/* @__PURE__ */ s(
|
1049
|
+
/* @__PURE__ */ s(Ce, { children: [
|
1024
1050
|
/* @__PURE__ */ e(
|
1025
|
-
|
1051
|
+
O,
|
1026
1052
|
{
|
1027
1053
|
variant: "text",
|
1028
1054
|
onClick: () => {
|
@@ -1032,15 +1058,15 @@ function tn({
|
|
1032
1058
|
}
|
1033
1059
|
),
|
1034
1060
|
/* @__PURE__ */ e(
|
1035
|
-
|
1061
|
+
ve,
|
1036
1062
|
{
|
1037
1063
|
variant: "filled",
|
1038
1064
|
color: "primary",
|
1039
1065
|
type: "submit",
|
1040
|
-
disabled: !
|
1041
|
-
loading:
|
1042
|
-
startIcon: /* @__PURE__ */ e(
|
1043
|
-
children:
|
1066
|
+
disabled: !_,
|
1067
|
+
loading: S,
|
1068
|
+
startIcon: /* @__PURE__ */ e(we, {}),
|
1069
|
+
children: R ? "Create user" : "Update"
|
1044
1070
|
}
|
1045
1071
|
)
|
1046
1072
|
] })
|
@@ -1052,66 +1078,66 @@ function tn({
|
|
1052
1078
|
}
|
1053
1079
|
function rn({ onUserClicked: t }) {
|
1054
1080
|
const {
|
1055
|
-
users:
|
1081
|
+
users: r,
|
1056
1082
|
saveUser: n,
|
1057
|
-
deleteUser:
|
1058
|
-
} =
|
1083
|
+
deleteUser: l
|
1084
|
+
} = j(), i = ae(), m = se(), f = Ve(), v = f?.locale ? $e[f?.locale] : void 0, R = f?.dateTimeFormat ?? Me, [w, c] = P(void 0), [S, U] = P(!1);
|
1059
1085
|
return /* @__PURE__ */ s("div", { className: "overflow-auto", children: [
|
1060
|
-
/* @__PURE__ */ s(
|
1061
|
-
/* @__PURE__ */ s(
|
1062
|
-
/* @__PURE__ */ e(
|
1063
|
-
/* @__PURE__ */ e(
|
1064
|
-
/* @__PURE__ */ e(
|
1065
|
-
/* @__PURE__ */ e(
|
1066
|
-
/* @__PURE__ */ e(
|
1067
|
-
/* @__PURE__ */ e(
|
1086
|
+
/* @__PURE__ */ s(re, { children: [
|
1087
|
+
/* @__PURE__ */ s(ie, { children: [
|
1088
|
+
/* @__PURE__ */ e(d, { className: "truncate w-16" }),
|
1089
|
+
/* @__PURE__ */ e(d, { children: "ID" }),
|
1090
|
+
/* @__PURE__ */ e(d, { children: "Email" }),
|
1091
|
+
/* @__PURE__ */ e(d, { children: "Name" }),
|
1092
|
+
/* @__PURE__ */ e(d, { children: "Roles" }),
|
1093
|
+
/* @__PURE__ */ e(d, { children: "Created on" })
|
1068
1094
|
] }),
|
1069
1095
|
/* @__PURE__ */ s(oe, { children: [
|
1070
|
-
|
1071
|
-
const
|
1096
|
+
r && r.map((a) => {
|
1097
|
+
const C = a.roles, y = a.created_on ? Oe(a.created_on, R, { locale: v }) : "";
|
1072
1098
|
return /* @__PURE__ */ s(
|
1073
|
-
|
1099
|
+
W,
|
1074
1100
|
{
|
1075
1101
|
onClick: () => {
|
1076
|
-
t(
|
1102
|
+
t(a);
|
1077
1103
|
},
|
1078
1104
|
children: [
|
1079
|
-
/* @__PURE__ */ e(
|
1080
|
-
|
1105
|
+
/* @__PURE__ */ e(d, { className: "w-10", children: /* @__PURE__ */ e(V, { title: "Delete this user", children: /* @__PURE__ */ e(
|
1106
|
+
ye,
|
1081
1107
|
{
|
1082
1108
|
size: "small",
|
1083
|
-
onClick: (
|
1084
|
-
children: /* @__PURE__ */ e(
|
1109
|
+
onClick: (b) => (b.stopPropagation(), c(a)),
|
1110
|
+
children: /* @__PURE__ */ e(be, {})
|
1085
1111
|
}
|
1086
1112
|
) }) }),
|
1087
|
-
/* @__PURE__ */ e(
|
1088
|
-
/* @__PURE__ */ e(
|
1089
|
-
/* @__PURE__ */ e(
|
1090
|
-
/* @__PURE__ */ e(
|
1091
|
-
(
|
1113
|
+
/* @__PURE__ */ e(d, { children: a.uid }),
|
1114
|
+
/* @__PURE__ */ e(d, { children: a.email }),
|
1115
|
+
/* @__PURE__ */ e(d, { className: "font-medium align-left", children: a.displayName }),
|
1116
|
+
/* @__PURE__ */ e(d, { className: "align-left", children: C ? /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: C.map(
|
1117
|
+
(b) => /* @__PURE__ */ e(X, { role: b }, b?.id)
|
1092
1118
|
) }) : null }),
|
1093
|
-
/* @__PURE__ */ e(
|
1119
|
+
/* @__PURE__ */ e(d, { children: y })
|
1094
1120
|
]
|
1095
1121
|
},
|
1096
|
-
"row_" +
|
1122
|
+
"row_" + a.uid
|
1097
1123
|
);
|
1098
1124
|
}),
|
1099
|
-
(!
|
1100
|
-
/* @__PURE__ */ e(
|
1125
|
+
(!r || r.length === 0) && /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(d, { colspan: 6, children: /* @__PURE__ */ s(Ne, { className: "flex flex-col gap-4 my-8 items-center", children: [
|
1126
|
+
/* @__PURE__ */ e(A, { variant: "label", children: "There are no users yet" }),
|
1101
1127
|
/* @__PURE__ */ e(
|
1102
|
-
|
1128
|
+
O,
|
1103
1129
|
{
|
1104
1130
|
variant: "outlined",
|
1105
1131
|
onClick: () => {
|
1106
|
-
if (!
|
1132
|
+
if (!i.user?.uid)
|
1107
1133
|
throw Error("UsersTable, authController misconfiguration");
|
1108
1134
|
n({
|
1109
|
-
uid:
|
1110
|
-
email:
|
1111
|
-
displayName:
|
1112
|
-
photoURL:
|
1113
|
-
providerId:
|
1114
|
-
isAnonymous:
|
1135
|
+
uid: i.user?.uid,
|
1136
|
+
email: i.user?.email,
|
1137
|
+
displayName: i.user?.displayName,
|
1138
|
+
photoURL: i.user?.photoURL,
|
1139
|
+
providerId: i.user?.providerId,
|
1140
|
+
isAnonymous: i.user?.isAnonymous,
|
1115
1141
|
roles: [{ id: "admin", name: "Admin" }],
|
1116
1142
|
created_on: /* @__PURE__ */ new Date()
|
1117
1143
|
}).then(() => {
|
@@ -1119,10 +1145,10 @@ function rn({ onUserClicked: t }) {
|
|
1119
1145
|
type: "success",
|
1120
1146
|
message: "User added successfully"
|
1121
1147
|
});
|
1122
|
-
}).catch((
|
1148
|
+
}).catch((a) => {
|
1123
1149
|
m.open({
|
1124
1150
|
type: "error",
|
1125
|
-
message: "Error adding user: " +
|
1151
|
+
message: "Error adding user: " + a.message
|
1126
1152
|
});
|
1127
1153
|
});
|
1128
1154
|
},
|
@@ -1133,46 +1159,46 @@ function rn({ onUserClicked: t }) {
|
|
1133
1159
|
] })
|
1134
1160
|
] }),
|
1135
1161
|
/* @__PURE__ */ e(
|
1136
|
-
|
1162
|
+
xe,
|
1137
1163
|
{
|
1138
|
-
open: !!
|
1139
|
-
loading:
|
1164
|
+
open: !!w,
|
1165
|
+
loading: S,
|
1140
1166
|
onAccept: () => {
|
1141
|
-
|
1167
|
+
w && (U(!0), l(w).then(() => {
|
1142
1168
|
c(void 0);
|
1143
|
-
}).catch((
|
1169
|
+
}).catch((a) => {
|
1144
1170
|
m.open({
|
1145
1171
|
type: "error",
|
1146
|
-
message: "Error deleting user: " +
|
1172
|
+
message: "Error deleting user: " + a.message
|
1147
1173
|
});
|
1148
1174
|
}).finally(() => {
|
1149
|
-
|
1175
|
+
U(!1);
|
1150
1176
|
}));
|
1151
1177
|
},
|
1152
1178
|
onCancel: () => {
|
1153
1179
|
c(void 0);
|
1154
1180
|
},
|
1155
|
-
title: /* @__PURE__ */ e(
|
1156
|
-
body: /* @__PURE__ */ e(
|
1181
|
+
title: /* @__PURE__ */ e(K, { children: "Delete?" }),
|
1182
|
+
body: /* @__PURE__ */ e(K, { children: "Are you sure you want to delete this user?" })
|
1157
1183
|
}
|
1158
1184
|
)
|
1159
1185
|
] });
|
1160
1186
|
}
|
1161
|
-
const on = function({ children:
|
1162
|
-
const [n,
|
1163
|
-
m(
|
1164
|
-
}, []), c =
|
1165
|
-
|
1187
|
+
const on = function({ children: r }) {
|
1188
|
+
const [n, l] = P(), [i, m] = P(), { users: f, usersLimit: v } = j(), R = v !== void 0 && f && f.length >= v, w = k((S) => {
|
1189
|
+
m(S), l(!0);
|
1190
|
+
}, []), c = k(() => {
|
1191
|
+
l(!1), m(void 0);
|
1166
1192
|
}, []);
|
1167
|
-
return /* @__PURE__ */ s(
|
1168
|
-
|
1193
|
+
return /* @__PURE__ */ s(Ue, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
|
1194
|
+
r,
|
1169
1195
|
/* @__PURE__ */ s(
|
1170
1196
|
"div",
|
1171
1197
|
{
|
1172
1198
|
className: "flex items-center mt-12",
|
1173
1199
|
children: [
|
1174
1200
|
/* @__PURE__ */ e(
|
1175
|
-
|
1201
|
+
A,
|
1176
1202
|
{
|
1177
1203
|
gutterBottom: !0,
|
1178
1204
|
variant: "h4",
|
@@ -1182,43 +1208,103 @@ const on = function({ children: i }) {
|
|
1182
1208
|
}
|
1183
1209
|
),
|
1184
1210
|
/* @__PURE__ */ e(
|
1185
|
-
|
1211
|
+
O,
|
1186
1212
|
{
|
1187
1213
|
size: "large",
|
1188
|
-
disabled:
|
1189
|
-
startIcon: /* @__PURE__ */ e(
|
1190
|
-
onClick: () =>
|
1214
|
+
disabled: R,
|
1215
|
+
startIcon: /* @__PURE__ */ e(le, {}),
|
1216
|
+
onClick: () => l(!0),
|
1191
1217
|
children: "Add user"
|
1192
1218
|
}
|
1193
1219
|
)
|
1194
1220
|
]
|
1195
1221
|
}
|
1196
1222
|
),
|
1197
|
-
/* @__PURE__ */ e(rn, { onUserClicked:
|
1223
|
+
/* @__PURE__ */ e(rn, { onUserClicked: w }),
|
1198
1224
|
/* @__PURE__ */ e(
|
1199
1225
|
tn,
|
1200
1226
|
{
|
1201
1227
|
open: n ?? !1,
|
1202
|
-
user:
|
1228
|
+
user: i,
|
1203
1229
|
handleClose: c
|
1204
1230
|
},
|
1205
|
-
|
1231
|
+
i?.uid ?? "new"
|
1206
1232
|
)
|
1207
1233
|
] });
|
1208
1234
|
};
|
1209
|
-
function
|
1235
|
+
function Nn({ userManagement: t }) {
|
1236
|
+
const r = t.users.length === 0, n = t.roles.length === 0;
|
1210
1237
|
return {
|
1211
|
-
|
1238
|
+
key: "user_management",
|
1212
1239
|
loading: t.loading,
|
1240
|
+
homePage: {
|
1241
|
+
additionalChildrenStart: r || n ? /* @__PURE__ */ e(
|
1242
|
+
ln,
|
1243
|
+
{
|
1244
|
+
noUsers: r,
|
1245
|
+
noRoles: n,
|
1246
|
+
userManagement: t
|
1247
|
+
}
|
1248
|
+
) : void 0
|
1249
|
+
},
|
1213
1250
|
provider: {
|
1214
|
-
Component:
|
1251
|
+
Component: He,
|
1215
1252
|
props: {
|
1216
1253
|
userManagement: t
|
1217
1254
|
}
|
1218
1255
|
}
|
1219
1256
|
};
|
1220
1257
|
}
|
1221
|
-
|
1258
|
+
function ln({
|
1259
|
+
noUsers: t,
|
1260
|
+
noRoles: r,
|
1261
|
+
userManagement: n
|
1262
|
+
}) {
|
1263
|
+
const l = ae(), i = se();
|
1264
|
+
return /* @__PURE__ */ s(
|
1265
|
+
pe,
|
1266
|
+
{
|
1267
|
+
className: "my-4 flex flex-col px-4 py-6 bg-white dark:bg-slate-800 gap-2",
|
1268
|
+
children: [
|
1269
|
+
/* @__PURE__ */ e(A, { variant: "subtitle2", className: "uppercase", children: "Create your users and roles" }),
|
1270
|
+
/* @__PURE__ */ e(A, { children: "You have no users or roles defined. You can create default roles and add the current user as admin." }),
|
1271
|
+
/* @__PURE__ */ s(O, { onClick: () => {
|
1272
|
+
if (!l.user?.uid)
|
1273
|
+
throw Error("UsersTable, authController misconfiguration");
|
1274
|
+
t && n.saveUser({
|
1275
|
+
uid: l.user?.uid,
|
1276
|
+
email: l.user?.email,
|
1277
|
+
displayName: l.user?.displayName,
|
1278
|
+
photoURL: l.user?.photoURL,
|
1279
|
+
providerId: l.user?.providerId,
|
1280
|
+
isAnonymous: l.user?.isAnonymous,
|
1281
|
+
roles: [{
|
1282
|
+
id: "admin",
|
1283
|
+
name: "Admin"
|
1284
|
+
}],
|
1285
|
+
created_on: /* @__PURE__ */ new Date()
|
1286
|
+
}).then(() => {
|
1287
|
+
i.open({
|
1288
|
+
type: "success",
|
1289
|
+
message: "User added successfully"
|
1290
|
+
});
|
1291
|
+
}).catch((f) => {
|
1292
|
+
i.open({
|
1293
|
+
type: "error",
|
1294
|
+
message: "Error adding user: " + f.message
|
1295
|
+
});
|
1296
|
+
}), r && Se.forEach((f) => {
|
1297
|
+
n.saveRole(f);
|
1298
|
+
});
|
1299
|
+
}, children: [
|
1300
|
+
/* @__PURE__ */ e(le, {}),
|
1301
|
+
t && r ? "Create default roles and add current user as admin" : t ? "Add current user as admin" : r ? "Create default roles" : void 0
|
1302
|
+
] })
|
1303
|
+
]
|
1304
|
+
}
|
1305
|
+
);
|
1306
|
+
}
|
1307
|
+
const Un = [
|
1222
1308
|
{
|
1223
1309
|
path: "users",
|
1224
1310
|
name: "CMS Users",
|
@@ -1235,29 +1321,30 @@ const Nn = [
|
|
1235
1321
|
}
|
1236
1322
|
];
|
1237
1323
|
export {
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
Ke as
|
1324
|
+
ln as IntroWidget,
|
1325
|
+
fn as RESERVED_GROUPS,
|
1326
|
+
X as RoleChip,
|
1327
|
+
Ke as RoleYupSchema,
|
1328
|
+
Qe as RolesDetailsForm,
|
1242
1329
|
Xe as RolesTable,
|
1243
1330
|
Ze as RolesView,
|
1244
1331
|
tn as UserDetailsForm,
|
1245
|
-
|
1246
|
-
|
1332
|
+
Ee as UserManagementContext,
|
1333
|
+
He as UserManagementProvider,
|
1247
1334
|
en as UserYupSchema,
|
1248
1335
|
rn as UsersTable,
|
1249
1336
|
on as UsersView,
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1337
|
+
je as areRolesEqual,
|
1338
|
+
pn as cacheDelegatedLoginToken,
|
1339
|
+
vn as clearDelegatedLoginTokensCache,
|
1340
|
+
wn as darkenColor,
|
1341
|
+
Cn as getDelegatedLoginTokenFromCache,
|
1342
|
+
gn as getUserRoles,
|
1343
|
+
yn as hexToRgbaWithOpacity,
|
1344
|
+
Ye as resolveUserRolePermissions,
|
1345
|
+
bn as useFirestoreUserManagement,
|
1346
|
+
j as useUserManagement,
|
1347
|
+
Nn as useUserManagementPlugin,
|
1348
|
+
Un as userManagementAdminViews
|
1262
1349
|
};
|
1263
1350
|
//# sourceMappingURL=index.es.js.map
|