@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.
@@ -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, usersLimit, canEditRoles, allowDefaultRolesCreation, includeCollectionConfigPermissions }: UserManagementParams<CONTROLLER>): UserManagement<USER> & CONTROLLER;
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(23);
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
- const t4 = !canEditRoles ? "Update plans to customise roles" : void 0;
1399
- const t5 = !canEditRoles;
1400
- let t6;
1401
- let t7;
1390
+ let t4;
1391
+ let t5;
1402
1392
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
1403
- t6 = /* @__PURE__ */ jsx(AddIcon, {});
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(Tooltip, { asChild: true, title: t4, children: t8 })
1395
+ /* @__PURE__ */ jsx(Button, { size: "large", startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: () => setDialogOpen(true), children: "Add role" })
1424
1396
  ] });
1425
- $[7] = t4;
1426
- $[8] = t8;
1427
- $[9] = t9;
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
- t11 = $[11];
1401
+ t4 = $[3];
1402
+ t5 = $[4];
1439
1403
  }
1440
- const t12 = selectedRole?.id ?? "new";
1441
- let t13;
1442
- if ($[12] !== canEditRoles || $[13] !== collections || $[14] !== dialogOpen || $[15] !== selectedRole || $[16] !== t12) {
1443
- t13 = /* @__PURE__ */ jsx(RolesDetailsForm, { open: dialogOpen, role: selectedRole, editable: canEditRoles, collections, handleClose }, t12);
1444
- $[12] = canEditRoles;
1445
- $[13] = collections;
1446
- $[14] = dialogOpen;
1447
- $[15] = selectedRole;
1448
- $[16] = t12;
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
- t13 = $[17];
1414
+ t7 = $[9];
1452
1415
  }
1453
- let t14;
1454
- if ($[18] !== children || $[19] !== t11 || $[20] !== t13 || $[21] !== t9) {
1455
- t14 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
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
- t9,
1458
- t11,
1459
- t13
1420
+ t4,
1421
+ t5,
1422
+ t7
1460
1423
  ] });
1461
- $[18] = children;
1462
- $[19] = t11;
1463
- $[20] = t13;
1464
- $[21] = t9;
1465
- $[22] = t14;
1424
+ $[10] = children;
1425
+ $[11] = t7;
1426
+ $[12] = t8;
1466
1427
  } else {
1467
- t14 = $[22];
1428
+ t8 = $[12];
1468
1429
  }
1469
- return t14;
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(16);
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
- const {
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__ */ jsx(AddIcon, {});
2054
- t5 = () => setDialogOpen(true);
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
- let t6;
2062
- if ($[5] !== reachedUsersLimit) {
2063
- t6 = /* @__PURE__ */ jsxs("div", { className: "flex items-center mt-12", children: [
2064
- t3,
2065
- /* @__PURE__ */ jsx(Button, { size: "large", disabled: reachedUsersLimit, startIcon: t4, onClick: t5, children: "Add user" })
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
- t7 = $[7];
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 t11;
2092
- if ($[12] !== children || $[13] !== t10 || $[14] !== t6) {
2093
- t11 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
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
- t6,
2096
- t7,
2097
- t10
2037
+ t4,
2038
+ t5,
2039
+ t8
2098
2040
  ] });
2099
- $[12] = children;
2100
- $[13] = t10;
2101
- $[14] = t6;
2102
- $[15] = t11;
2041
+ $[9] = children;
2042
+ $[10] = t8;
2043
+ $[11] = t9;
2103
2044
  } else {
2104
- t11 = $[15];
2045
+ t9 = $[11];
2105
2046
  }
2106
- return t11;
2047
+ return t9;
2107
2048
  };
2108
2049
  function useUserManagementPlugin(t0) {
2109
2050
  const $ = c(12);