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