@firecms/user_management 3.0.0-beta.11 → 3.0.0-beta.12
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/hooks/useBuildUserManagement.d.ts +1 -11
- package/dist/index.es.js +57 -116
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +57 -116
- package/dist/index.umd.js.map +1 -1
- package/dist/types/user_management.d.ts +0 -8
- package/package.json +12 -12
- package/src/components/roles/RolesDetailsForm.tsx +0 -1
- package/src/components/roles/RolesView.tsx +9 -17
- package/src/components/users/UsersView.tsx +1 -4
- package/src/hooks/useBuildUserManagement.tsx +0 -16
- package/src/types/user_management.tsx +0 -10
@@ -19,14 +19,6 @@ export interface UserManagementParams<CONTROLLER extends AuthController<any> = A
|
|
19
19
|
* Default: __FIRECMS/config/roles
|
20
20
|
*/
|
21
21
|
rolesPath?: string;
|
22
|
-
/**
|
23
|
-
* Maximum number of users that can be created.
|
24
|
-
*/
|
25
|
-
usersLimit?: number;
|
26
|
-
/**
|
27
|
-
* Can the logged user edit roles
|
28
|
-
*/
|
29
|
-
canEditRoles?: boolean;
|
30
22
|
/**
|
31
23
|
* If there are no roles in the database, provide a button to create the default roles.
|
32
24
|
*/
|
@@ -43,9 +35,7 @@ export interface UserManagementParams<CONTROLLER extends AuthController<any> = A
|
|
43
35
|
* @param dataSourceDelegate
|
44
36
|
* @param usersPath
|
45
37
|
* @param rolesPath
|
46
|
-
* @param usersLimit
|
47
|
-
* @param canEditRoles
|
48
38
|
* @param allowDefaultRolesCreation
|
49
39
|
* @param includeCollectionConfigPermissions
|
50
40
|
*/
|
51
|
-
export declare function useBuildUserManagement<CONTROLLER extends AuthController<any> = AuthController<any>, USER extends User = CONTROLLER extends AuthController<infer U> ? U : any>({ authController, dataSourceDelegate, usersPath, rolesPath,
|
41
|
+
export declare function useBuildUserManagement<CONTROLLER extends AuthController<any> = AuthController<any>, USER extends User = CONTROLLER extends AuthController<infer U> ? U : any>({ authController, dataSourceDelegate, usersPath, rolesPath, allowDefaultRolesCreation, includeCollectionConfigPermissions }: UserManagementParams<CONTROLLER>): UserManagement<USER> & CONTROLLER;
|
package/dist/index.es.js
CHANGED
@@ -147,8 +147,6 @@ function useBuildUserManagement({
|
|
147
147
|
dataSourceDelegate,
|
148
148
|
usersPath = "__FIRECMS/config/users",
|
149
149
|
rolesPath = "__FIRECMS/config/roles",
|
150
|
-
usersLimit,
|
151
|
-
canEditRoles = true,
|
152
150
|
allowDefaultRolesCreation,
|
153
151
|
includeCollectionConfigPermissions
|
154
152
|
}) {
|
@@ -349,10 +347,8 @@ function useBuildUserManagement({
|
|
349
347
|
rolesError,
|
350
348
|
deleteUser,
|
351
349
|
deleteRole,
|
352
|
-
usersLimit,
|
353
350
|
usersError,
|
354
351
|
isAdmin,
|
355
|
-
canEditRoles: canEditRoles === void 0 ? true : canEditRoles,
|
356
352
|
allowDefaultRolesCreation: allowDefaultRolesCreation === void 0 ? true : allowDefaultRolesCreation,
|
357
353
|
includeCollectionConfigPermissions: Boolean(includeCollectionConfigPermissions),
|
358
354
|
collectionPermissions,
|
@@ -451,7 +447,6 @@ const RoleYupSchema = Yup.object().shape({
|
|
451
447
|
});
|
452
448
|
function canRoleBeEdited(loggedUser) {
|
453
449
|
const loggedUserIsAdmin = loggedUser.roles?.map((r) => r.id).includes("admin");
|
454
|
-
console.log("loggedUserIsAdmin", loggedUser);
|
455
450
|
if (!loggedUserIsAdmin) {
|
456
451
|
throw new Error("Only admins can edit roles");
|
457
452
|
}
|
@@ -1354,7 +1349,7 @@ function RolesTable(t0) {
|
|
1354
1349
|
return t11;
|
1355
1350
|
}
|
1356
1351
|
const RolesView = React.memo(function RolesView2(t0) {
|
1357
|
-
const $ = c(
|
1352
|
+
const $ = c(13);
|
1358
1353
|
const {
|
1359
1354
|
children
|
1360
1355
|
} = t0;
|
@@ -1363,9 +1358,6 @@ const RolesView = React.memo(function RolesView2(t0) {
|
|
1363
1358
|
} = useNavigationController();
|
1364
1359
|
const [dialogOpen, setDialogOpen] = useState(false);
|
1365
1360
|
const [selectedRole, setSelectedRole] = useState();
|
1366
|
-
const {
|
1367
|
-
canEditRoles
|
1368
|
-
} = useUserManagement();
|
1369
1361
|
let t1;
|
1370
1362
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
1371
1363
|
t1 = (user) => {
|
@@ -1395,78 +1387,47 @@ const RolesView = React.memo(function RolesView2(t0) {
|
|
1395
1387
|
} else {
|
1396
1388
|
t3 = $[2];
|
1397
1389
|
}
|
1398
|
-
|
1399
|
-
|
1400
|
-
let t6;
|
1401
|
-
let t7;
|
1390
|
+
let t4;
|
1391
|
+
let t5;
|
1402
1392
|
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
1403
|
-
|
1404
|
-
t7 = () => setDialogOpen(true);
|
1405
|
-
$[3] = t6;
|
1406
|
-
$[4] = t7;
|
1407
|
-
} else {
|
1408
|
-
t6 = $[3];
|
1409
|
-
t7 = $[4];
|
1410
|
-
}
|
1411
|
-
let t8;
|
1412
|
-
if ($[5] !== t5) {
|
1413
|
-
t8 = /* @__PURE__ */ jsx(Button, { size: "large", disabled: t5, startIcon: t6, onClick: t7, children: "Add role" });
|
1414
|
-
$[5] = t5;
|
1415
|
-
$[6] = t8;
|
1416
|
-
} else {
|
1417
|
-
t8 = $[6];
|
1418
|
-
}
|
1419
|
-
let t9;
|
1420
|
-
if ($[7] !== t4 || $[8] !== t8) {
|
1421
|
-
t9 = /* @__PURE__ */ jsxs("div", { className: "flex items-center mt-12", children: [
|
1393
|
+
t4 = /* @__PURE__ */ jsxs("div", { className: "flex items-center mt-12", children: [
|
1422
1394
|
t3,
|
1423
|
-
/* @__PURE__ */ jsx(
|
1395
|
+
/* @__PURE__ */ jsx(Button, { size: "large", startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: () => setDialogOpen(true), children: "Add role" })
|
1424
1396
|
] });
|
1425
|
-
|
1426
|
-
$[
|
1427
|
-
$[
|
1428
|
-
} else {
|
1429
|
-
t9 = $[9];
|
1430
|
-
}
|
1431
|
-
const t10 = Boolean(canEditRoles);
|
1432
|
-
let t11;
|
1433
|
-
if ($[10] !== t10) {
|
1434
|
-
t11 = /* @__PURE__ */ jsx(RolesTable, { onRoleClicked, editable: t10 });
|
1435
|
-
$[10] = t10;
|
1436
|
-
$[11] = t11;
|
1397
|
+
t5 = /* @__PURE__ */ jsx(RolesTable, { onRoleClicked, editable: true });
|
1398
|
+
$[3] = t4;
|
1399
|
+
$[4] = t5;
|
1437
1400
|
} else {
|
1438
|
-
|
1401
|
+
t4 = $[3];
|
1402
|
+
t5 = $[4];
|
1439
1403
|
}
|
1440
|
-
const
|
1441
|
-
let
|
1442
|
-
if ($[
|
1443
|
-
|
1444
|
-
$[
|
1445
|
-
$[
|
1446
|
-
$[
|
1447
|
-
$[
|
1448
|
-
$[
|
1449
|
-
$[17] = t13;
|
1404
|
+
const t6 = selectedRole?.id ?? "new";
|
1405
|
+
let t7;
|
1406
|
+
if ($[5] !== collections || $[6] !== dialogOpen || $[7] !== selectedRole || $[8] !== t6) {
|
1407
|
+
t7 = /* @__PURE__ */ jsx(RolesDetailsForm, { open: dialogOpen, role: selectedRole, editable: true, collections, handleClose }, t6);
|
1408
|
+
$[5] = collections;
|
1409
|
+
$[6] = dialogOpen;
|
1410
|
+
$[7] = selectedRole;
|
1411
|
+
$[8] = t6;
|
1412
|
+
$[9] = t7;
|
1450
1413
|
} else {
|
1451
|
-
|
1414
|
+
t7 = $[9];
|
1452
1415
|
}
|
1453
|
-
let
|
1454
|
-
if ($[
|
1455
|
-
|
1416
|
+
let t8;
|
1417
|
+
if ($[10] !== children || $[11] !== t7) {
|
1418
|
+
t8 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
|
1456
1419
|
children,
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1420
|
+
t4,
|
1421
|
+
t5,
|
1422
|
+
t7
|
1460
1423
|
] });
|
1461
|
-
$[
|
1462
|
-
$[
|
1463
|
-
$[
|
1464
|
-
$[21] = t9;
|
1465
|
-
$[22] = t14;
|
1424
|
+
$[10] = children;
|
1425
|
+
$[11] = t7;
|
1426
|
+
$[12] = t8;
|
1466
1427
|
} else {
|
1467
|
-
|
1428
|
+
t8 = $[12];
|
1468
1429
|
}
|
1469
|
-
return
|
1430
|
+
return t8;
|
1470
1431
|
});
|
1471
1432
|
const UserYupSchema = Yup.object().shape({
|
1472
1433
|
displayName: Yup.string().required("Required"),
|
@@ -2007,17 +1968,13 @@ function _temp(userRole) {
|
|
2007
1968
|
return /* @__PURE__ */ jsx(RoleChip, { role: userRole }, userRole?.id);
|
2008
1969
|
}
|
2009
1970
|
const UsersView = function UsersView2(t0) {
|
2010
|
-
const $ = c(
|
1971
|
+
const $ = c(12);
|
2011
1972
|
const {
|
2012
1973
|
children
|
2013
1974
|
} = t0;
|
2014
1975
|
const [dialogOpen, setDialogOpen] = useState();
|
2015
1976
|
const [selectedUser, setSelectedUser] = useState();
|
2016
|
-
|
2017
|
-
users,
|
2018
|
-
usersLimit
|
2019
|
-
} = useUserManagement();
|
2020
|
-
const reachedUsersLimit = usersLimit !== void 0 && users && users.length >= usersLimit;
|
1977
|
+
useUserManagement();
|
2021
1978
|
let t1;
|
2022
1979
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
2023
1980
|
t1 = (user) => {
|
@@ -2050,60 +2007,44 @@ const UsersView = function UsersView2(t0) {
|
|
2050
2007
|
let t4;
|
2051
2008
|
let t5;
|
2052
2009
|
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
2053
|
-
t4 = /* @__PURE__ */
|
2054
|
-
|
2010
|
+
t4 = /* @__PURE__ */ jsxs("div", { className: "flex items-center mt-12", children: [
|
2011
|
+
t3,
|
2012
|
+
/* @__PURE__ */ jsx(Button, { size: "large", startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: () => setDialogOpen(true), children: "Add user" })
|
2013
|
+
] });
|
2014
|
+
t5 = /* @__PURE__ */ jsx(UsersTable, { onUserClicked });
|
2055
2015
|
$[3] = t4;
|
2056
2016
|
$[4] = t5;
|
2057
2017
|
} else {
|
2058
2018
|
t4 = $[3];
|
2059
2019
|
t5 = $[4];
|
2060
2020
|
}
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
]
|
2067
|
-
$[5] = reachedUsersLimit;
|
2021
|
+
const t6 = selectedUser?.uid ?? "new";
|
2022
|
+
const t7 = dialogOpen ?? false;
|
2023
|
+
let t8;
|
2024
|
+
if ($[5] !== selectedUser || $[6] !== t6 || $[7] !== t7) {
|
2025
|
+
t8 = /* @__PURE__ */ jsx(UserDetailsForm, { open: t7, user: selectedUser, handleClose }, t6);
|
2026
|
+
$[5] = selectedUser;
|
2068
2027
|
$[6] = t6;
|
2069
|
-
} else {
|
2070
|
-
t6 = $[6];
|
2071
|
-
}
|
2072
|
-
let t7;
|
2073
|
-
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
2074
|
-
t7 = /* @__PURE__ */ jsx(UsersTable, { onUserClicked });
|
2075
2028
|
$[7] = t7;
|
2029
|
+
$[8] = t8;
|
2076
2030
|
} else {
|
2077
|
-
|
2078
|
-
}
|
2079
|
-
const t8 = selectedUser?.uid ?? "new";
|
2080
|
-
const t9 = dialogOpen ?? false;
|
2081
|
-
let t10;
|
2082
|
-
if ($[8] !== selectedUser || $[9] !== t8 || $[10] !== t9) {
|
2083
|
-
t10 = /* @__PURE__ */ jsx(UserDetailsForm, { open: t9, user: selectedUser, handleClose }, t8);
|
2084
|
-
$[8] = selectedUser;
|
2085
|
-
$[9] = t8;
|
2086
|
-
$[10] = t9;
|
2087
|
-
$[11] = t10;
|
2088
|
-
} else {
|
2089
|
-
t10 = $[11];
|
2031
|
+
t8 = $[8];
|
2090
2032
|
}
|
2091
|
-
let
|
2092
|
-
if ($[
|
2093
|
-
|
2033
|
+
let t9;
|
2034
|
+
if ($[9] !== children || $[10] !== t8) {
|
2035
|
+
t9 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
|
2094
2036
|
children,
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2037
|
+
t4,
|
2038
|
+
t5,
|
2039
|
+
t8
|
2098
2040
|
] });
|
2099
|
-
$[
|
2100
|
-
$[
|
2101
|
-
$[
|
2102
|
-
$[15] = t11;
|
2041
|
+
$[9] = children;
|
2042
|
+
$[10] = t8;
|
2043
|
+
$[11] = t9;
|
2103
2044
|
} else {
|
2104
|
-
|
2045
|
+
t9 = $[11];
|
2105
2046
|
}
|
2106
|
-
return
|
2047
|
+
return t9;
|
2107
2048
|
};
|
2108
2049
|
function useUserManagementPlugin(t0) {
|
2109
2050
|
const $ = c(12);
|