@keycloak/keycloak-admin-ui 26.1.5 → 26.2.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 (103) hide show
  1. package/README.md +4 -4
  2. package/lib/.vite/manifest.json +51 -30
  3. package/lib/{CreateFlow-CJuPGQV2.js → CreateFlow-BkGiX0Bw.js} +9 -9
  4. package/lib/{CreateFlow-CJuPGQV2.js.map → CreateFlow-BkGiX0Bw.js.map} +1 -1
  5. package/lib/{DetailOrganization-BZxym2fM.js → DetailOrganization-CJKEEgO8.js} +33 -33
  6. package/lib/{DetailOrganization-BZxym2fM.js.map → DetailOrganization-CJKEEgO8.js.map} +1 -1
  7. package/lib/{ExecutorForm-DxyNT3T5.js → ExecutorForm-C9_CWJhw.js} +49 -48
  8. package/lib/ExecutorForm-C9_CWJhw.js.map +1 -0
  9. package/lib/FlowDetails-InWOgFIk.js +9025 -0
  10. package/lib/FlowDetails-InWOgFIk.js.map +1 -0
  11. package/lib/NewOrganization-D93k_LVb.js +36 -0
  12. package/lib/{NewOrganization-CdgyibqF.js.map → NewOrganization-D93k_LVb.js.map} +1 -1
  13. package/lib/PermissionConfigurationDetails-DPu0gttX.js +702 -0
  14. package/lib/PermissionConfigurationDetails-DPu0gttX.js.map +1 -0
  15. package/lib/{PermissionDetails-lynVHdOa.js → PermissionDetails-C4X5r4gF.js} +72 -72
  16. package/lib/{PermissionDetails-lynVHdOa.js.map → PermissionDetails-C4X5r4gF.js.map} +1 -1
  17. package/lib/RealmSection-DYc_8dbl.js +179 -0
  18. package/lib/RealmSection-DYc_8dbl.js.map +1 -0
  19. package/lib/ResourceDetails-BO8zlCP_.js +226 -0
  20. package/lib/ResourceDetails-BO8zlCP_.js.map +1 -0
  21. package/lib/{ScopeDetails-plfHXCXz.js → ScopeDetails-DyHGLML9.js} +35 -35
  22. package/lib/{ScopeDetails-plfHXCXz.js.map → ScopeDetails-DyHGLML9.js.map} +1 -1
  23. package/lib/ScopePicker-DxDYNCCh.js +85 -0
  24. package/lib/ScopePicker-DxDYNCCh.js.map +1 -0
  25. package/lib/authentication/components/AuthenticationProviderContext.d.ts +9 -0
  26. package/lib/authentication/components/FlowRow.d.ts +1 -0
  27. package/lib/authentication/components/FlowTitle.d.ts +5 -2
  28. package/lib/clients/add/SamlSignature.d.ts +1 -0
  29. package/lib/clients/authorization/ScopePicker.d.ts +5 -2
  30. package/lib/clients/authorization/policy/LogicSelector.d.ts +1 -1
  31. package/lib/clients/authorization/policy/NameDescription.d.ts +3 -2
  32. package/lib/clients/routes/PermissionConfigurationDetails.d.ts +10 -0
  33. package/lib/components/client/ClientSelect.d.ts +4 -2
  34. package/lib/components/dynamic/BooleanComponent.d.ts +1 -1
  35. package/lib/components/dynamic/DynamicComponents.d.ts +2 -1
  36. package/lib/components/dynamic/FileComponent.d.ts +1 -1
  37. package/lib/components/dynamic/GroupComponent.d.ts +1 -1
  38. package/lib/components/dynamic/IntComponent.d.ts +1 -1
  39. package/lib/components/dynamic/ListComponent.d.ts +1 -1
  40. package/lib/components/dynamic/MapComponent.d.ts +1 -1
  41. package/lib/components/dynamic/MultivaluedListComponent.d.ts +1 -1
  42. package/lib/components/dynamic/MultivaluedStringComponent.d.ts +1 -1
  43. package/lib/components/dynamic/NumberComponent.d.ts +1 -1
  44. package/lib/components/dynamic/PasswordComponent.d.ts +1 -1
  45. package/lib/components/dynamic/RoleComponent.d.ts +1 -1
  46. package/lib/components/dynamic/ScriptComponent.d.ts +1 -1
  47. package/lib/components/dynamic/StringComponent.d.ts +1 -1
  48. package/lib/components/dynamic/TextComponent.d.ts +1 -1
  49. package/lib/components/dynamic/UserProfileAttributeListComponent.d.ts +1 -1
  50. package/lib/components/dynamic/components.d.ts +1 -0
  51. package/lib/components/form/CodeEditor.d.ts +12 -0
  52. package/lib/components/role-mapping/AddRoleMappingModal.d.ts +1 -1
  53. package/lib/components/users/UserSelect.d.ts +1 -1
  54. package/lib/context/RecentRealms.d.ts +6 -2
  55. package/lib/i18n/i18n.d.ts +4 -0
  56. package/lib/{index-lFXE1rYJ.js → index-B5GgWXK6.js} +36279 -36318
  57. package/lib/{index-lFXE1rYJ.js.map → index-B5GgWXK6.js.map} +1 -1
  58. package/lib/index.d.ts +1 -2
  59. package/lib/keycloak-admin-ui.css +1 -1
  60. package/lib/keycloak-admin-ui.js +162 -163
  61. package/lib/organizations/IdentityProviderSelect.d.ts +1 -1
  62. package/lib/permissions-configuration/PermissionsConfigurationSection.d.ts +1 -0
  63. package/lib/permissions-configuration/permission-configuration/AssignedPolicies.d.ts +10 -0
  64. package/lib/permissions-configuration/permission-configuration/AuthorizationScopesDetails.d.ts +10 -0
  65. package/lib/permissions-configuration/permission-configuration/ExistingPoliciesDialog.d.ts +10 -0
  66. package/lib/permissions-configuration/permission-configuration/NewPermissionConfigurationDialog.d.ts +8 -0
  67. package/lib/permissions-configuration/permission-configuration/NewPermissionPolicyDialog.d.ts +13 -0
  68. package/lib/permissions-configuration/permission-configuration/PermissionConfigurationDetails.d.ts +1 -0
  69. package/lib/permissions-configuration/permission-configuration/PermissionsConfigurationTab.d.ts +5 -0
  70. package/lib/permissions-configuration/permission-evaluation/PermissionEvaluationResult.d.ts +6 -0
  71. package/lib/permissions-configuration/permission-evaluation/PermissionsEvaluationTab.d.ts +8 -0
  72. package/lib/permissions-configuration/resource-types/GroupSelect.d.ts +8 -0
  73. package/lib/permissions-configuration/resource-types/ResourceType.d.ts +11 -0
  74. package/lib/permissions-configuration/resource-types/RoleSelect.d.ts +5 -0
  75. package/lib/permissions-configuration/resource-types/SearchDropdown.d.ts +20 -0
  76. package/lib/permissions-configuration/routes/NewPermissionConfiguration.d.ts +9 -0
  77. package/lib/permissions-configuration/routes/NewPermissionPolicy.d.ts +9 -0
  78. package/lib/permissions-configuration/routes/PermissionConfigurationDetails.d.ts +10 -0
  79. package/lib/permissions-configuration/routes/PermissionPolicyDetails.d.ts +10 -0
  80. package/lib/permissions-configuration/routes/PermissionsConfiguration.d.ts +7 -0
  81. package/lib/permissions-configuration/routes/PermissionsConfigurationTabs.d.ts +10 -0
  82. package/lib/permissions-configuration/routes/PermissionsPolicies.d.ts +8 -0
  83. package/lib/realm/RealmRoutes.d.ts +7 -0
  84. package/lib/realm/RealmSection.d.ts +5 -0
  85. package/lib/realm/add/NewRealmForm.d.ts +5 -1
  86. package/lib/realm-settings/themes/ThemesTab.d.ts +1 -0
  87. package/lib/utils/useIsFeatureEnabled.d.ts +2 -1
  88. package/lib/utils/useSortedResourceTypes.d.ts +5 -0
  89. package/package.json +26 -37
  90. package/lib/ExecutorForm-DxyNT3T5.js.map +0 -1
  91. package/lib/FlowDetails-ChnCh0MX.js +0 -10786
  92. package/lib/FlowDetails-ChnCh0MX.js.map +0 -1
  93. package/lib/NewOrganization-CdgyibqF.js +0 -36
  94. package/lib/ResourceDetails-BBY9AcKD.js +0 -286
  95. package/lib/ResourceDetails-BBY9AcKD.js.map +0 -1
  96. package/lib/browser-ponyfill-CTSSxZf6.js +0 -342
  97. package/lib/browser-ponyfill-CTSSxZf6.js.map +0 -1
  98. package/lib/components/realm-selector/RealmSelector.d.ts +0 -1
  99. package/lib/permissions/PermissionsSection.d.ts +0 -1
  100. package/lib/permissions/routes/Permissions.d.ts +0 -7
  101. package/lib/permissions/routes/PermissionsTabs.d.ts +0 -9
  102. package/lib/realm/routes/AddRealm.d.ts +0 -7
  103. /package/lib/{permissions → permissions-configuration}/routes.d.ts +0 -0
