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