theme.keycloak.v2.admin.resources.assets.RealmRoleTabs-B2OqQPtK.js Maven / Gradle / Ivy
import{jsx as e,jsxs as g,Fragment as Re}from"react/jsx-runtime";import{useState as E}from"react";import{u as J,d as X,c as Y,a as Z,at as he,P as _,a9 as fe,i as h,aC as T,bK as ye,aH as ge,g as ve,bL as Ce,f as we,ab as Q,w as ke,aD as j,B as z,k as D,D as I,a3 as Ae,F as Te,aR as H,bM as G,aI as De,bh as Ie,bN as Fe,bO as Ne,bP as Ke,bz as Ee,bQ as Be}from"./main-C7ps2lmX.js";import{u as q}from"./ConfirmDialog-hx7XKLbN.js";import{A as Se}from"./AttributeForm-CdFbESi6.js";import{P as Pe}from"./PermissionTab-CKEvhIGg.js";import{R as Le}from"./RoleForm-COK3IXcf.js";import{A as xe,R as Me}from"./AddRoleMappingModal-DW8o4W0z.js";import{R as Ve,u as Oe}from"./RoutableTabs-T8JTILEW.js";import{V as Ue}from"./ViewHeader-B7eeFzFA.js";import{u as ee}from"./useParams-B67lSY02.js";import{L as We}from"./PaginatingTableToolbar-Cjsz5Jh4.js";import{K as $e}from"./KeycloakDataTable-DbY4la1D.js";import{Q as Qe}from"./question-circle-icon-dDThmv9d.js";import{a as f,b as y}from"./Tabs-CMdqT4Cg.js";import"react-dom";import"./FormAccess-DyLNkc18.js";import"./copy-icon-ACZmDH8e.js";import"./KeyValueInput-B0tpVTv9.js";import"./KeySelect-jKxsKqdI.js";import"./useToggle-K3Kx99tM.js";import"./EmptyStateFooter-DqmBOP2I.js";import"./Trans-DcGUccv9.js";import"./Td-D2hVFK0Z.js";import"./grip-vertical-icon-BxF7V59o.js";import"./filter-icon-DO0QNij3.js";import"./PageHandler-P2CRgucq.js";import"./DynamicComponents-DvaX3FJx.js";import"./ClientSelect-B9UqjyP6.js";import"./FileUpload-CumNwlWc.js";import"./CodeEditor-C-nZkUJx.js";import"./EmptyStateActions-DWNUFByn.js";import"./GroupPickerDialog-C09EjRTA.js";import"./DataListItemRow-BC0LurDd.js";import"./FlexItem-BzZfUnQ1.js";import"./MultiLineInput-DiPNQ1LE.js";import"./PageList-s9OtSlkz.js";import"./_baseFlatten-eIEJR-AJ.js";const je=()=>{const{adminClient:l}=J(),c=X(),{realm:t}=Y(),{t:a}=Z(),{id:v,clientId:F}=ee(),N=async(r,i)=>{const m=await l.roles.findOneById({id:v});if(!m)throw new Error(a("notFound"));return m.clientRole?l.clients.findUsersWithRole({roleName:m.name,id:F,first:r,max:i}):l.roles.findUsersWithRole({name:m.name,first:r,max:i})},{enabled:p}=he();return e(_,{"data-testid":"users-page",variant:"light",children:e($e,{isPaginated:!0,loader:N,ariaLabelKey:"roleList",searchPlaceholderKey:"","data-testid":"users-in-role-table",toolbarItem:p&&e(fe,{"aria-label":"Basic popover",position:"bottom",bodyContent:g("div",{children:[a("whoWillAppearPopoverTextRoles"),e(h,{className:"kc-groups-link",variant:"link",onClick:()=>c(`/${t}/groups`),children:a("groups")}),a("or"),g(h,{className:"kc-users-link",variant:"link",onClick:()=>c(`/${t}/users`),children:[a("users"),"."]})]}),footerContent:a("whoWillAppearPopoverFooterText"),children:e(h,{variant:"link",className:"kc-who-will-appear-button",icon:e(Qe,{}),children:a("whoWillAppearLinkTextRoles")},"who-will-appear-button")}),emptyState:e(We,{hasIcon:!0,message:a("noDirectUsers"),instructions:g("div",{children:[a("noUsersEmptyStateDescription"),e(h,{className:"kc-groups-link-empty-state",variant:"link",onClick:()=>c(`/${t}/groups`),children:a("groups")}),a("or"),e(h,{className:"kc-users-link-empty-state",variant:"link",onClick:()=>c(`/${t}/users`),children:a("users")}),a("noUsersEmptyStateDescriptionContinued")]})}),columns:[{name:"username",displayKey:"userName",cellFormatters:[T()]},{name:"email",displayKey:"email",cellFormatters:[T()]},{name:"lastName",displayKey:"lastName",cellFormatters:[T()]},{name:"firstName",displayKey:"firstName",cellFormatters:[ye(),T()]}]})})};function Nt(){const{adminClient:l}=J(),c=ge(),{t}=Z(),a=ve({mode:"onChange"}),{control:v,reset:F,setValue:N}=a,p=X(),{id:r,clientId:i}=ee(),{pathname:m}=Ce(),{realm:d,realmRepresentation:C}=Y(),[B,te]=E(0),[oe,S]=E(),P=()=>te(B+1),{addAlert:w,addError:k}=we(),[L,x]=E(!1),ae=o=>{const{attributes:s,...K}=o;return{attributes:Be(s),...K}},n=Q({control:v,defaultValue:void 0,name:"name"}),M=Q({control:v,defaultValue:!1,name:"composite"});ke(async()=>l.roles.findOneById({id:r}),o=>{if(!o)throw new Error(t("notFound"));const s=ae(o);F(s),S(s.attributes)},[B]);const V=async o=>{try{const{attributes:s,...K}=o,R=K;R.name=R.name?.trim(),R.attributes=Ie(s),i?await l.clients.updateRole({id:i,roleName:o.name},R):await l.roles.updateById({id:r},R),S(s),w(t("roleSaveSuccess"),D.success)}catch(s){k("roleSaveError",s)}},O=j(Fe.path),u=j(Ne.path),se=()=>{if(O)return G({realm:d});if(u)return H({realm:d,clientId:u.params.clientId,tab:"roles"});throw new Error("Roles overview route could not be determined.")},A=o=>{if(O)return Ke({realm:d,id:r,tab:o});if(u)return Ee({realm:d,id:r,clientId:u.params.clientId,tab:o});throw new Error("Route could not be determined.")},b=o=>Oe(A(o)),re=b("details"),le=b("associated-roles"),ie=b("attributes"),ne=b("users-in-role"),ce=b("permissions"),[U,me]=q({titleKey:"roleDeleteConfirm",messageKey:t("roleDeleteConfirmDialog",{selectedRoleName:n||t("createRole")}),continueButtonLabel:"delete",continueButtonVariant:z.danger,onConfirm:async()=>{try{i?await l.clients.delRole({id:i,roleName:n}):await l.roles.delById({id:r}),w(t("roleDeletedSuccess"),D.success),p(se())}catch(o){k("roleDeleteError",o)}}}),de=m.includes("associated-roles")?[e(I,{component:"button",onClick:()=>ue(),children:t("removeAllAssociatedRoles")},"delete-all-associated"),e(I,{component:"button",onClick:()=>{U()},children:t("deleteRole")},"delete-role")]:[e(I,{"data-testid":"add-roles",component:"button",onClick:()=>be(),children:t("addAssociatedRolesText")},"toggle-modal"),e(I,{component:"button",onClick:()=>U(),children:t("deleteRole")},"delete-role")],[ue,pe]=q({titleKey:t("removeAllAssociatedRoles")+"?",messageKey:t("removeAllAssociatedRolesConfirmDialog",{name:n||t("createRole")}),continueButtonLabel:"delete",continueButtonVariant:z.danger,onConfirm:async()=>{try{const o=await l.roles.getCompositeRoles({id:r});await l.roles.delCompositeRoles({id:r},o),w(t("compositeRoleOff"),D.success,t("compositesRemovedAlertDescription")),p(A("details")),P()}catch(o){k("roleDeleteError",o)}}}),be=()=>{x(!L)},W=async o=>{try{await l.roles.createComposite({roleId:r,realm:C.realm},o),P(),p(A("associated-roles")),w(t("addAssociatedRolesSuccess"),D.success)}catch(s){k("addAssociatedRolesError",s)}},$=o=>C?.defaultRole&&C.defaultRole.name===o;return C?g(Re,{children:[e(me,{}),e(pe,{}),L&&e(xe,{id:r,type:"roles",name:n,onAssign:o=>W(o.map(s=>s.role)),onClose:()=>x(!1)}),e(Ue,{titleKey:n,badges:[{id:"composite-role-badge",text:M?t("composite"):"",readonly:!0}],actionsDropdownId:"roles-actions-dropdown",dropdownItems:de,divider:!1}),e(_,{variant:"light",className:"pf-v5-u-p-0",children:e(Te,{...a,children:g(Ve,{isBox:!0,mountOnEnter:!0,defaultLocation:A("details"),children:[e(f,{title:e(y,{children:t("details")}),...re,children:e(Le,{form:a,onSubmit:V,role:u?"manage-clients":"manage-realm",cancelLink:u?H({realm:d,clientId:i,tab:"roles"}):G({realm:d}),editMode:!0})}),M&&e(f,{"data-testid":"associatedRolesTab",title:e(y,{children:t("associatedRolesText")}),...le,children:e(Me,{name:n,id:r,type:"roles",isManager:!0,save:o=>W(o.map(s=>s.role))})}),!$(n)&&e(f,{"data-testid":"attributesTab",className:"kc-attributes-tab",title:e(y,{children:t("attributes")}),...ie,children:e(Se,{form:a,save:V,reset:()=>N("attributes",oe,{shouldDirty:!1})})}),!$(n)&&e(f,{title:e(y,{children:t("usersInRole")}),...ne,children:e(je,{"data-cy":"users-in-role-tab"})}),c(De.AdminFineGrainedAuthz)&&e(f,{title:e(y,{children:t("permissions")}),...ce,children:e(Pe,{id:r,type:"roles"})})]})})})]}):e(Ae,{})}export{Nt as default};
//# sourceMappingURL=RealmRoleTabs-B2OqQPtK.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy