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