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