@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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to `@dloizides/ui-access-admin` are documented here.
5
5
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the
6
6
  project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.4.0]
9
+
10
+ ### Changed
11
+
12
+ - `UserManagementApi.createUser` and `resetPassword` are optional. Without `createUser` the panel hides Create; without `resetPassword` it hides each row's Reset password (FINREG-FUNDS-1 "Tenant funds, deal gate, blocking and roles"). Non-breaking.
13
+
8
14
  ## [1.3.0]
9
15
 
10
16
  ### Added
package/dist/index.d.mts CHANGED
@@ -350,7 +350,7 @@ interface UserManagementPatch {
350
350
  /** What the host is asked to do. Each rejects with an `Error` on failure. */
351
351
  interface UserManagementApi {
352
352
  listUsers(): Promise<UserManagementUser[]>;
353
- createUser(input: {
353
+ createUser?(input: {
354
354
  email: string;
355
355
  password: string;
356
356
  displayName: string;
@@ -358,7 +358,7 @@ interface UserManagementApi {
358
358
  tenantId: string | null;
359
359
  }): Promise<void>;
360
360
  updateUser(id: string, patch: UserManagementPatch): Promise<void>;
361
- resetPassword(id: string, password: string): Promise<void>;
361
+ resetPassword?(id: string, password: string): Promise<void>;
362
362
  }
363
363
  /** One selectable tenant for the platform-admin tenant picker. */
364
364
  interface UserManagementTenant {
package/dist/index.d.ts CHANGED
@@ -350,7 +350,7 @@ interface UserManagementPatch {
350
350
  /** What the host is asked to do. Each rejects with an `Error` on failure. */
351
351
  interface UserManagementApi {
352
352
  listUsers(): Promise<UserManagementUser[]>;
353
- createUser(input: {
353
+ createUser?(input: {
354
354
  email: string;
355
355
  password: string;
356
356
  displayName: string;
@@ -358,7 +358,7 @@ interface UserManagementApi {
358
358
  tenantId: string | null;
359
359
  }): Promise<void>;
360
360
  updateUser(id: string, patch: UserManagementPatch): Promise<void>;
361
- resetPassword(id: string, password: string): Promise<void>;
361
+ resetPassword?(id: string, password: string): Promise<void>;
362
362
  }
363
363
  /** One selectable tenant for the platform-admin tenant picker. */
364
364
  interface UserManagementTenant {
package/dist/index.js CHANGED
@@ -755,7 +755,7 @@ function buildUserColumns({
755
755
  variant: "secondary"
756
756
  }
757
757
  ),
758
- /* @__PURE__ */ jsxRuntime.jsx(
758
+ onReset !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
759
759
  uiButtons.Button,
760
760
  {
761
761
  accessibilityHint: t(ACCESS_ADMIN_I18N.usersResetHint),
@@ -766,7 +766,7 @@ function buildUserColumns({
766
766
  testID: `${testIDPrefix}-reset-${user.id}`,
767
767
  variant: "secondary"
768
768
  }
769
- )
769
+ ) : null
770
770
  ] })
771
771
  }
772
772
  ];
@@ -1122,6 +1122,8 @@ var ResetPasswordModal = ({
1122
1122
  ] })
1123
1123
  ] }) });
1124
1124
  };
