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