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