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