@@ -0,0 +1,702 @@
1
+ import { jsx as e, jsxs as C, Fragment as z } from "react/jsx-runtime";
2
+ import { u as M, a as ce, b as Y, b9 as le, ax as de, V as J, aq as pe, M as W, j as _, k as me, F as Q, Y as $, $ as ye, ba as V, bb as ue, A as X, B as F, l as K, bc as ge, bd as Pe, be as fe, bf as G, bg as he, bh as ve, bi as be, bj as Ce, bk as Se, bl as Te, bm as we, bn as xe, e as B, S as Z, n as L, bo as H, aY as ee, v as ie, I as se, J as te, K as R, O as oe, bp as ne, bq as ae, ak as Ae, at as ke, al as Ie, aw as Oe, a7 as De, ao as Ee, br as Fe, aa as Ve, ar as Ne, c as Ke, P as Re, d as Le, bs as Me, bt as qe, bu as U, bv as Be } from "./index-B5GgWXK6.js";
3
+ import { useEffect as je, useState as w, useMemo as ze } from "react";
4
+ import { useTranslation as q } from "react-i18next";
5
+ import { useNavigate as He, Link as $e } from "react-router-dom";
6
+ import { S as Ge } from "./ScopePicker-DxDYNCCh.js";
7
+ const Ue = {
8
+ name: "",
9
+ description: "",
10
+ type: "group",
11
+ policies: [],
12
+ decisionStrategy: de.UNANIMOUS,
13
+ logic: le.POSITIVE
14
+ }, j = {
15
+ aggregate: xe,
16
+ client: we,
17
+ user: Te,
18
+ "client-scope": Se,
19
+ group: G,
20
+ regex: Ce,
21
+ role: be,
22
+ time: ve,
23
+ js: he,
24
+ default: G
25
+ }, Ye = (c) => c in j, Je = ({
26
+ permissionClientId: c,
27
+ providers: l,
28
+ policies: x,
29
+ toggleDialog: o,
30
+ onAssign: s
31
+ }) => {
32
+ const { adminClient: n } = M(), { realmRepresentation: A } = ce(), { t: d } = q(), u = Y({
33
+ mode: "onChange",
34
+ defaultValues: Ue
35
+ }), { addAlert: k, addError: D } = J(), { handleSubmit: b, reset: f } = u, I = A?.adminPermissionsEnabled, g = pe({
36
+ control: u.control,
37
+ name: "type"
38
+ });
39
+ function E() {
40
+ return g && Ye(g) ? j[g] : j.default;
41
+ }
42
+ const S = E();
43
+ je(() => {
44
+ if (g) {
45
+ const { name: r, description: P, decisionStrategy: m, logic: T } = u.getValues();
46
+ f({
47
+ type: g,
48
+ name: r,
49
+ description: P,
50
+ decisionStrategy: m,
51
+ logic: T
52
+ });
53
+ }
54
+ }, [g, f, u]);
55
+ const a = async (r) => {
56
+ const { groups: P, roles: m, policies: T, clients: O, ...t } = r, y = {
57
+ ...t,
58
+ ...P && P.length > 0 && { groups: P },
59
+ ...m && m.length > 0 && { roles: m },
60
+ ...T && T.length > 0 && { policies: T },
61
+ ...O && O.length > 0 && { clients: O },
62
+ ...t.type === "group" && (!P || P.length === 0) && { groups: [] },
63
+ ...t.type === "client" && (!O || O.length === 0) && { clients: [] }
64
+ };
65
+ try {
66
+ const p = await n.clients.createPolicy(
67
+ { id: c, type: g },
68
+ y
69
+ );
70
+ s(p), o(), k(d("createPolicySuccess"), B.success);
71
+ } catch (p) {
72
+ D("policySaveError", p);
73
+ }
74
+ };
75
+ return /* @__PURE__ */ e(
76
+ W,
77
+ {
78
+ "aria-label": d("createPermissionPolicy"),
79
+ variant: _.medium,
80
+ header: /* @__PURE__ */ e(ge, { children: /* @__PURE__ */ e(Pe, { component: fe.h1, children: d("createPermissionPolicy") }) }),
81
+ isOpen: !0,
82
+ onClose: o,
83
+ children: /* @__PURE__ */ C(
84
+ me,
85
+ {
86
+ id: "createPermissionPolicy-form",
87
+ onSubmit: (r) => {
88
+ r.stopPropagation(), b(a)(r);
89
+ },
90
+ isHorizontal: !0,
91
+ children: [
92
+ /* @__PURE__ */ C(Q, { ...u, children: [
93
+ /* @__PURE__ */ e(
94
+ $,
95
+ {
96
+ name: "name",
97
+ label: d("name"),
98
+ rules: { required: d("required") }
99
+ }
100
+ ),
101
+ /* @__PURE__ */ e($, { name: "description", label: d("description") }),
102
+ l && l.length > 0 && /* @__PURE__ */ e(
103
+ ye,
104
+ {
105
+ name: "type",
106
+ label: d("policyType"),
107
+ labelIcon: d("policyTypeHelpText"),
108
+ options: l.map((r) => ({
109
+ key: r.type,
110
+ value: V(r.type)
111
+ })),
112
+ controller: { defaultValue: "" }
113
+ }
114
+ ),
115
+ /* @__PURE__ */ e(
116
+ S,
117
+ {
118
+ isPermissionClient: I,
119
+ permissionClientId: c
120
+ }
121
+ ),
122
+ /* @__PURE__ */ e(ue, {})
123
+ ] }),
124
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ C("div", { className: "pf-v5-u-mt-md", children: [
125
+ /* @__PURE__ */ e(
126
+ F,
127
+ {
128
+ variant: K.primary,
129
+ className: "pf-v5-u-mr-md",
130
+ type: "submit",
131
+ "data-testid": "save",
132
+ isDisabled: x?.length === 0 && g === "aggregate",
133
+ children: d("save")
134
+ }
135
+ ),
136
+ /* @__PURE__ */ e(F, { variant: "link", "data-testid": "cancel", onClick: o, children: d("cancel") })
137
+ ] }) })
138
+ ]
139
+ }
140
+ )
141
+ }
142
+ );
143
+ }, We = ({
144
+ toggleDialog: c,
145
+ onAssign: l,
146
+ open: x,
147
+ permissionClientId: o
148
+ }) => {
149
+ const { t: s } = q(), { adminClient: n } = M(), [A, d] = w([]), [u, k] = w(void 0), [D, b] = Z(), [f, I] = w([]), [g, E] = w([]);
150
+ L(
151
+ () => Promise.all([
152
+ n.clients.listPolicyProviders({
153
+ id: o
154
+ }),
155
+ n.clients.listPolicies({
156
+ id: o,
157
+ permission: "false"
158
+ })
159
+ ]),
160
+ ([a, r]) => {
161
+ const P = a.filter((m) => m.type !== "resource" && m.type !== "scope").map((m) => m.name).filter((m) => m !== void 0);
162
+ E(H(P)), I(r || []);
163
+ },
164
+ [o]
165
+ );
166
+ const S = u ? f.filter((a) => V(a.type) === u) : f;
167
+ return /* @__PURE__ */ e(
168
+ W,
169
+ {
170
+ variant: _.medium,
171
+ title: s("assignExistingPolicies"),
172
+ isOpen: x,
173
+ onClose: c,
174
+ actions: [
175
+ /* @__PURE__ */ C(z, { children: [
176
+ /* @__PURE__ */ e(
177
+ F,
178
+ {
179
+ id: "modal-assignExistingPolicies",
180
+ "data-testid": "confirm",
181
+ variant: K.primary,
182
+ onClick: () => {
183
+ const a = A.map((r) => ({ policy: r }));
184
+ l(a), c();
185
+ },
186
+ isDisabled: A.length === 0,
187
+ children: s("assign")
188
+ },
189
+ "assign"
190
+ ),
191
+ /* @__PURE__ */ e(
192
+ F,
193
+ {
194
+ id: "modal-cancelExistingPolicies",
195
+ "data-testid": "cancel",
196
+ variant: K.link,
197
+ onClick: () => {
198
+ d([]), c();
199
+ },
200
+ children: s("cancel")
201
+ },
202
+ "cancel"
203
+ )
204
+ ] })
205
+ ],
206
+ children: /* @__PURE__ */ e(
207
+ ee,
208
+ {
209
+ loader: S,
210
+ ariaLabelKey: s("chooseAPolicyType"),
211
+ searchPlaceholderKey: s("searchClientAuthorizationPolicy"),
212
+ isSearching: !0,
213
+ searchTypeComponent: /* @__PURE__ */ e(
214
+ se,
215
+ {
216
+ onSelect: (a, r) => {
217
+ k(r), b();
218
+ },
219
+ onOpenChange: b,
220
+ toggle: (a) => /* @__PURE__ */ e(
221
+ oe,
222
+ {
223
+ ref: a,
224
+ "data-testid": "filter-type-dropdown-existingPolicies",
225
+ id: "toggle-id-10",
226
+ onClick: b,
227
+ icon: /* @__PURE__ */ e(ae, {}),
228
+ statusIcon: /* @__PURE__ */ e(ne, {}),
229
+ children: u || s("allTypes")
230
+ }
231
+ ),
232
+ isOpen: D,
233
+ children: /* @__PURE__ */ C(te, { children: [
234
+ /* @__PURE__ */ e(
235
+ R,
236
+ {
237
+ "data-testid": "filter-type-dropdown-existingPolicies-all",
238
+ onClick: () => k(void 0),
239
+ children: s("allTypes")
240
+ },
241
+ "all"
242
+ ),
243
+ g.map((a) => /* @__PURE__ */ e(
244
+ R,
245
+ {
246
+ "data-testid": `filter-type-dropdown-existingPolicies-${a}`,
247
+ onClick: () => k(a),
248
+ children: a
249
+ },
250
+ a
251
+ ))
252
+ ] })
253
+ }
254
+ ),
255
+ canSelectAll: !0,
256
+ onSelect: (a) => d(a),
257
+ columns: [
258
+ { name: "name", displayKey: s("name") },
259
+ {
260
+ name: "type",
261
+ displayKey: s("type"),
262
+ cellFormatters: [(a) => V(String(a || ""))]
263
+ },
264
+ { name: "description", displayKey: s("description") }
265
+ ],
266
+ emptyState: /* @__PURE__ */ e(
267
+ ie,
268
+ {
269
+ message: s("emptyAssignExistingPolicies"),
270
+ instructions: s("emptyAssignExistingPoliciesInstructions")
271
+ }
272
+ )
273
+ }
274
+ )
275
+ }
276
+ );
277
+ }, _e = ({
278
+ permissionClientId: c,
279
+ providers: l,
280
+ policies: x,
281
+ resourceType: o
282
+ }) => {
283
+ const { adminClient: s } = M(), { t: n } = q(), {
284
+ control: A,
285
+ getValues: d,
286
+ setValue: u,
287
+ trigger: k,
288
+ formState: { errors: D }
289
+ } = Ae(), b = d("policies"), [f, I] = w(!1), [g, E] = w(!1), [S, a] = w([]), [r, P] = w(void 0), [m, T] = Z();
290
+ L(
291
+ () => b && b.length > 0 ? Promise.all(
292
+ b.map(
293
+ (i) => s.clients.findOnePolicy({
294
+ id: c,
295
+ type: i.type,
296
+ policyId: i.id
297
+ })
298
+ )
299
+ ) : Promise.resolve([]),
300
+ (i) => {
301
+ const h = i.filter((v) => v);
302
+ a(h);
303
+ },
304
+ [x]
305
+ );
306
+ const O = H(
307
+ l ? l.filter((i) => i.type !== "resource" && i.type !== "scope").map((i) => i.name) : []
308
+ ), t = (i) => {
309
+ const h = i.map(({ policy: v }) => ({
310
+ id: v.id
311
+ }));
312
+ u("policies", [
313
+ ...d("policies") || [],
314
+ ...h
315
+ ]), k("policies"), a([
316
+ ...S,
317
+ ...i.map(({ policy: v }) => v)
318
+ ]);
319
+ }, y = (i) => {
320
+ const h = S.filter(
321
+ (v) => v.id !== i.id
322
+ );
323
+ a(h), u(
324
+ "policies",
325
+ h.map((v) => ({
326
+ id: v.id,
327
+ name: v.name,
328
+ type: v.type,
329
+ description: v.description
330
+ }))
331
+ );
332
+ }, p = r ? S.filter(
333
+ (i) => V(i.type) === r
334
+ ) : S;
335
+ return /* @__PURE__ */ C(
336
+ ke,
337
+ {
338
+ label: n("policies"),
339
+ labelIcon: /* @__PURE__ */ e(
340
+ De,
341
+ {
342
+ helpText: n("permissionPoliciesHelp"),
343
+ fieldLabelId: "policies"
344
+ }
345
+ ),
346
+ fieldId: "policies",
347
+ isRequired: !0,
348
+ children: [
349
+ /* @__PURE__ */ e(
350
+ Ie,
351
+ {
352
+ name: "policies",
353
+ control: A,
354
+ defaultValue: [],
355
+ rules: {
356
+ validate: (i) => !i || i.length === 0 ? !1 : i.every(({ id: h }) => h && h.trim().length > 0)
357
+ },
358
+ render: () => /* @__PURE__ */ C(z, { children: [
359
+ f && /* @__PURE__ */ e(
360
+ We,
361
+ {
362
+ permissionClientId: c,
363
+ open: f,
364
+ toggleDialog: () => I(!f),
365
+ onAssign: t
366
+ }
367
+ ),
368
+ g && /* @__PURE__ */ e(
369
+ Je,
370
+ {
371
+ toggleDialog: () => E(!g),
372
+ permissionClientId: c,
373
+ providers: l,
374
+ policies: x,
375
+ resourceType: o,
376
+ onAssign: (i) => {
377
+ t([{ policy: i }]);
378
+ }
379
+ }
380
+ ),
381
+ /* @__PURE__ */ e(
382
+ F,
383
+ {
384
+ "data-testid": "select-assignedPolicy-button",
385
+ variant: "secondary",
386
+ onClick: () => {
387
+ I(!0);
388
+ },
389
+ children: n("assignExistingPolicies")
390
+ }
391
+ ),
392
+ /* @__PURE__ */ e(
393
+ F,
394
+ {
395
+ "data-testid": "select-createNewPolicy-button",
396
+ className: "pf-v5-u-ml-md",
397
+ variant: "secondary",
398
+ onClick: () => {
399
+ E(!0);
400
+ },
401
+ children: n("createNewPolicy")
402
+ }
403
+ )
404
+ ] })
405
+ }
406
+ ),
407
+ S.length > 0 && /* @__PURE__ */ e(
408
+ ee,
409
+ {
410
+ loader: p,
411
+ ariaLabelKey: n("policies"),
412
+ searchPlaceholderKey: n("searchClientAuthorizationPolicy"),
413
+ isSearching: !0,
414
+ searchTypeComponent: /* @__PURE__ */ e(
415
+ se,
416
+ {
417
+ onSelect: (i, h) => {
418
+ P(h), T();
419
+ },
420
+ onOpenChange: T,
421
+ toggle: (i) => /* @__PURE__ */ e(
422
+ oe,
423
+ {
424
+ ref: i,
425
+ "data-testid": "filter-type-dropdown-existingPolicies",
426
+ id: "toggle-id-10",
427
+ onClick: T,
428
+ icon: /* @__PURE__ */ e(ae, {}),
429
+ statusIcon: /* @__PURE__ */ e(ne, {}),
430
+ children: r ? V(r) : n("allTypes")
431
+ }
432
+ ),
433
+ isOpen: m,
434
+ children: /* @__PURE__ */ C(te, { children: [
435
+ /* @__PURE__ */ e(
436
+ R,
437
+ {
438
+ "data-testid": "filter-type-dropdown-existingPolicies-all",
439
+ onClick: () => P(void 0),
440
+ children: n("allTypes")
441
+ },
442
+ "all"
443
+ ),
444
+ O.map((i) => /* @__PURE__ */ e(
445
+ R,
446
+ {
447
+ "data-testid": `filter-type-dropdown-existingPolicies-${i}`,
448
+ onClick: () => P(i),
449
+ children: i
450
+ },
451
+ i
452
+ ))
453
+ ] })
454
+ }
455
+ ),
456
+ actionResolver: (i) => [
457
+ {
458
+ title: n("unAssignPolicy"),
459
+ onClick: () => y(i.data)
460
+ }
461
+ ],
462
+ columns: [
463
+ { name: "name", displayKey: n("name") },
464
+ {
465
+ name: "type",
466
+ displayKey: n("type"),
467
+ cellFormatters: [(i) => V(String(i || ""))]
468
+ },
469
+ { name: "description", displayKey: n("description") }
470
+ ],
471
+ emptyState: /* @__PURE__ */ e(
472
+ ie,
473
+ {
474
+ message: n("emptyAssignExistingPolicies"),
475
+ instructions: n("emptyAssignExistingPoliciesInstructions")
476
+ }
477
+ )
478
+ }
479
+ ),
480
+ D.policies && /* @__PURE__ */ e(Oe, { message: n("requiredPolicies") })
481
+ ]
482
+ }
483
+ );
484
+ };
485
+ function ti() {
486
+ const { adminClient: c } = M(), { t: l } = q(), { realm: x, permissionClientId: o, permissionId: s, resourceType: n } = Ee(), A = He(), d = Y(), { handleSubmit: u, reset: k } = d, { addAlert: D, addError: b } = J(), [f, I] = w(), [g, E] = w(), [S, a] = w(), r = Fe({
487
+ clientId: o
488
+ }), P = ze(
489
+ () => r.filter(({ type: t }) => t === n).flatMap(({ scopes: t = [] }) => t).map((t) => t || ""),
490
+ [r, n]
491
+ );
492
+ L(
493
+ async () => {
494
+ if (!o)
495
+ return {};
496
+ const [t, y] = await Promise.all([
497
+ c.clients.listPolicyProviders({ id: o }),
498
+ c.clients.listPolicies({
499
+ id: o,
500
+ permission: "false"
501
+ })
502
+ ]);
503
+ return { providers: t, policies: y };
504
+ },
505
+ ({ providers: t, policies: y }) => {
506
+ const p = t?.filter(
507
+ (i) => i.type !== "resource" && i.type !== "scope"
508
+ );
509
+ E(
510
+ H(
511
+ p,
512
+ (i) => i.type
513
+ )
514
+ ), a(y || []);
515
+ },
516
+ [o]
517
+ ), L(
518
+ async () => {
519
+ if (!s)
520
+ return {};
521
+ const [t, y, p, i] = await Promise.all([
522
+ c.clients.findOnePermission({
523
+ id: o,
524
+ type: "scope",
525
+ permissionId: s
526
+ }),
527
+ c.clients.getAssociatedResources({
528
+ id: o,
529
+ permissionId: s
530
+ }),
531
+ c.clients.getAssociatedPolicies({
532
+ id: o,
533
+ permissionId: s
534
+ }),
535
+ c.clients.getAssociatedScopes({
536
+ id: o,
537
+ permissionId: s
538
+ })
539
+ ]);
540
+ if (!t)
541
+ throw new Error(l("notFound"));
542
+ return {
543
+ permission: t,
544
+ resources: y,
545
+ policies: p,
546
+ scopes: i
547
+ };
548
+ },
549
+ ({ permission: t, resources: y, policies: p, scopes: i }) => {
550
+ const h = y?.map((N) => N.name) || [], v = p?.map((N) => N.id) || [], re = i?.map((N) => N.name) || [];
551
+ k({
552
+ ...t,
553
+ resources: h,
554
+ policies: p,
555
+ scopes: i
556
+ }), I({
557
+ ...t,
558
+ resources: h,
559
+ policies: v,
560
+ scopes: re
561
+ });
562
+ },
563
+ [o, s]
564
+ );
565
+ const m = async (t) => {
566
+ try {
567
+ const y = {
568
+ ...t,
569
+ policies: t.policies?.map((p) => p.id),
570
+ scopes: t.scopes?.map((p) => p.name),
571
+ resourceType: n
572
+ };
573
+ if (s)
574
+ await c.clients.updatePermission(
575
+ { id: o, type: "scope", permissionId: s },
576
+ y
577
+ );
578
+ else {
579
+ const p = await c.clients.createPermission(
580
+ { id: o, type: "scope" },
581
+ y
582
+ );
583
+ I(p), A(
584
+ Be({
585
+ realm: x,
586
+ permissionClientId: o,
587
+ permissionId: p.id,
588
+ resourceType: n
589
+ })
590
+ );
591
+ }
592
+ D(
593
+ l(s ? "updatePermissionSuccess" : "createPermissionSuccess"),
594
+ B.success
595
+ );
596
+ } catch (y) {
597
+ b("permissionSaveError", y);
598
+ }
599
+ }, [T, O] = Ve({
600
+ titleKey: "deletePermission",
601
+ messageKey: l("deleteAdminPermissionConfirm", {
602
+ permission: f?.name
603
+ }),
604
+ continueButtonVariant: K.danger,
605
+ continueButtonLabel: "confirm",
606
+ onConfirm: async () => {
607
+ try {
608
+ await c.clients.delPermission({
609
+ id: o,
610
+ type: "scope",
611
+ permissionId: s
612
+ }), D(l("permissionDeletedSuccess"), B.success), A(
613
+ U({
614
+ realm: x,
615
+ permissionClientId: o,
616
+ tab: "permissions"
617
+ })
618
+ );
619
+ } catch (t) {
620
+ b("permissionDeletedError", t);
621
+ }
622
+ }
623
+ });
624
+ return f ? /* @__PURE__ */ C(z, { children: [
625
+ /* @__PURE__ */ e(O, {}),
626
+ /* @__PURE__ */ e(
627
+ Ke,
628
+ {
629
+ titleKey: s ? f?.name : l("createPermission"),
630
+ subKey: s ? f?.description : l("createPermissionOfType", { resourceType: n }),
631
+ dropdownItems: s ? [
632
+ /* @__PURE__ */ e(
633
+ R,
634
+ {
635
+ "data-testid": "delete-permission",
636
+ onClick: () => T(),
637
+ children: l("delete")
638
+ },
639
+ "delete"
640
+ )
641
+ ] : void 0
642
+ }
643
+ ),
644
+ /* @__PURE__ */ e(Re, { variant: "light", children: /* @__PURE__ */ C(Le, { isHorizontal: !0, onSubmit: u(m), role: "anyone", children: [
645
+ /* @__PURE__ */ C(Q, { ...d, children: [
646
+ /* @__PURE__ */ e(Me, { clientId: o }),
647
+ /* @__PURE__ */ e(
648
+ Ge,
649
+ {
650
+ clientId: o,
651
+ resourceTypeScopes: P ?? []
652
+ }
653
+ ),
654
+ /* @__PURE__ */ e(qe, { resourceType: n }),
655
+ /* @__PURE__ */ e(
656
+ _e,
657
+ {
658
+ permissionClientId: o,
659
+ providers: g,
660
+ policies: S,
661
+ resourceType: n
662
+ }
663
+ )
664
+ ] }),
665
+ /* @__PURE__ */ e(X, { children: /* @__PURE__ */ C("div", { className: "pf-v5-u-mt-md", children: [
666
+ /* @__PURE__ */ e(
667
+ F,
668
+ {
669
+ variant: K.primary,
670
+ className: "pf-v5-u-mr-md",
671
+ type: "submit",
672
+ "data-testid": "save",
673
+ children: l("save")
674
+ }
675
+ ),
676
+ /* @__PURE__ */ e(
677
+ F,
678
+ {
679
+ variant: "link",
680
+ "data-testid": "cancel",
681
+ component: (t) => /* @__PURE__ */ e(
682
+ $e,
683
+ {
684
+ ...t,
685
+ to: U({
686
+ realm: x,
687
+ permissionClientId: o,
688
+ tab: "permissions"
689
+ })
690
+ }
691
+ ),
692
+ children: l("cancel")
693
+ }
694
+ )
695
+ ] }) })
696
+ ] }) })
697
+ ] }) : /* @__PURE__ */ e(Ne, {});
698
+ }
699
+ export {
700
+ ti as default
701
+ };
702
+ //# sourceMappingURL=PermissionConfigurationDetails-DPu0gttX.js.map