@moh-sso/users 1.5.0 → 1.6.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.
Files changed (31) hide show
  1. package/README.md +7 -2
  2. package/dist/_types/apps/rbac/src/api/health-context.api.d.ts +99 -99
  3. package/dist/_types/apps/rbac/src/api/identity-sync.api.d.ts +2884 -0
  4. package/dist/_types/apps/rbac/src/api/index.d.ts +1 -0
  5. package/dist/_types/apps/rbac/src/api/rbac.api.d.ts +385 -385
  6. package/dist/_types/apps/rbac/src/types/identity-sync.types.d.ts +109 -0
  7. package/dist/_types/apps/rbac/src/types/index.d.ts +1 -0
  8. package/dist/_types/apps/rbac/src/types/rbac.types.d.ts +2 -0
  9. package/dist/_types/apps/users/src/api/users.api.d.ts +77 -77
  10. package/dist/_types/apps/users/src/components/UserFilters.d.ts +2 -1
  11. package/dist/_types/packages/api/src/api/baseApi.d.ts +1 -1
  12. package/dist/_types/packages/auth/src/api/auth.api.d.ts +21 -21
  13. package/dist/_types/packages/auth/src/api/health-context.api.d.ts +19 -19
  14. package/dist/_types/packages/auth/src/auth/auth.selectors.d.ts +22 -22
  15. package/dist/_types/packages/state/src/clients/clients.selectors.d.ts +17 -17
  16. package/dist/_types/packages/state/src/index.d.ts +2 -2
  17. package/dist/_types/packages/ui/src/accessibility/useFocusTrap.d.ts +2 -1
  18. package/dist/_types/packages/ui/src/overlays/header-panel/ReusableHeaderPanel.d.ts +2 -1
  19. package/dist/_types/packages/ui/src/overlays/header-panel/header-panel.context.d.ts +3 -1
  20. package/dist/api.js +1 -1
  21. package/dist/assets/root.component-C62grxQn.js +1619 -0
  22. package/dist/assets/root.component-C62grxQn.js.map +1 -0
  23. package/dist/assets/users-BOKiZZ2J.css +1 -0
  24. package/dist/index.js +2 -2
  25. package/dist/routes.js +1 -1
  26. package/dist/single-spa.js +2 -2
  27. package/dist/types.js +1 -1
  28. package/package.json +8 -8
  29. package/dist/assets/root.component-DjmegrfS.js +0 -1479
  30. package/dist/assets/root.component-DjmegrfS.js.map +0 -1
  31. package/dist/assets/users-D7Pe7bza.css +0 -1