1125
+ var MISSING_CREATE = "createUser is not provided";
1126
+ var MISSING_RESET = "resetPassword is not provided";
1125
1127
  function useUserManagement(api, t) {
1126
1128
  const [users, setUsers] = react.useState([]);
1127
1129
  const [loading, setLoading] = react.useState(true);
@@ -1163,7 +1165,7 @@ function useUserManagement(api, t) {
1163
1165
  );
1164
1166
  const create = react.useCallback(
1165
1167
  (input) => runWrite(
1166
- () => api.createUser(input),
1168
+ () => api.createUser ? api.createUser(input) : Promise.reject(new Error(MISSING_CREATE)),
1167
1169
  ACCESS_ADMIN_I18N.usersCreateSuccess,
1168
1170
  ACCESS_ADMIN_I18N.usersCreateFailed
1169
1171
  ),
@@ -1179,7 +1181,7 @@ function useUserManagement(api, t) {
1179
1181
  );
1180
1182
  const resetPassword = react.useCallback(
1181
1183
  (id, password) => runWrite(
1182
- () => api.resetPassword(id, password),
1184
+ () => api.resetPassword ? api.resetPassword(id, password) : Promise.reject(new Error(MISSING_RESET)),
1183
1185
  ACCESS_ADMIN_I18N.usersResetSuccess,
1184
1186
  ACCESS_ADMIN_I18N.usersResetFailed
1185
1187
  ),
@@ -1229,9 +1231,17 @@ var UserManagementPanel = ({
1229
1231
  setOpenModal("reset" /* Reset */);
1230
1232
  };
1231
1233
  const closeModal = () => setOpenModal("none" /* None */);
1234
+ const canCreate = api.createUser !== void 0;
1235
+ const canReset = api.resetPassword !== void 0;
1232
1236
  const columns = react.useMemo(
1233
- () => buildUserColumns({ t, tenants, testIDPrefix: testID, onEdit: openEdit, onReset: openReset }),
1234
- [t, tenants, testID]
1237
+ () => buildUserColumns({
1238
+ t,
1239
+ tenants,
1240
+ testIDPrefix: testID,
1241
+ onEdit: openEdit,
1242
+ onReset: canReset ? openReset : void 0
1243
+ }),
1244
+ [t, tenants, testID, canReset]
1235
1245
  );
1236
1246
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles2.panel, testID, children: [
1237
1247
  /* @__PURE__ */ jsxRuntime.jsx(uiFeedback.ToastHost, { subscribe: controller.toastSubscribe, toastTestID: `${testID}-toast` }),
@@ -1240,7 +1250,7 @@ var UserManagementPanel = ({
1240
1250
  /* @__PURE__ */ jsxRuntime.jsx(
1241
1251
  uiTables.FilterBar,
1242
1252
  {
1243
- actions: /* @__PURE__ */ jsxRuntime.jsx(
1253
+ actions: canCreate ? /* @__PURE__ */ jsxRuntime.jsx(
1244
1254
  uiButtons.Button,
1245
1255
  {
1246
1256
  accessibilityHint: t(ACCESS_ADMIN_I18N.usersCreateHint),
@@ -1249,7 +1259,7 @@ var UserManagementPanel = ({
1249
1259
  onPress: () => setOpenModal("create" /* Create */),
1250
1260
  testID: `${testID}-create`
1251
1261
  }
1252
- ),
1262
+ ) : void 0,
1253
1263
  resultsCount: visibleUsers.length,
1254
1264
  resultsLabel: t(ACCESS_ADMIN_I18N.usersResultsLabel),
1255
1265
  testID: `${testID}-filter-bar`,
@@ -1294,7 +1304,7 @@ var UserManagementPanel = ({
1294
1304
  zebra: true
1295
1305
  }
1296
1306
  ),
1297
- /* @__PURE__ */ jsxRuntime.jsx(
1307
+ canCreate ? /* @__PURE__ */ jsxRuntime.jsx(
1298
1308
  CreateUserModal,
1299
1309
  {
1300
1310
  assignableRoles,
@@ -1306,7 +1316,7 @@ var UserManagementPanel = ({
1306
1316
  testIDPrefix: `${testID}-create-modal`,
1307
1317
  visible: openModal === "create" /* Create */
1308
1318
  }
1309
- ),
1319
+ ) : null,
1310
1320
  /* @__PURE__ */ jsxRuntime.jsx(
1311
1321
  EditUserModal,
1312
1322
  {
@@ -1321,7 +1331,7 @@ var UserManagementPanel = ({
1321
1331
  visible: openModal === "edit" /* Edit */
1322
1332
  }
1323
1333
  ),
1324
- /* @__PURE__ */ jsxRuntime.jsx(
1334
+ canReset ? /* @__PURE__ */ jsxRuntime.jsx(
1325
1335
  ResetPasswordModal,
1326
1336
  {
1327
1337
  onCancel: closeModal,
@@ -1331,7 +1341,7 @@ var UserManagementPanel = ({
1331
1341
  user: activeUser,
1332
1342
  visible: openModal === "reset" /* Reset */
1333
1343
  }
1334
- )
1344
+ ) : null
1335
1345
  ] });
1336
1346
  };
1337
1347
  var buildStyles3 = (c) => reactNative.StyleSheet.create({