@dloizides/ui-access-admin 1.3.0 → 1.4.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/index.mjs CHANGED
@@ -753,7 +753,7 @@ function buildUserColumns({
753
753
  variant: "secondary"
754
754
  }
755
755
  ),
756
- /* @__PURE__ */ jsx(
756
+ onReset !== void 0 ? /* @__PURE__ */ jsx(
757
757
  Button,
758
758
  {
759
759
  accessibilityHint: t(ACCESS_ADMIN_I18N.usersResetHint),
@@ -764,7 +764,7 @@ function buildUserColumns({
764
764
  testID: `${testIDPrefix}-reset-${user.id}`,
765
765
  variant: "secondary"
766
766
  }
767
- )
767
+ ) : null
768
768
  ] })
769
769
  }
770
770
  ];
@@ -1120,6 +1120,8 @@ var ResetPasswordModal = ({
1120
1120
  ] })
1121
1121
  ] }) });
1122
1122
  };
1123
+ var MISSING_CREATE = "createUser is not provided";
1124
+ var MISSING_RESET = "resetPassword is not provided";
1123
1125
  function useUserManagement(api, t) {
1124
1126
  const [users, setUsers] = useState([]);
1125
1127
  const [loading, setLoading] = useState(true);
@@ -1161,7 +1163,7 @@ function useUserManagement(api, t) {
1161
1163
  );
1162
1164
  const create = useCallback(
1163
1165
  (input) => runWrite(
1164
- () => api.createUser(input),
1166
+ () => api.createUser ? api.createUser(input) : Promise.reject(new Error(MISSING_CREATE)),
1165
1167
  ACCESS_ADMIN_I18N.usersCreateSuccess,
1166
1168
  ACCESS_ADMIN_I18N.usersCreateFailed
1167
1169
  ),
@@ -1177,7 +1179,7 @@ function useUserManagement(api, t) {
1177
1179
  );
1178
1180
  const resetPassword = useCallback(
1179
1181
  (id, password) => runWrite(
1180
- () => api.resetPassword(id, password),
1182
+ () => api.resetPassword ? api.resetPassword(id, password) : Promise.reject(new Error(MISSING_RESET)),
1181
1183
  ACCESS_ADMIN_I18N.usersResetSuccess,
1182
1184
  ACCESS_ADMIN_I18N.usersResetFailed
1183
1185
  ),
@@ -1227,9 +1229,17 @@ var UserManagementPanel = ({
1227
1229
  setOpenModal("reset" /* Reset */);
1228
1230
  };
1229
1231
  const closeModal = () => setOpenModal("none" /* None */);
1232
+ const canCreate = api.createUser !== void 0;
1233
+ const canReset = api.resetPassword !== void 0;
1230
1234
  const columns = useMemo(
1231
- () => buildUserColumns({ t, tenants, testIDPrefix: testID, onEdit: openEdit, onReset: openReset }),
1232
- [t, tenants, testID]
1235
+ () => buildUserColumns({
1236
+ t,
1237
+ tenants,
1238
+ testIDPrefix: testID,
1239
+ onEdit: openEdit,
1240
+ onReset: canReset ? openReset : void 0
1241
+ }),
1242
+ [t, tenants, testID, canReset]
1233
1243
  );
1234
1244
  return /* @__PURE__ */ jsxs(View, { style: styles2.panel, testID, children: [
1235
1245
  /* @__PURE__ */ jsx(ToastHost, { subscribe: controller.toastSubscribe, toastTestID: `${testID}-toast` }),
@@ -1238,7 +1248,7 @@ var UserManagementPanel = ({
1238
1248
  /* @__PURE__ */ jsx(
1239
1249
  FilterBar,
1240
1250
  {
1241
- actions: /* @__PURE__ */ jsx(
1251
+ actions: canCreate ? /* @__PURE__ */ jsx(
1242
1252
  Button,
1243
1253
  {
1244
1254
  accessibilityHint: t(ACCESS_ADMIN_I18N.usersCreateHint),
@@ -1247,7 +1257,7 @@ var UserManagementPanel = ({
1247
1257
  onPress: () => setOpenModal("create" /* Create */),
1248
1258
  testID: `${testID}-create`
1249
1259
  }
1250
- ),
1260
+ ) : void 0,
1251
1261
  resultsCount: visibleUsers.length,
1252
1262
  resultsLabel: t(ACCESS_ADMIN_I18N.usersResultsLabel),
1253
1263
  testID: `${testID}-filter-bar`,
@@ -1292,7 +1302,7 @@ var UserManagementPanel = ({
1292
1302
  zebra: true
1293
1303
  }
1294
1304
  ),
1295
- /* @__PURE__ */ jsx(
1305
+ canCreate ? /* @__PURE__ */ jsx(
1296
1306
  CreateUserModal,
1297
1307
  {
1298
1308
  assignableRoles,
@@ -1304,7 +1314,7 @@ var UserManagementPanel = ({
1304
1314
  testIDPrefix: `${testID}-create-modal`,
1305
1315
  visible: openModal === "create" /* Create */
1306
1316
  }
1307
- ),
1317
+ ) : null,
1308
1318
  /* @__PURE__ */ jsx(
1309
1319
  EditUserModal,
1310
1320
  {
@@ -1319,7 +1329,7 @@ var UserManagementPanel = ({
1319
1329
  visible: openModal === "edit" /* Edit */
1320
1330
  }
1321
1331
  ),
1322
- /* @__PURE__ */ jsx(
1332
+ canReset ? /* @__PURE__ */ jsx(
1323
1333
  ResetPasswordModal,
1324
1334
  {
1325
1335
  onCancel: closeModal,
@@ -1329,7 +1339,7 @@ var UserManagementPanel = ({
1329
1339
  user: activeUser,
1330
1340
  visible: openModal === "reset" /* Reset */
1331
1341
  }
1332
- )
1342
+ ) : null
1333
1343
  ] });
1334
1344
  };
1335
1345
  var buildStyles3 = (c) => StyleSheet.create({