@@ -1,1479 +0,0 @@
1
- import { jsx as r, jsxs as u, Fragment as de } from "react/jsx-runtime";
2
- import { InlineLoading as k, Stack as C, Button as v, Tile as z, MultiSelect as W, Tag as Y, Form as Ce, FormGroup as se, TextInput as B, Checkbox as te, Dropdown as ae, OverflowMenu as ve, OverflowMenuItem as V, ButtonSet as $e, DataTable as Ie, Table as Ue, TableHead as qe, TableRow as re, TableSelectAll as Ae, TableHeader as Le, TableBody as Pe, TableSelectRow as we, TableCell as oe } from "@carbon/react";
3
- import { useState as T, useEffect as J, useMemo as M } from "react";
4
- import { useSelector as ce } from "react-redux";
5
- import { selectUser as ue } from "@moh-sso/auth";
6
- import { useToast as X, FormInlineAlert as me, useModal as pe, useHeaderPanel as Me, DataTableShell as _e, TableStatusTag as xe, RowActionsCell as Ee, DataTablePagination as Ge, ErrorState as ke } from "@moh-sso/ui";
7
- import { baseApi as ye } from "@moh-sso/api";
8
- import { u as Ne, i as De, e as He, g as Oe, f as Fe } from "./users.api-DoE9CD9k.js";
9
- const o = "/admin/rbac", Qe = ye.injectEndpoints({
10
- endpoints: (t) => ({
11
- registerRbacSystem: t.mutation({
12
- query: (e) => ({ url: `${o}/systems`, method: "POST", body: e }),
13
- transformResponse: (e) => e.data,
14
- invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
15
- }),
16
- listRbacSystems: t.query({
17
- query: () => `${o}/systems`,
18
- transformResponse: (e) => e.data,
19
- providesTags: [{ type: "RbacSystem", id: "LIST" }]
20
- }),
21
- getRbacSystem: t.query({
22
- query: (e) => `${o}/systems/${encodeURIComponent(e)}`,
23
- transformResponse: (e) => e.data,
24
- providesTags: (e, s, a) => [{ type: "RbacSystem", id: a }]
25
- }),
26
- updateRbacSystem: t.mutation({
27
- query: ({ clientId: e, data: s }) => ({
28
- url: `${o}/systems/${encodeURIComponent(e)}`,
29
- method: "PUT",
30
- body: s
31
- }),
32
- transformResponse: (e) => e.data,
33
- invalidatesTags: (e, s, { clientId: a }) => [
34
- { type: "RbacSystem", id: "LIST" },
35
- { type: "RbacSystem", id: a }
36
- ]
37
- }),
38
- transitionRbacSystem: t.mutation({
39
- query: ({ clientId: e, ...s }) => ({
40
- url: `${o}/systems/${encodeURIComponent(e)}/lifecycle`,
41
- method: "POST",
42
- body: s
43
- }),
44
- transformResponse: (e) => e.data,
45
- invalidatesTags: (e, s, { clientId: a }) => [
46
- { type: "RbacSystem", id: "LIST" },
47
- { type: "RbacSystem", id: a },
48
- { type: "RbacAudit", id: "LIST" }
49
- ]
50
- }),
51
- listRbacPermissions: t.query({
52
- query: () => `${o}/permissions`,
53
- transformResponse: (e) => e.data,
54
- providesTags: [{ type: "RbacPermission", id: "LIST" }]
55
- }),
56
- updateRbacPermissionMetadata: t.mutation({
57
- query: ({ permissionKey: e, data: s }) => ({
58
- url: `${o}/permissions/${encodeURIComponent(e)}`,
59
- method: "PUT",
60
- body: s
61
- }),
62
- transformResponse: (e) => e.data,
63
- invalidatesTags: [{ type: "RbacPermission", id: "LIST" }]
64
- }),
65
- listSystemRoles: t.query({
66
- query: (e) => `${o}/systems/${encodeURIComponent(e)}/roles`,
67
- transformResponse: (e) => e.data,
68
- providesTags: (e, s, a) => [{ type: "RbacSystem", id: a }]
69
- }),
70
- createSystemRole: t.mutation(
71
- {
72
- query: ({ clientId: e, data: s }) => ({
73
- url: `${o}/systems/${encodeURIComponent(e)}/roles`,
74
- method: "POST",
75
- body: s
76
- }),
77
- transformResponse: (e) => e.data,
78
- invalidatesTags: (e, s, { clientId: a }) => [{ type: "RbacSystem", id: a }]
79
- }
80
- ),
81
- updateSystemRole: t.mutation({
82
- query: ({ roleId: e, data: s }) => ({
83
- url: `${o}/roles/${encodeURIComponent(e)}`,
84
- method: "PUT",
85
- body: s
86
- }),
87
- transformResponse: (e) => e.data,
88
- invalidatesTags: (e, s, { clientId: a }) => [{ type: "RbacSystem", id: a }]
89
- }),
90
- deleteSystemRole: t.mutation({
91
- query: ({ roleId: e }) => ({
92
- url: `${o}/roles/${encodeURIComponent(e)}`,
93
- method: "DELETE"
94
- }),
95
- invalidatesTags: (e, s, { clientId: a }) => [{ type: "RbacSystem", id: a }]
96
- }),
97
- getRoleUsage: t.query({
98
- query: (e) => `${o}/roles/${encodeURIComponent(e)}/usage`,
99
- transformResponse: (e) => e.data
100
- }),
101
- copyRolePermissions: t.mutation({
102
- query: ({ roleId: e, data: s }) => ({
103
- url: `${o}/roles/${encodeURIComponent(e)}/copy-permissions`,
104
- method: "POST",
105
- body: s
106
- }),
107
- transformResponse: (e) => e.data,
108
- invalidatesTags: (e, s, { clientId: a }) => [{ type: "RbacSystem", id: a }]
109
- }),
110
- assignSystemRolePermission: t.mutation({
111
- query: ({ roleId: e, data: s }) => ({
112
- url: `${o}/roles/${encodeURIComponent(e)}/permissions`,
113
- method: "POST",
114
- body: s
115
- }),
116
- invalidatesTags: (e, s, { clientId: a }) => [{ type: "RbacSystem", id: a }]
117
- }),
118
- removeSystemRolePermission: t.mutation({
119
- query: ({ roleId: e, permissionKey: s }) => ({
120
- url: `${o}/roles/${encodeURIComponent(e)}/permissions/${encodeURIComponent(s)}`,
121
- method: "DELETE"
122
- }),
123
- invalidatesTags: (e, s, { clientId: a }) => [{ type: "RbacSystem", id: a }]
124
- }),
125
- listRealmRolePermissions: t.query({
126
- query: () => `${o}/realm-roles`,
127
- transformResponse: (e) => e.data,
128
- providesTags: [{ type: "RbacRealmRole", id: "LIST" }]
129
- }),
130
- listRbacGroups: t.query({
131
- query: () => `${o}/groups`,
132
- transformResponse: (e) => e.data,
133
- providesTags: [{ type: "RbacGroup", id: "LIST" }]
134
- }),
135
- getRbacGroup: t.query({
136
- query: (e) => `${o}/groups/${encodeURIComponent(e)}`,
137
- transformResponse: (e) => e.data,
138
- providesTags: (e, s, a) => [{ type: "RbacGroup", id: a }]
139
- }),
140
- listRbacGroupMembers: t.query({
141
- query: (e) => `${o}/groups/${encodeURIComponent(e)}/members`,
142
- transformResponse: (e) => e.data,
143
- providesTags: (e, s, a) => [{ type: "RbacGroup", id: `${a}:members` }]
144
- }),
145
- upsertRbacGroup: t.mutation({
146
- query: (e) => ({
147
- url: `${o}/groups`,
148
- method: "POST",
149
- body: e
150
- }),
151
- transformResponse: (e) => e.data,
152
- invalidatesTags: [
153
- { type: "RbacGroup", id: "LIST" },
154
- { type: "RbacAudit", id: "LIST" }
155
- ]
156
- }),
157
- addRbacGroupMember: t.mutation({
158
- query: ({ groupId: e, data: s }) => ({
159
- url: `${o}/groups/${encodeURIComponent(e)}/members`,
160
- method: "POST",
161
- body: s
162
- }),
163
- transformResponse: (e) => e.data,
164
- invalidatesTags: (e, s, { groupId: a, data: c }) => [
165
- { type: "RbacGroup", id: a },
166
- { type: "RbacGroup", id: `${a}:members` },
167
- { type: "RbacGroup", id: "LIST" },
168
- { type: "RbacAudit", id: "LIST" },
169
- { type: "User", id: c.userId }
170
- ]
171
- }),
172
- removeRbacGroupMember: t.mutation({
173
- query: ({ groupId: e, userId: s }) => ({
174
- url: `${o}/groups/${encodeURIComponent(e)}/members/${encodeURIComponent(s)}`,
175
- method: "DELETE"
176
- }),
177
- transformResponse: (e) => e.data,
178
- invalidatesTags: (e, s, { groupId: a, userId: c }) => [
179
- { type: "RbacGroup", id: a },
180
- { type: "RbacGroup", id: `${a}:members` },
181
- { type: "RbacGroup", id: "LIST" },
182
- { type: "RbacAudit", id: "LIST" },
183
- { type: "User", id: c }
184
- ]
185
- }),
186
- syncRbacGroupMembers: t.mutation({
187
- query: (e) => ({
188
- url: `${o}/groups/${encodeURIComponent(e)}/sync-members`,
189
- method: "POST"
190
- }),
191
- transformResponse: (e) => e.data,
192
- invalidatesTags: (e, s, a) => [
193
- { type: "RbacGroup", id: a },
194
- { type: "RbacGroup", id: `${a}:members` },
195
- { type: "RbacGroup", id: "LIST" },
196
- { type: "RbacAudit", id: "LIST" }
197
- ]
198
- }),
199
- replaceRbacGroupMembers: t.mutation({
200
- query: ({ groupId: e, data: s }) => ({
201
- url: `${o}/groups/${encodeURIComponent(e)}/members`,
202
- method: "PUT",
203
- body: s
204
- }),
205
- invalidatesTags: (e, s, { groupId: a }) => [
206
- { type: "RbacGroup", id: a },
207
- { type: "RbacGroup", id: "LIST" },
208
- { type: "RbacAudit", id: "LIST" }
209
- ]
210
- }),
211
- assignGroupPermission: t.mutation(
212
- {
213
- query: ({ groupId: e, data: s }) => ({
214
- url: `${o}/groups/${encodeURIComponent(e)}/permissions`,
215
- method: "POST",
216
- body: s
217
- }),
218
- invalidatesTags: (e, s, { groupId: a }) => [
219
- { type: "RbacGroup", id: a },
220
- { type: "RbacGroup", id: "LIST" }
221
- ]
222
- }
223
- ),
224
- removeGroupPermission: t.mutation({
225
- query: ({ groupId: e, permissionKey: s }) => ({
226
- url: `${o}/groups/${encodeURIComponent(e)}/permissions/${encodeURIComponent(s)}`,
227
- method: "DELETE"
228
- }),
229
- invalidatesTags: (e, s, { groupId: a }) => [
230
- { type: "RbacGroup", id: a },
231
- { type: "RbacGroup", id: "LIST" }
232
- ]
233
- }),
234
- assignGroupRealmRole: t.mutation({
235
- query: ({ groupId: e, data: s }) => ({
236
- url: `${o}/groups/${encodeURIComponent(e)}/realm-roles`,
237
- method: "POST",
238
- body: s
239
- }),
240
- invalidatesTags: (e, s, { groupId: a }) => [
241
- { type: "RbacGroup", id: a },
242
- { type: "RbacGroup", id: "LIST" }
243
- ]
244
- }),
245
- removeGroupRealmRole: t.mutation({
246
- query: ({ groupId: e, realmRole: s }) => ({
247
- url: `${o}/groups/${encodeURIComponent(e)}/realm-roles/${encodeURIComponent(s)}`,
248
- method: "DELETE"
249
- }),
250
- invalidatesTags: (e, s, { groupId: a }) => [
251
- { type: "RbacGroup", id: a },
252
- { type: "RbacGroup", id: "LIST" }
253
- ]
254
- }),
255
- assignGroupSystemRole: t.mutation({
256
- query: ({ groupId: e, data: s }) => ({
257
- url: `${o}/groups/${encodeURIComponent(e)}/system-roles`,
258
- method: "POST",
259
- body: s
260
- }),
261
- invalidatesTags: (e, s, { groupId: a }) => [
262
- { type: "RbacGroup", id: a },
263
- { type: "RbacGroup", id: "LIST" }
264
- ]
265
- }),
266
- removeGroupSystemRole: t.mutation({
267
- query: ({ groupId: e, clientId: s, roleName: a }) => ({
268
- url: `${o}/groups/${encodeURIComponent(e)}/system-roles/${encodeURIComponent(s)}/${encodeURIComponent(a)}`,
269
- method: "DELETE"
270
- }),
271
- invalidatesTags: (e, s, { groupId: a }) => [
272
- { type: "RbacGroup", id: a },
273
- { type: "RbacGroup", id: "LIST" }
274
- ]
275
- }),
276
- getRealmRoleUsage: t.query({
277
- query: (e) => `${o}/realm-roles/${encodeURIComponent(e)}/usage`,
278
- transformResponse: (e) => e.data
279
- }),
280
- assignRealmRolePermission: t.mutation({
281
- query: ({ realmRole: e, data: s }) => ({
282
- url: `${o}/realm-roles/${encodeURIComponent(e)}/permissions`,
283
- method: "POST",
284
- body: s
285
- }),
286
- invalidatesTags: [{ type: "RbacRealmRole", id: "LIST" }]
287
- }),
288
- removeRealmRolePermission: t.mutation(
289
- {
290
- query: ({ realmRole: e, permissionKey: s }) => ({
291
- url: `${o}/realm-roles/${encodeURIComponent(e)}/permissions/${encodeURIComponent(s)}`,
292
- method: "DELETE"
293
- }),
294
- invalidatesTags: [{ type: "RbacRealmRole", id: "LIST" }]
295
- }
296
- ),
297
- addSystemAccessRole: t.mutation({
298
- query: ({ clientId: e, data: s }) => ({
299
- url: `${o}/systems/${encodeURIComponent(e)}/access-roles`,
300
- method: "POST",
301
- body: s
302
- }),
303
- invalidatesTags: (e, s, { clientId: a }) => [{ type: "RbacSystem", id: a }]
304
- }),
305
- removeSystemAccessRole: t.mutation({
306
- query: ({ clientId: e, roleName: s, force: a }) => ({
307
- url: `${o}/systems/${encodeURIComponent(e)}/access-roles/${encodeURIComponent(s)}${a ? "?force=true" : ""}`,
308
- method: "DELETE"
309
- }),
310
- invalidatesTags: (e, s, { clientId: a }) => [{ type: "RbacSystem", id: a }]
311
- }),
312
- getRbacDrift: t.query({
313
- query: () => `${o}/drift`,
314
- transformResponse: (e) => e.data,
315
- providesTags: [{ type: "RbacSystem", id: "DRIFT" }]
316
- }),
317
- previewRbacRealmExportDrift: t.mutation({
318
- query: (e) => ({
319
- url: `${o}/drift/realm-export`,
320
- method: "POST",
321
- body: e
322
- }),
323
- transformResponse: (e) => e.data
324
- }),
325
- previewRbacSync: t.mutation({
326
- query: (e) => ({
327
- url: `${o}/sync/preview`,
328
- method: "POST",
329
- body: e
330
- }),
331
- transformResponse: (e) => e.data
332
- }),
333
- applyRbacSync: t.mutation({
334
- query: (e) => ({
335
- url: `${o}/sync/apply`,
336
- method: "POST",
337
- body: e
338
- }),
339
- transformResponse: (e) => e.data,
340
- invalidatesTags: [
341
- { type: "RbacSystem", id: "LIST" },
342
- { type: "RbacSystem", id: "DRIFT" },
343
- { type: "RbacRealmRole", id: "LIST" }
344
- ]
345
- }),
346
- getRbacEffectiveAccess: t.query({
347
- query: ({ userId: e = "lookup", username: s, email: a }) => {
348
- const c = new URLSearchParams();
349
- s && c.set("username", s), a && c.set("email", a);
350
- const d = c.toString();
351
- return `${o}/effective-access/users/${encodeURIComponent(e)}${d ? `?${d}` : ""}`;
352
- },
353
- transformResponse: (e) => e.data
354
- }),
355
- getAssignableUserAccess: t.query({
356
- query: () => `${o}/user-access/assignable`,
357
- transformResponse: (e) => e.data,
358
- providesTags: [{ type: "RbacSystem", id: "USER_ACCESS_ASSIGNABLE" }]
359
- }),
360
- getUserAccessProfile: t.query({
361
- query: (e) => `${o}/user-access/users/${encodeURIComponent(e)}`,
362
- transformResponse: (e) => e.data,
363
- providesTags: (e, s, a) => [
364
- { type: "RbacSystem", id: "USER_ACCESS_ASSIGNABLE" },
365
- { type: "User", id: a },
366
- { type: "UserClientRole", id: `LIST-${a}` }
367
- ]
368
- }),
369
- updateUserAccess: t.mutation({
370
- query: ({ userId: e, data: s }) => ({
371
- url: `${o}/user-access/users/${encodeURIComponent(e)}`,
372
- method: "PUT",
373
- body: s
374
- }),
375
- transformResponse: (e) => e.data,
376
- invalidatesTags: (e, s, { userId: a }) => [
377
- { type: "User", id: a },
378
- { type: "User", id: "LIST" },
379
- { type: "UserClientRole", id: `LIST-${a}` },
380
- { type: "RbacAudit", id: "LIST" }
381
- ]
382
- }),
383
- previewRbacChange: t.mutation({
384
- query: (e) => ({ url: `${o}/changes/preview`, method: "POST", body: e }),
385
- transformResponse: (e) => e.data
386
- }),
387
- exportRbacSeed: t.query({
388
- query: () => `${o}/export`,
389
- transformResponse: (e) => e.data
390
- }),
391
- previewRbacImport: t.mutation({
392
- query: (e) => ({ url: `${o}/import/preview`, method: "POST", body: e }),
393
- transformResponse: (e) => e.data
394
- }),
395
- applyRbacImport: t.mutation({
396
- query: (e) => ({ url: `${o}/import/apply`, method: "POST", body: e }),
397
- transformResponse: (e) => e.data,
398
- invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
399
- }),
400
- listRbacAuditEvents: t.query({
401
- query: (e) => {
402
- const s = new URLSearchParams();
403
- e?.actor && s.set("actor", e.actor), e?.systemClientId && s.set("systemClientId", e.systemClientId), e?.roleName && s.set("roleName", e.roleName), e?.permissionKey && s.set("permissionKey", e.permissionKey), e?.action && s.set("action", e.action), e?.from && s.set("from", e.from), e?.to && s.set("to", e.to), e?.limit && s.set("limit", String(e.limit));
404
- const a = s.toString();
405
- return `${o}/audit${a ? `?${a}` : ""}`;
406
- },
407
- transformResponse: (e) => e.data,
408
- providesTags: [{ type: "RbacAudit", id: "LIST" }]
409
- }),
410
- listRbacRoleTemplates: t.query({
411
- query: () => `${o}/role-templates`,
412
- transformResponse: (e) => e.data
413
- }),
414
- createRoleFromTemplate: t.mutation({
415
- query: ({ clientId: e, data: s }) => ({
416
- url: `${o}/systems/${encodeURIComponent(e)}/roles/from-template`,
417
- method: "POST",
418
- body: s
419
- }),
420
- transformResponse: (e) => e.data,
421
- invalidatesTags: (e, s, { clientId: a }) => [{ type: "RbacSystem", id: a }]
422
- }),
423
- bulkAssignPermission: t.mutation({
424
- query: (e) => ({ url: `${o}/bulk/assign-permission`, method: "POST", body: e }),
425
- invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
426
- }),
427
- bulkRemovePermission: t.mutation({
428
- query: (e) => ({ url: `${o}/bulk/remove-permission`, method: "POST", body: e }),
429
- invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
430
- }),
431
- listAccessRequests: t.query({
432
- query: () => `${o}/access-requests`,
433
- transformResponse: (e) => e.data,
434
- providesTags: [{ type: "RbacAccessRequest", id: "LIST" }]
435
- }),
436
- createAccessRequest: t.mutation({
437
- query: (e) => ({ url: "/access-requests", method: "POST", body: e }),
438
- transformResponse: (e) => e.data,
439
- invalidatesTags: [{ type: "RbacAccessRequest", id: "LIST" }]
440
- }),
441
- decideAccessRequest: t.mutation({
442
- query: ({ id: e, decision: s, data: a }) => ({
443
- url: `${o}/access-requests/${encodeURIComponent(e)}/${s}`,
444
- method: "POST",
445
- body: a ?? {}
446
- }),
447
- transformResponse: (e) => e.data,
448
- invalidatesTags: [
449
- { type: "RbacAccessRequest", id: "LIST" },
450
- { type: "RbacAudit", id: "LIST" }
451
- ]
452
- }),
453
- listChangeRequests: t.query({
454
- query: () => `${o}/change-requests`,
455
- transformResponse: (e) => e.data,
456
- providesTags: [{ type: "RbacChangeRequest", id: "LIST" }]
457
- }),
458
- createChangeRequest: t.mutation({
459
- query: (e) => ({ url: `${o}/change-requests`, method: "POST", body: e }),
460
- transformResponse: (e) => e.data,
461
- invalidatesTags: [{ type: "RbacChangeRequest", id: "LIST" }]
462
- }),
463
- decideChangeRequest: t.mutation({
464
- query: ({ id: e, decision: s, data: a }) => ({
465
- url: `${o}/change-requests/${encodeURIComponent(e)}/${s}`,
466
- method: "POST",
467
- body: a ?? {}
468
- }),
469
- transformResponse: (e) => e.data,
470
- invalidatesTags: [
471
- { type: "RbacChangeRequest", id: "LIST" },
472
- { type: "RbacAudit", id: "LIST" }
473
- ]
474
- }),
475
- simulateRbacAccess: t.mutation({
476
- query: (e) => ({ url: `${o}/simulate`, method: "POST", body: e }),
477
- transformResponse: (e) => e.data
478
- })
479
- })
480
- }), {
481
- useApplyRbacSyncMutation: fs,
482
- useApplyRbacImportMutation: bs,
483
- useAddSystemAccessRoleMutation: Ts,
484
- useAddRbacGroupMemberMutation: Ss,
485
- useAssignGroupPermissionMutation: Cs,
486
- useAssignGroupRealmRoleMutation: vs,
487
- useAssignGroupSystemRoleMutation: $s,
488
- useAssignRealmRolePermissionMutation: Is,
489
- useAssignSystemRolePermissionMutation: Us,
490
- useBulkAssignPermissionMutation: qs,
491
- useBulkRemovePermissionMutation: As,
492
- useCopyRolePermissionsMutation: Ls,
493
- useCreateAccessRequestMutation: Ps,
494
- useCreateChangeRequestMutation: ws,
495
- useCreateRoleFromTemplateMutation: Ms,
496
- useCreateSystemRoleMutation: _s,
497
- useDecideAccessRequestMutation: xs,
498
- useDecideChangeRequestMutation: Es,
499
- useDeleteSystemRoleMutation: Gs,
500
- useExportRbacSeedQuery: ks,
501
- useGetRbacDriftQuery: Ns,
502
- useGetRbacEffectiveAccessQuery: Ds,
503
- useGetRbacGroupQuery: Hs,
504
- useGetAssignableUserAccessQuery: ze,
505
- useGetUserAccessProfileQuery: Be,
506
- useGetRealmRoleUsageQuery: Os,
507
- useGetRoleUsageQuery: Fs,
508
- useListAccessRequestsQuery: Qs,
509
- useListChangeRequestsQuery: zs,
510
- useListRbacAuditEventsQuery: Bs,
511
- useGetRbacSystemQuery: Vs,
512
- useListRbacPermissionsQuery: js,
513
- useListRbacGroupMembersQuery: Ks,
514
- useListRbacGroupsQuery: Ws,
515
- useListRbacRoleTemplatesQuery: Ys,
516
- useListRbacSystemsQuery: Js,
517
- useListRealmRolePermissionsQuery: Xs,
518
- useListSystemRolesQuery: Zs,
519
- usePreviewRbacChangeMutation: et,
520
- usePreviewRbacImportMutation: st,
521
- usePreviewRbacRealmExportDriftMutation: tt,
522
- usePreviewRbacSyncMutation: at,
523
- useRemoveGroupPermissionMutation: rt,
524
- useRemoveRbacGroupMemberMutation: ot,
525
- useRemoveGroupRealmRoleMutation: nt,
526
- useRemoveGroupSystemRoleMutation: it,
527
- useRemoveRealmRolePermissionMutation: lt,
528
- useRemoveSystemAccessRoleMutation: dt,
529
- useRemoveSystemRolePermissionMutation: ct,
530
- useSimulateRbacAccessMutation: ut,
531
- useSyncRbacGroupMembersMutation: mt,
532
- useUpdateUserAccessMutation: Ve,
533
- useUpdateRbacPermissionMetadataMutation: pt,
534
- useUpdateRbacSystemMutation: yt,
535
- useRegisterRbacSystemMutation: Rt,
536
- useTransitionRbacSystemMutation: ht,
537
- useUpdateSystemRoleMutation: gt,
538
- useUpsertRbacGroupMutation: ft,
539
- useReplaceRbacGroupMembersMutation: bt
540
- } = Qe, P = "/admin/health-contexts", je = ye.injectEndpoints({
541
- endpoints: (t) => ({
542
- listHealthContexts: t.query({
543
- query: (e) => {
544
- const s = new URLSearchParams();
545
- e?.includeDisabled && s.set("includeDisabled", "true"), e?.type && s.set("type", e.type);
546
- const a = s.toString();
547
- return `${P}${a ? `?${a}` : ""}`;
548
- },
549
- transformResponse: (e) => e.data,
550
- providesTags: [{ type: "HealthContext", id: "LIST" }]
551
- }),
552
- createHealthContext: t.mutation({
553
- query: (e) => ({ url: P, method: "POST", body: e }),
554
- transformResponse: (e) => e.data,
555
- invalidatesTags: [{ type: "HealthContext", id: "LIST" }]
556
- }),
557
- updateHealthContext: t.mutation({
558
- query: ({ contextId: e, body: s }) => ({
559
- url: `${P}/${encodeURIComponent(e)}`,
560
- method: "PUT",
561
- body: s
562
- }),
563
- transformResponse: (e) => e.data,
564
- invalidatesTags: (e, s, { contextId: a }) => [
565
- { type: "HealthContext", id: "LIST" },
566
- { type: "HealthContext", id: a }
567
- ]
568
- }),
569
- deleteHealthContext: t.mutation({
570
- query: (e) => ({
571
- url: `${P}/${encodeURIComponent(e)}`,
572
- method: "DELETE"
573
- }),
574
- invalidatesTags: [{ type: "HealthContext", id: "LIST" }]
575
- }),
576
- listHealthContextAliases: t.query({
577
- query: (e) => `${P}/${encodeURIComponent(e)}/aliases`,
578
- transformResponse: (e) => e.data,
579
- providesTags: (e, s, a) => [
580
- { type: "HealthContext", id: `${a}:aliases` }
581
- ]
582
- }),
583
- upsertHealthContextAlias: t.mutation({
584
- query: ({ contextId: e, ...s }) => ({
585
- url: `${P}/${encodeURIComponent(e)}/aliases`,
586
- method: "PUT",
587
- body: s
588
- }),
589
- transformResponse: (e) => e.data,
590
- invalidatesTags: (e, s, { contextId: a }) => [
591
- { type: "HealthContext", id: `${a}:aliases` }
592
- ]
593
- }),
594
- deleteHealthContextAlias: t.mutation({
595
- query: ({ contextId: e, aliasId: s }) => ({
596
- url: `${P}/${encodeURIComponent(e)}/aliases/${encodeURIComponent(s)}`,
597
- method: "DELETE"
598
- }),
599
- invalidatesTags: (e, s, { contextId: a }) => [
600
- { type: "HealthContext", id: `${a}:aliases` }
601
- ]
602
- }),
603
- listUserHealthContexts: t.query({
604
- query: (e) => `/admin/users/${encodeURIComponent(e)}/health-contexts`,
605
- transformResponse: (e) => e.data,
606
- providesTags: (e, s, a) => [
607
- { type: "HealthContext", id: `user:${a}` }
608
- ]
609
- }),
610
- replaceUserHealthContexts: t.mutation({
611
- query: ({ targetId: e, assignments: s }) => ({
612
- url: `/admin/users/${encodeURIComponent(e)}/health-contexts`,
613
- method: "PUT",
614
- body: { assignments: s }
615
- }),
616
- invalidatesTags: (e, s, { targetId: a }) => [
617
- { type: "HealthContext", id: `user:${a}` }
618
- ]
619
- }),
620
- listGroupHealthContexts: t.query({
621
- query: (e) => `/admin/rbac/groups/${encodeURIComponent(e)}/health-contexts`,
622
- transformResponse: (e) => e.data,
623
- providesTags: (e, s, a) => [
624
- { type: "HealthContext", id: `group:${a}` }
625
- ]
626
- }),
627
- replaceGroupHealthContexts: t.mutation({
628
- query: ({ targetId: e, assignments: s }) => ({
629
- url: `/admin/rbac/groups/${encodeURIComponent(e)}/health-contexts`,
630
- method: "PUT",
631
- body: { assignments: s }
632
- }),
633
- invalidatesTags: (e, s, { targetId: a }) => [
634
- { type: "HealthContext", id: `group:${a}` }
635
- ]
636
- }),
637
- getHealthContextDrift: t.query({
638
- query: () => `${P}/drift`,
639
- transformResponse: (e) => e.data,
640
- providesTags: [{ type: "HealthContext", id: "DRIFT" }]
641
- }),
642
- previewHealthContextSync: t.mutation({
643
- query: (e) => ({
644
- url: `${P}/sync/preview`,
645
- method: "POST",
646
- body: e
647
- }),
648
- transformResponse: (e) => e.data
649
- }),
650
- applyHealthContextSync: t.mutation({
651
- query: (e) => ({
652
- url: `${P}/sync/apply`,
653
- method: "POST",
654
- body: e
655
- }),
656
- transformResponse: (e) => e.data,
657
- invalidatesTags: [
658
- { type: "HealthContext", id: "DRIFT" },
659
- { type: "HealthContext", id: "LIST" }
660
- ]
661
- })
662
- })
663
- }), {
664
- useApplyHealthContextSyncMutation: Tt,
665
- useCreateHealthContextMutation: St,
666
- useDeleteHealthContextAliasMutation: Ct,
667
- useDeleteHealthContextMutation: vt,
668
- useListGroupHealthContextsQuery: $t,
669
- useGetHealthContextDriftQuery: It,
670
- useListHealthContextAliasesQuery: Ut,
671
- useListHealthContextsQuery: qt,
672
- useListUserHealthContextsQuery: At,
673
- useReplaceGroupHealthContextsMutation: Lt,
674
- useReplaceUserHealthContextsMutation: Pt,
675
- usePreviewHealthContextSyncMutation: wt,
676
- useUpdateHealthContextMutation: Mt,
677
- useUpsertHealthContextAliasMutation: _t
678
- } = je;
679
- function Ke({ userId: t }) {
680
- const e = X(), { data: s, isLoading: a, isFetching: c, isError: d, error: l, refetch: h } = Be(t), [g, { isLoading: f }] = Ve(), [$, _] = T([]), [I, x] = T({});
681
- J(() => {
682
- s && (_(s.directAccess?.realmRoles ?? s.effectiveAccess.realmRoles ?? []), x(s.directAccess?.clientRoles ?? s.effectiveAccess.clientRoles ?? {}));
683
- }, [s]);
684
- const U = M(
685
- () => (s?.assignable.realmRoles ?? []).map((n) => ({
686
- id: n.name,
687
- text: n.displayName || n.name
688
- })),
689
- [s?.assignable.realmRoles]
690
- ), E = M(
691
- () => We(s?.effectiveAccess.permissions ?? []),
692
- [s?.effectiveAccess.permissions]
693
- ), q = M(
694
- () => (s?.effectiveAccess.grantSources ?? []).filter(
695
- (n) => n.grantedByType.startsWith("group")
696
- ),
697
- [s?.effectiveAccess.grantSources]
698
- ), G = M(() => Ye(q), [q]), w = (n, y) => {
699
- x((A) => ({
700
- ...A,
701
- [n.clientId]: y
702
- }));
703
- }, N = async () => {
704
- try {
705
- await g({
706
- userId: t,
707
- data: {
708
- realmRoles: $,
709
- clientRoles: I
710
- }
711
- }).unwrap(), e.success("Access updated", "User roles and effective permissions were updated.");
712
- } catch (n) {
713
- e.error("Access update failed", ie(n, "Unable to update user access."));
714
- }
715
- };
716
- return a ? /* @__PURE__ */ r(k, { description: "Loading user access..." }) : d || !s ? /* @__PURE__ */ u(C, { gap: 4, children: [
717
- /* @__PURE__ */ r(
718
- me,
719
- {
720
- title: "Unable to load user access",
721
- subtitle: ie(l, "Check RBAC configuration and try again.")
722
- }
723
- ),
724
- /* @__PURE__ */ r(v, { kind: "secondary", size: "sm", onClick: () => h(), children: "Retry" })
725
- ] }) : /* @__PURE__ */ u(C, { gap: 5, children: [
726
- c && /* @__PURE__ */ r(k, { description: "Refreshing access profile..." }),
727
- /* @__PURE__ */ r(z, { children: /* @__PURE__ */ u(C, { gap: 4, children: [
728
- /* @__PURE__ */ r("strong", { children: "Realm roles" }),
729
- /* @__PURE__ */ r("small", { children: "These are direct user realm roles. Group-derived roles are shown as inherited access below." }),
730
- /* @__PURE__ */ r(
731
- W,
732
- {
733
- id: `user-${t}-realm-roles`,
734
- titleText: "Realm roles",
735
- label: "Select realm roles",
736
- items: U,
737
- itemToString: (n) => n?.text ?? "",
738
- selectedItems: U.filter((n) => $.includes(n.id)),
739
- onChange: ({ selectedItems: n }) => {
740
- _((n ?? []).map((y) => y.id));
741
- }
742
- }
743
- )
744
- ] }) }),
745
- /* @__PURE__ */ r(z, { children: /* @__PURE__ */ u(C, { gap: 5, children: [
746
- /* @__PURE__ */ r("strong", { children: "System roles and app access" }),
747
- /* @__PURE__ */ r("small", { children: "These are direct user system roles. Group-derived system roles are read-only in the inherited access section." }),
748
- s.assignable.systems.map((n) => {
749
- const y = n.roles.map((i) => ({
750
- id: i.name,
751
- text: i.displayName || i.name
752
- })), A = I[n.clientId] ?? [];
753
- return /* @__PURE__ */ u(C, { gap: 3, children: [
754
- /* @__PURE__ */ u("div", { children: [
755
- /* @__PURE__ */ r("strong", { children: n.displayName || n.clientId }),
756
- /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r("small", { children: n.clientId }) })
757
- ] }),
758
- /* @__PURE__ */ r(
759
- W,
760
- {
761
- id: `user-${t}-${n.clientId}-roles`,
762
- titleText: "System roles",
763
- label: "Select system roles",
764
- items: y,
765
- itemToString: (i) => i?.text ?? "",
766
- selectedItems: y.filter((i) => A.includes(i.id)),
767
- onChange: ({ selectedItems: i }) => {
768
- w(
769
- n,
770
- (i ?? []).map((b) => b.id)
771
- );
772
- }
773
- }
774
- ),
775
- n.accessRoles.length > 0 && /* @__PURE__ */ u("div", { children: [
776
- /* @__PURE__ */ r("small", { children: "App access roles" }),
777
- /* @__PURE__ */ r(ne, { values: n.accessRoles, type: "cyan" })
778
- ] })
779
- ] }, n.clientId);
780
- })
781
- ] }) }),
782
- /* @__PURE__ */ r(z, { children: /* @__PURE__ */ u(C, { gap: 4, children: [
783
- /* @__PURE__ */ r("strong", { children: "Groups and inherited access" }),
784
- s.effectiveAccess.groups && s.effectiveAccess.groups.length > 0 ? /* @__PURE__ */ r("div", { className: "user-access-group-list", children: s.effectiveAccess.groups.map((n) => /* @__PURE__ */ u("div", { className: "user-access-group", children: [
785
- /* @__PURE__ */ u("div", { children: [
786
- /* @__PURE__ */ r("strong", { children: n.displayName || n.name || n.path }),
787
- /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r("small", { children: n.path }) })
788
- ] }),
789
- /* @__PURE__ */ r(Y, { size: "sm", type: "purple", children: "Inherited" }),
790
- /* @__PURE__ */ u("small", { children: [
791
- "Inherited from group ",
792
- n.displayName || n.name || n.path,
793
- ". Edit the group or Keycloak membership to change this access."
794
- ] }),
795
- /* @__PURE__ */ r(Je, { sources: G[n.id] ?? [] })
796
- ] }, n.id || n.path)) }) : /* @__PURE__ */ r("small", { children: "No Keycloak groups are synced for this user." })
797
- ] }) }),
798
- /* @__PURE__ */ r(z, { children: /* @__PURE__ */ u(C, { gap: 4, children: [
799
- /* @__PURE__ */ r("strong", { children: "Effective permissions" }),
800
- Object.entries(E).map(([n, y]) => /* @__PURE__ */ u("div", { children: [
801
- /* @__PURE__ */ r("small", { children: n }),
802
- /* @__PURE__ */ r(ne, { values: y.map((A) => A.key), type: "green" })
803
- ] }, n)),
804
- s.effectiveAccess.permissions.length === 0 && /* @__PURE__ */ r("small", { children: "No permissions resolved for this user." })
805
- ] }) }),
806
- /* @__PURE__ */ r(v, { kind: "primary", disabled: f, onClick: N, children: f ? "Saving access..." : "Save access" })
807
- ] });
808
- }
809
- function We(t) {
810
- return t.reduce((e, s) => {
811
- const a = s.category || s.key.split(":")[0] || "other";
812
- return e[a] = [...e[a] ?? [], s], e;
813
- }, {});
814
- }
815
- function ne({ values: t, type: e }) {
816
- return /* @__PURE__ */ r("div", { className: "user-access-tag-list", children: t.map((s) => /* @__PURE__ */ r(Y, { size: "sm", type: e, children: s }, s)) });
817
- }
818
- function Ye(t) {
819
- return t.reduce((e, s) => {
820
- const a = s.groupId || "unknown";
821
- return e[a] = [...e[a] ?? [], s], e;
822
- }, {});
823
- }
824
- function Je({ sources: t }) {
825
- return t.length === 0 ? /* @__PURE__ */ r("small", { children: "Groups synced, but no group-derived permissions are mapped yet." }) : /* @__PURE__ */ r("div", { className: "user-access-inherited-list", children: t.map((e) => /* @__PURE__ */ u(
826
- Y,
827
- {
828
- size: "sm",
829
- type: "purple",
830
- children: [
831
- e.permissionKey,
832
- e.role ? ` via ${e.role}` : "",
833
- e.systemName || e.systemClientId ? ` (${e.systemName || e.systemClientId})` : ""
834
- ]
835
- },
836
- `${e.grantedByType}-${e.permissionKey}-${e.role}-${e.systemClientId ?? ""}`
837
- )) });
838
- }
839
- function ie(t, e) {
840
- if (!t || typeof t != "object")
841
- return e;
842
- const s = t;
843
- return typeof s.data?.message == "string" ? s.data.message : typeof s.data?.error?.message == "string" ? s.data.error.message : typeof s.error == "string" ? s.error : e;
844
- }
845
- const le = (t) => ({
846
- username: t?.username ?? "",
847
- email: t?.email ?? "",
848
- firstName: t?.firstName ?? "",
849
- lastName: t?.lastName ?? "",
850
- realmRoles: t?.realmRoles ?? [],
851
- enabled: t?.enabled ?? t?.isActive ?? !0,
852
- emailVerified: t?.emailVerified ?? !0
853
- });
854
- function Xe({ mode: t, initialUser: e, onSuccess: s }) {
855
- const a = ce(ue), c = t === "edit" && e?.id === a?.id, d = X(), [l, h] = T(() => le(e)), [g, f] = T(null), [$, { isLoading: _ }] = Ne(), [I, { isLoading: x }] = De(), { data: U, isLoading: E } = ze(), q = _ || x, G = M(
856
- () => (U?.realmRoles ?? []).map((i) => ({
857
- id: i.name,
858
- text: i.displayName || i.name
859
- })),
860
- [U?.realmRoles]
861
- );
862
- J(() => {
863
- h(le(e)), f(null);
864
- }, [e, t]);
865
- const w = (i) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i), N = () => ({
866
- email: l.email.trim().toLowerCase(),
867
- firstName: l.firstName.trim(),
868
- lastName: l.lastName.trim(),
869
- realmRoles: l.realmRoles,
870
- enabled: l.enabled,
871
- emailVerified: l.emailVerified
872
- }), n = M(() => !(!l.username.trim() || !l.firstName.trim() || !l.lastName.trim() || !w(l.email)), [l]), y = (i, b) => {
873
- h((O) => ({ ...O, [i]: b }));
874
- }, A = async () => {
875
- if (!(!n || q)) {
876
- f(null);
877
- try {
878
- t === "create" ? (await $({
879
- username: l.username.trim().toLowerCase(),
880
- ...N()
881
- }).unwrap(), d.success("User created", `User "${l.username}" was created successfully`)) : e?.id && (await I({
882
- id: e.id,
883
- data: N()
884
- }).unwrap(), d.success("User updated", `Changes to "${l.username}" were saved`)), s?.();
885
- } catch (i) {
886
- const b = Ze(i) ?? (t === "create" ? "Failed to create user" : "Failed to update user");
887
- f(b), d.error("Operation failed", "Please review the form and try again");
888
- }
889
- }
890
- };
891
- return /* @__PURE__ */ r(Ce, { children: /* @__PURE__ */ u(C, { gap: 6, children: [
892
- g && /* @__PURE__ */ r(me, { title: "Unable to save user", subtitle: g }),
893
- /* @__PURE__ */ r(se, { legendText: "User details", children: /* @__PURE__ */ u(C, { gap: 4, children: [
894
- /* @__PURE__ */ r(
895
- B,
896
- {
897
- id: "username",
898
- labelText: "Username",
899
- required: !0,
900
- disabled: t === "edit",
901
- helperText: t === "edit" ? "Username cannot be changed" : void 0,
902
- value: l.username,
903
- onChange: (i) => {
904
- y("username", i.target.value.toLowerCase());
905
- }
906
- }
907
- ),
908
- /* @__PURE__ */ r(
909
- B,
910
- {
911
- id: "email",
912
- labelText: "Email",
913
- type: "email",
914
- required: !0,
915
- value: l.email,
916
- invalid: !!l.email && !w(l.email),
917
- invalidText: "Enter a valid email address",
918
- onChange: (i) => {
919
- y("email", i.target.value);
920
- }
921
- }
922
- ),
923
- /* @__PURE__ */ r(
924
- B,
925
- {
926
- id: "firstName",
927
- labelText: "First name",
928
- required: !0,
929
- value: l.firstName,
930
- onChange: (i) => {
931
- y("firstName", i.target.value);
932
- }
933
- }
934
- ),
935
- /* @__PURE__ */ r(
936
- B,
937
- {
938
- id: "lastName",
939
- labelText: "Last name",
940
- required: !0,
941
- value: l.lastName,
942
- onChange: (i) => {
943
- y("lastName", i.target.value);
944
- }
945
- }
946
- )
947
- ] }) }),
948
- /* @__PURE__ */ r(se, { legendText: "Access control", children: /* @__PURE__ */ u(C, { gap: 4, children: [
949
- /* @__PURE__ */ r(
950
- W,
951
- {
952
- id: "realmRoles",
953
- titleText: "Realm roles",
954
- label: E ? "Loading realm roles..." : "Realm roles",
955
- items: G,
956
- itemToString: (i) => i?.text ?? "",
957
- selectedItems: G.filter((i) => l.realmRoles.includes(i.id)),
958
- disabled: E,
959
- onChange: ({ selectedItems: i }) => {
960
- y(
961
- "realmRoles",
962
- (i ?? []).map((b) => b.id)
963
- );
964
- }
965
- }
966
- ),
967
- /* @__PURE__ */ r(
968
- te,
969
- {
970
- id: "enabled",
971
- labelText: "User enabled",
972
- disabled: c,
973
- checked: l.enabled,
974
- onChange: (i, { checked: b }) => {
975
- y("enabled", b);
976
- }
977
- }
978
- ),
979
- /* @__PURE__ */ r(
980
- te,
981
- {
982
- id: "emailVerified",
983
- labelText: "Email verified",
984
- checked: l.emailVerified,
985
- onChange: (i, { checked: b }) => {
986
- y("emailVerified", b);
987
- }
988
- }
989
- )
990
- ] }) }),
991
- /* @__PURE__ */ r(C, { orientation: "horizontal", gap: 3, children: /* @__PURE__ */ r(v, { kind: "primary", disabled: !n || q, onClick: A, children: q ? /* @__PURE__ */ r(
992
- k,
993
- {
994
- description: t === "create" ? "Creating user…" : "Saving changes…"
995
- }
996
- ) : t === "create" ? "Create user" : "Save changes" }) })
997
- ] }) });
998
- }
999
- function Ze(t) {
1000
- if (!t || typeof t != "object")
1001
- return;
1002
- const e = t;
1003
- if (typeof e.data?.message == "string")
1004
- return e.data.message;
1005
- if (typeof e.data?.error?.message == "string")
1006
- return e.data.error.message;
1007
- if (typeof e.error == "string")
1008
- return e.error;
1009
- }
1010
- function es({ username: t, enabled: e, onConfirm: s, onCancel: a }) {
1011
- const [c, d] = T(!1);
1012
- async function l() {
1013
- try {
1014
- d(!0), await s();
1015
- } finally {
1016
- d(!1);
1017
- }
1018
- }
1019
- return /* @__PURE__ */ u("div", { className: "user-confirm-modal", children: [
1020
- /* @__PURE__ */ u("p", { children: [
1021
- "Are you sure you want to ",
1022
- /* @__PURE__ */ r("strong", { children: e ? "disable" : "enable" }),
1023
- " the user",
1024
- " ",
1025
- /* @__PURE__ */ r("strong", { children: t }),
1026
- "?"
1027
- ] }),
1028
- /* @__PURE__ */ r("p", { className: "user-confirm-modal__description", children: e ? "The user will no longer be able to log in." : "The user will regain access to the platform." }),
1029
- c && /* @__PURE__ */ r(k, { description: e ? "Disabling user…" : "Enabling user…" }),
1030
- /* @__PURE__ */ u("div", { className: "user-confirm-modal__actions", children: [
1031
- /* @__PURE__ */ r(v, { kind: "secondary", onClick: a, disabled: c, children: "Cancel" }),
1032
- /* @__PURE__ */ r(v, { kind: e ? "danger" : "primary", onClick: l, disabled: c, children: e ? "Disable user" : "Enable user" })
1033
- ] })
1034
- ] });
1035
- }
1036
- function ss() {
1037
- const { openModal: t, closeModal: e } = pe();
1038
- function s({ username: a, enabled: c, onConfirm: d }) {
1039
- t({
1040
- title: c ? "Disable user" : "Enable user",
1041
- size: "sm",
1042
- content: /* @__PURE__ */ r(
1043
- es,
1044
- {
1045
- username: a,
1046
- enabled: c,
1047
- onConfirm: async () => {
1048
- await d(), e();
1049
- },
1050
- onCancel: e
1051
- }
1052
- ),
1053
- onClose: e
1054
- });
1055
- }
1056
- return { openEnableUserModal: s };
1057
- }
1058
- function ts({
1059
- username: t,
1060
- email: e,
1061
- onConfirm: s,
1062
- onCancel: a
1063
- }) {
1064
- const [c, d] = T(!1);
1065
- async function l() {
1066
- try {
1067
- d(!0), await s();
1068
- } finally {
1069
- d(!1);
1070
- }
1071
- }
1072
- return /* @__PURE__ */ u("div", { className: "user-confirm-modal", children: [
1073
- /* @__PURE__ */ u("p", { children: [
1074
- "This will initiate a password reset for ",
1075
- /* @__PURE__ */ r("strong", { children: t }),
1076
- "."
1077
- ] }),
1078
- /* @__PURE__ */ r("p", { className: "user-confirm-modal__description", children: e ? `A password reset email will be sent to ${e}.` : "The user will be required to set a new password on next login." }),
1079
- c && /* @__PURE__ */ r(k, { description: "Sending password reset…" }),
1080
- /* @__PURE__ */ u("div", { className: "user-confirm-modal__actions", children: [
1081
- /* @__PURE__ */ r(v, { kind: "secondary", onClick: a, disabled: c, children: "Cancel" }),
1082
- /* @__PURE__ */ r(v, { kind: "danger", onClick: l, disabled: c, children: "Reset password" })
1083
- ] })
1084
- ] });
1085
- }
1086
- function as() {
1087
- const { openModal: t, closeModal: e } = pe();
1088
- function s({ username: a, email: c, onConfirm: d }) {
1089
- t({
1090
- title: "Reset password",
1091
- size: "sm",
1092
- content: /* @__PURE__ */ r(
1093
- ts,
1094
- {
1095
- username: a,
1096
- email: c,
1097
- onConfirm: async () => {
1098
- await d(), e();
1099
- },
1100
- onCancel: e
1101
- }
1102
- ),
1103
- onClose: e
1104
- });
1105
- }
1106
- return { openResetPasswordModal: s };
1107
- }
1108
- function rs({
1109
- onReset: t,
1110
- status: e,
1111
- roles: s,
1112
- selectedRole: a,
1113
- neverLoggedIn: c,
1114
- onStatusChange: d,
1115
- onRoleChange: l,
1116
- onToggleNeverLoggedIn: h
1117
- }) {
1118
- return /* @__PURE__ */ u(C, { orientation: "horizontal", gap: 5, className: "user-filters", children: [
1119
- /* @__PURE__ */ r(
1120
- ae,
1121
- {
1122
- id: "user-status-filter",
1123
- label: "Status",
1124
- titleText: "Status",
1125
- items: ["all", "active", "disabled"],
1126
- selectedItem: e,
1127
- className: "user-filters__field--status",
1128
- onChange: ({ selectedItem: g }) => {
1129
- d(g);
1130
- }
1131
- }
1132
- ),
1133
- /* @__PURE__ */ r(
1134
- ae,
1135
- {
1136
- id: "user-role-filter",
1137
- label: "Role",
1138
- titleText: "Role",
1139
- items: s,
1140
- selectedItem: a,
1141
- className: "user-filters__field--role",
1142
- onChange: ({ selectedItem: g }) => {
1143
- l(g);
1144
- }
1145
- }
1146
- ),
1147
- /* @__PURE__ */ r(
1148
- v,
1149
- {
1150
- kind: c ? "primary" : "secondary",
1151
- size: "md",
1152
- "aria-pressed": c,
1153
- onClick: h,
1154
- children: "Never logged in"
1155
- }
1156
- ),
1157
- /* @__PURE__ */ r(v, { kind: "ghost", size: "md", onClick: t, children: "Clear filters" })
1158
- ] });
1159
- }
1160
- function os({
1161
- user: t,
1162
- isCurrentUser: e = !1,
1163
- onEdit: s,
1164
- onManageRoles: a,
1165
- onToggleStatus: c,
1166
- onResetPassword: d
1167
- }) {
1168
- return /* @__PURE__ */ u(ve, { size: "sm", flipped: !0, onClick: (h) => {
1169
- h.stopPropagation();
1170
- }, children: [
1171
- /* @__PURE__ */ r(V, { itemText: "Edit user", hasDivider: !0, onClick: s }),
1172
- /* @__PURE__ */ r(V, { itemText: "Manage roles", hasDivider: !0, onClick: a }),
1173
- /* @__PURE__ */ r(
1174
- V,
1175
- {
1176
- itemText: e ? "Cannot disable your own account" : t.isActive ? "Disable user" : "Enable user",
1177
- disabled: e,
1178
- isDelete: t.isActive,
1179
- onClick: c
1180
- }
1181
- ),
1182
- /* @__PURE__ */ r(V, { itemText: "Reset password", hasDivider: !0, onClick: d })
1183
- ] });
1184
- }
1185
- function ns({
1186
- users: t,
1187
- currentUserId: e,
1188
- loadingAction: s,
1189
- onEnable: a,
1190
- onDisable: c
1191
- }) {
1192
- if (t.length === 0) return null;
1193
- const d = t.every((f) => f.isActive), l = t.every((f) => !f.isActive), h = s !== null, g = t.some((f) => f.id === e);
1194
- return /* @__PURE__ */ u(de, { children: [
1195
- /* @__PURE__ */ u($e, { className: "user-bulk-actions", children: [
1196
- /* @__PURE__ */ r(v, { kind: "secondary", disabled: d || h, onClick: a, children: s === "enable" ? /* @__PURE__ */ r(k, { description: "Enabling…" }) : `Enable (${t.length})` }),
1197
- /* @__PURE__ */ r(
1198
- v,
1199
- {
1200
- kind: "danger",
1201
- disabled: l || h || g,
1202
- onClick: c,
1203
- children: s === "disable" ? /* @__PURE__ */ r(k, { description: "Disabling…" }) : `Disable (${t.length})`
1204
- }
1205
- )
1206
- ] }),
1207
- g && /* @__PURE__ */ r("p", { children: "Deselect your account to disable other users. You cannot disable your own account." })
1208
- ] });
1209
- }
1210
- const is = [
1211
- { key: "username", header: "Username" },
1212
- { key: "email", header: "Email" },
1213
- { key: "status", header: "Status" },
1214
- { key: "verified", header: "Email verified" },
1215
- { key: "lastLogin", header: "Last login" },
1216
- { key: "actions", header: "" },
1217
- { key: "raw", header: "" }
1218
- ];
1219
- function ls() {
1220
- const t = ce(ue), { openPanel: e, closePanel: s } = Me(), { openEnableUserModal: a } = ss(), { openResetPasswordModal: c } = as(), d = X(), [l, h] = T(null), [g, f] = T(""), [$, _] = T("all"), [I, x] = T("all"), [U, E] = T(!1), [q, G] = T(1), [w, N] = T(10), { data: n = [], isLoading: y, isError: A, error: i, refetch: b } = He(), [O] = Oe(), [Re] = Fe();
1221
- J(() => {
1222
- G(1);
1223
- }, [$, I, U, g]);
1224
- const he = M(() => {
1225
- const p = /* @__PURE__ */ new Set();
1226
- return n.forEach((S) => {
1227
- S.realmRoles?.forEach((D) => p.add(D));
1228
- }), ["all", ...Array.from(p)];
1229
- }, [n]), Q = M(() => {
1230
- const p = g.trim().toLowerCase();
1231
- return n.filter((S) => {
1232
- if (p && ![S.username, S.email, S.firstName, S.lastName].some(
1233
- (j) => j?.toLowerCase().includes(p)
1234
- ))
1235
- return !1;
1236
- const D = S.enabled ?? S.isActive ?? !1;
1237
- return !($ === "active" && !D || $ === "disabled" && D || U && S.lastLoginAt || I !== "all" && !S.realmRoles?.includes(I));
1238
- });
1239
- }, [n, $, I, U, g]), ge = M(() => {
1240
- const p = (q - 1) * w;
1241
- return Q.slice(p, p + w);
1242
- }, [Q, q, w]).map((p) => ({
1243
- id: p.id,
1244
- username: p.username,
1245
- email: p.email ?? "—",
1246
- status: p.enabled ?? p.isActive ? "Active" : "Disabled",
1247
- verified: p.emailVerified ? "Verified" : "Not verified",
1248
- lastLogin: p.lastLoginAt ? new Date(p.lastLoginAt).toLocaleString() : "Never",
1249
- actions: "",
1250
- raw: p
1251
- })), Z = () => {
1252
- f(""), _("all"), x("all"), E(!1);
1253
- };
1254
- return /* @__PURE__ */ r(
1255
- _e,
1256
- {
1257
- title: "Users",
1258
- description: "Manage users, roles, and access to applications.",
1259
- rows: ge,
1260
- headers: is,
1261
- getRowId: (p) => p.id,
1262
- isLoading: y,
1263
- loadingDescription: "Loading users…",
1264
- tableState: A ? /* @__PURE__ */ r(
1265
- ke,
1266
- {
1267
- title: "Failed to load users",
1268
- description: K(i, "Failed to load users"),
1269
- primaryAction: { label: "Retry", onClick: b }
1270
- }
1271
- ) : void 0,
1272
- searchValue: g,
1273
- onSearch: f,
1274
- searchPlaceholder: "Search users by name or email",
1275
- resultsDescription: !y && !A ? `${Q.length} of ${n.length} users` : void 0,
1276
- emptyActions: /* @__PURE__ */ r(v, { kind: "ghost", onClick: Z, children: "Clear filters" }),
1277
- emptyTitle: "No users found",
1278
- emptyDescription: "No users match the selected filters.",
1279
- filters: /* @__PURE__ */ r(
1280
- rs,
1281
- {
1282
- onReset: Z,
1283
- status: $,
1284
- roles: he,
1285
- selectedRole: I,
1286
- neverLoggedIn: U,
1287
- onStatusChange: _,
1288
- onRoleChange: x,
1289
- onToggleNeverLoggedIn: () => {
1290
- E((p) => !p);
1291
- }
1292
- }
1293
- ),
1294
- children: ({ rows: p, headers: S }) => /* @__PURE__ */ r(Ie, { rows: p, headers: S, children: ({ rows: D, headers: j, getHeaderProps: fe, getRowProps: be, getSelectionProps: ee, selectedRows: Te }) => {
1295
- const H = Te.map(
1296
- (R) => R.cells.find((m) => m.info.header === "raw")?.value
1297
- );
1298
- return /* @__PURE__ */ u(de, { children: [
1299
- /* @__PURE__ */ r(
1300
- ns,
1301
- {
1302
- users: H,
1303
- currentUserId: t?.id,
1304
- loadingAction: l,
1305
- onEnable: async () => {
1306
- try {
1307
- h("enable"), await Promise.all(
1308
- H.map((R) => O({ id: R.id, enabled: !0 }).unwrap())
1309
- ), d.success({
1310
- title: "Users enabled",
1311
- subtitle: `${H.length} user(s) enabled.`
1312
- });
1313
- } catch {
1314
- d.error({
1315
- title: "Enable failed",
1316
- subtitle: "Some users could not be enabled."
1317
- });
1318
- } finally {
1319
- h(null);
1320
- }
1321
- },
1322
- onDisable: async () => {
1323
- if (H.some((R) => R.id === t?.id)) {
1324
- d.error({
1325
- title: "Cannot disable your own account",
1326
- subtitle: "Deselect your account before disabling other users."
1327
- });
1328
- return;
1329
- }
1330
- try {
1331
- h("disable"), await Promise.all(
1332
- H.map((R) => O({ id: R.id, enabled: !1 }).unwrap())
1333
- ), d.warning({
1334
- title: "Users disabled",
1335
- subtitle: `${H.length} user(s) disabled.`
1336
- });
1337
- } catch {
1338
- d.error({
1339
- title: "Disable failed",
1340
- subtitle: "Some users could not be disabled."
1341
- });
1342
- } finally {
1343
- h(null);
1344
- }
1345
- }
1346
- }
1347
- ),
1348
- /* @__PURE__ */ u(Ue, { children: [
1349
- /* @__PURE__ */ r(qe, { children: /* @__PURE__ */ u(re, { children: [
1350
- /* @__PURE__ */ r(Ae, { ...ee() }),
1351
- j.filter((R) => R.key !== "raw").map((R) => /* @__PURE__ */ r(Le, { ...fe({ header: R }), children: R.header }))
1352
- ] }) }),
1353
- /* @__PURE__ */ r(Pe, { children: D.map((R) => {
1354
- const m = R.cells.find((L) => L.info.header === "raw")?.value;
1355
- return /* @__PURE__ */ u(re, { ...be({ row: R }), children: [
1356
- /* @__PURE__ */ r(we, { ...ee({ row: R }) }),
1357
- R.cells.map((L) => L.info.header === "raw" ? null : L.info.header === "status" ? /* @__PURE__ */ r(oe, { children: /* @__PURE__ */ r(
1358
- xe,
1359
- {
1360
- status: String(L.value),
1361
- kind: m.isAdmin ? "red" : "green"
1362
- }
1363
- ) }, L.id) : L.info.header === "actions" ? /* @__PURE__ */ r(Ee, { children: /* @__PURE__ */ r(
1364
- os,
1365
- {
1366
- user: m,
1367
- isCurrentUser: m.id === t?.id,
1368
- onEdit: () => {
1369
- e({
1370
- title: "Edit user",
1371
- content: /* @__PURE__ */ r(
1372
- Xe,
1373
- {
1374
- mode: "edit",
1375
- initialUser: m,
1376
- onSuccess: s
1377
- },
1378
- `edit-user-${m.id}`
1379
- ),
1380
- size: "md"
1381
- });
1382
- },
1383
- onManageRoles: () => {
1384
- e({
1385
- title: `Roles: ${m.username}`,
1386
- size: "lg",
1387
- content: /* @__PURE__ */ r(
1388
- Ke,
1389
- {
1390
- userId: m.id
1391
- },
1392
- `user-access-${m.id}`
1393
- )
1394
- });
1395
- },
1396
- onToggleStatus: () => {
1397
- const F = m.enabled ?? m.isActive ?? !1;
1398
- a({
1399
- username: m.username,
1400
- enabled: F,
1401
- onConfirm: async () => {
1402
- try {
1403
- await O({
1404
- id: m.id,
1405
- enabled: !F
1406
- }).unwrap(), d.success({
1407
- title: "User updated",
1408
- subtitle: `${m.username} ${F ? "disabled" : "enabled"}.`
1409
- });
1410
- } catch (Se) {
1411
- d.error({
1412
- title: "Update failed",
1413
- subtitle: K(
1414
- Se,
1415
- `Failed to update ${m.username}.`
1416
- )
1417
- });
1418
- }
1419
- }
1420
- });
1421
- },
1422
- onResetPassword: () => {
1423
- c({
1424
- username: m.username,
1425
- email: m.email,
1426
- onConfirm: async () => {
1427
- try {
1428
- await Re(m.id).unwrap(), d.success({
1429
- title: "Password reset sent",
1430
- subtitle: m.email ? `Reset email sent to ${m.email}.` : `Password reset started for ${m.username}.`
1431
- });
1432
- } catch (F) {
1433
- d.error({
1434
- title: "Password reset failed",
1435
- subtitle: K(
1436
- F,
1437
- `Failed to reset password for ${m.username}.`
1438
- )
1439
- });
1440
- }
1441
- }
1442
- });
1443
- }
1444
- }
1445
- ) }, L.id) : /* @__PURE__ */ r(oe, { children: L.value }, L.id))
1446
- ] });
1447
- }) })
1448
- ] }),
1449
- /* @__PURE__ */ r(
1450
- Ge,
1451
- {
1452
- page: q,
1453
- pageSize: w,
1454
- totalItems: Q.length,
1455
- onChange: ({ page: R, pageSize: m }) => {
1456
- G(R), N(m);
1457
- }
1458
- }
1459
- )
1460
- ] });
1461
- } })
1462
- }
1463
- );
1464
- }
1465
- function K(t, e) {
1466
- if (!t || typeof t != "object")
1467
- return e;
1468
- const s = t;
1469
- return typeof s.data?.message == "string" ? s.data.message : typeof s.data?.error?.message == "string" ? s.data.error.message : typeof s.error == "string" ? s.error : e;
1470
- }
1471
- function xt(t) {
1472
- return /* @__PURE__ */ r("div", { className: "moh-microfrontend-root", children: /* @__PURE__ */ r(ls, {}) });
1473
- }
1474
- export {
1475
- Xe as U,
1476
- ls as a,
1477
- xt as b
1478
- };
1479
- //# sourceMappingURL=root.component-DjmegrfS.js.map