theme.keycloak.v2.admin.resources.assets.PermissionTab-CKEvhIGg.js Maven / Gradle / Ivy
import{jsx as s,jsxs as a,Fragment as L}from"react/jsx-runtime";import{useState as g}from"react";import{u as w,a as D,d as E,c as k,s as _,w as x,a3 as K,P as j,X as d,bs as b,Y as p,r as A,ac as G,ad as H,a4 as U,L as $,b7 as f}from"./main-C7ps2lmX.js";import{u as z}from"./ConfirmDialog-hx7XKLbN.js";import{T as B}from"./Trans-DcGUccv9.js";import{U as M,V as O,W as T,X as C,Y as R,Z as u,a2 as X}from"./Td-D2hVFK0Z.js";const Q=({id:n,type:l})=>{const{adminClient:r}=w(),{t:i}=D(),v=E(),{realm:o}=k(),[h,y]=g(""),[m,c]=g(),F=_(),P=e=>{switch(l){case"clients":return r.clients.updateFineGrainPermission({id:n},{enabled:e});case"users":return r.realms.updateUsersManagementPermissions({realm:o,enabled:e});case"groups":return r.groups.updatePermission({id:n},{enabled:e});case"roles":return r.roles.updatePermission({id:n},{enabled:e});case"identityProviders":return r.identityProviders.updatePermission({alias:n},{enabled:e})}};x(()=>Promise.all([r.clients.find({search:!0,clientId:o==="master"?"master-realm":"realm-management"}),(()=>{switch(l){case"clients":return r.clients.listFineGrainPermissions({id:n});case"users":return r.realms.getUsersManagementPermissions({realm:o});case"groups":return r.groups.listPermissions({id:n});case"roles":return r.roles.listPermissions({id:n});case"identityProviders":return r.identityProviders.listPermissions({alias:n})}})()]),([e,t])=>{y(e[0]?.id),c(t)},[n]);const[I,N]=z({titleKey:"permissionsDisable",messageKey:"permissionsDisableConfirm",continueButtonLabel:"confirm",onConfirm:async()=>{const e=await P(!1);c(e)}});return m?a(j,{variant:"light",children:[s(N,{}),a(d,{isFlat:!0,children:[s(b,{children:i("permissions")}),a(p,{children:[i(`${l}PermissionsHint`),s(A,{isHorizontal:!0,className:"pf-v5-u-pt-md",children:s(G,{hasNoPaddingTop:!0,className:"permission-label",label:i("permissionsEnabled"),fieldId:"permissionsEnabled",labelIcon:s(H,{helpText:i("permissionsEnabledHelp"),fieldLabelId:"permissionsEnabled"}),children:s(U,{id:"permissionsEnabled","data-testid":"permissionSwitch",label:i("on"),labelOff:i("off"),isChecked:m.enabled,onChange:async(e,t)=>{if(t){const S=await P(t);c(S)}else I()},"aria-label":i("permissionsEnabled")})})})]})]}),m.enabled&&a(L,{children:[a(d,{isFlat:!0,className:"pf-v5-u-mt-lg",children:[s(b,{children:i("permissionsList")}),s(p,{children:a(B,{i18nKey:"permissionsListIntro",children:[" ",s("strong",{children:{realm:o==="master"?"master-realm":"realm-management"}}),"."]})})]}),s(d,{isFlat:!0,className:"keycloak__permission__permission-table",children:s(p,{className:"pf-v5-u-p-0",children:a(M,{"aria-label":i("permissionsList"),variant:"compact",children:[s(O,{children:a(T,{children:[s(C,{id:"permissionsScopeName",children:i("permissionsScopeName")}),s(C,{id:"description",children:i("description")})]})}),s(R,{children:F(Object.entries(m.scopePermissions||{}),([e])=>e).map(([e,t])=>a(T,{children:[s(u,{children:s($,{to:f({realm:o,id:h,permissionType:"scope",permissionId:t}),children:e})}),s(u,{children:i(`scopePermissions.${l}.${e}-description`)}),s(u,{isActionCell:!0,children:s(X,{items:[{title:i("edit"),onClick(){v(f({realm:o,id:h,permissionType:"scope",permissionId:t}))}}]})})]},t))})]})})})]})]}):s(K,{})};export{Q as P};
//# sourceMappingURL=PermissionTab-CKEvhIGg.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy