1import{jsx as e,jsxs as R,Fragment as pe}from"react/jsx-runtime";import{u as $,b as G,d as z,a as Q,am as be,P as j,I as fe,G as he,g as h,y as Re,bz as w,cD as ye,bE as ge,n as ve,B as we,br as Ce,Q as x,m as L,bA as O,cE as Te,f as ke,s as N,v as Ie,D as Ae,p as Fe,bO as U,cF as W,bF as De,cG as Ne,cH as Ee,cI as Pe,cp as Be,cJ as Ke}from"./main-CdTyjLTW.js";import{useState as C}from"react";import{u as Se}from"./ConfirmDialog-BpghauDa.js";import{A as Me}from"./AttributeForm-Diz54EfB.js";import{P as Ve}from"./PermissionTab-CD4TfTM-.js";import{R as xe}from"./RoleForm-DB3mENqG.js";import{A as Le,R as Oe}from"./AddRoleMappingModal-GdRn9A1w.js";import{R as Ue,u as We}from"./RoutableTabs-Cj6rcOzH.js";import{V as $e}from"./ViewHeader-DlSfixri.js";import{u as H}from"./useParams-ncjyfZeQ.js";import{Q as Ge}from"./question-circle-icon-YXWB_t4c.js";import{A as ze}from"./AdminEvents-Z3g8fkxj.js";import{a as p,b}from"./Tabs-IiPxazEu.js";import"react-dom";import"./FormAccess-Chb1jekR.js";import"./KeyValueInput-BMr7zNfI.js";import"./KeySelect-IDTeTluw.js";import"./useLocaleSort-CNAUNMmq.js";import"./Trans-DXLUl81y.js";import"./translationFormatter-FIcT_WMC.js";import"./filter-icon-AZ5aTmZF.js";import"./PageHandler-BUYQSOtk.js";import"./DynamicComponents-Cl2iJJnw.js";import"./ClientSelect-DfNvgTlt.js";import"./FileUpload-BTKRQPhc.js";import"./GroupPickerDialog-BD-l5Yq_.js";import"./DataListItemRow-C3LqP3Yr.js";import"./MultiLineInput-CM4ZGy5B.js";import"./index-BpgtWJNU.js";import"./constants-BclHbWtx.js";import"./DropdownPanel-Qv4gRNah.js";import"./useFormatDate-gxDpRdyE.js";import"./DatePicker-By9a3pBG.js";import"./pickBy-Bz7u8zJW.js";import"./DescriptionListTerm-CJeuzAKt.js";const Qe=()=>{const{adminClient:n}=$(),m=G(),{realm:a}=z(),{t:s}=Q(),{id:y,clientId:T}=H(),k=async(o,l)=>{const i=await n.roles.findOneById({id:y});if(!i)throw new Error(s("notFound"));return i.clientRole?n.clients.findUsersWithRole({roleName:i.name,id:T,briefRepresentation:!0,first:o,max:l}):n.roles.findUsersWithRole({name:i.name,briefRepresentation:!0,first:o,max:l})},{enabled:g}=be();return e(j,{"data-testid":"users-page",variant:"light",children:e(fe,{isPaginated:!0,loader:k,ariaLabelKey:"roleList",searchPlaceholderKey:"","data-testid":"users-in-role-table",toolbarItem:g&&e(he,{"aria-label":"Basic popover",position:"bottom",bodyContent:R("div",{children:[s("whoWillAppearPopoverTextRoles"),e(h,{className:"kc-groups-link",variant:"link",onClick:()=>m(`/${a}/groups`),children:s("groups")}),s("or"),R(h,{className:"kc-users-link",variant:"link",onClick:()=>m(`/${a}/users`),children:[s("users"),"."]})]}),footerContent:s("whoWillAppearPopoverFooterText"),children:e(h,{variant:"link",className:"kc-who-will-appear-button",icon:e(Ge,{}),children:s("whoWillAppearLinkTextRoles")},"who-will-appear-button")}),emptyState:e(Re,{hasIcon:!0,message:s("noDirectUsers"),instructions:R("div",{children:[s("noUsersEmptyStateDescription"),e(h,{className:"kc-groups-link-empty-state",variant:"link",onClick:()=>m(`/${a}/groups`),children:s("groups")}),s("or"),e(h,{className:"kc-users-link-empty-state",variant:"link",onClick:()=>m(`/${a}/users`),children:s("users")}),s("noUsersEmptyStateDescriptionContinued")]})}),columns:[{name:"username",displayKey:"userName",cellFormatters:[w()]},{name:"email",displayKey:"email",cellFormatters:[w()]},{name:"lastName",displayKey:"lastName",cellFormatters:[w()]},{name:"firstName",displayKey:"firstName",cellFormatters:[ye(),w()]}]})})};function Dt(){const{adminClient:n}=$(),m=ge(),{t:a}=Q(),s=ve({mode:"onChange"}),{control:y,reset:T,setValue:k}=s,g=G(),{id:o,clientId:l}=H(),{realm:i,realmRepresentation:v}=z(),[E,q]=C(0),[J,P]=C(),X=()=>q(E+1),{addAlert:I,addError:A}=we(),{hasAccess:B}=Ce(),Y=B("query-clients","manage-authorization"),[Z,_]=C(!1),[ee,te]=C(!1),ae=t=>{const{attributes:r,...D}=t;return{attributes:Ke(r),...D}},c=x({control:y,defaultValue:void 0,name:"name"}),se=x({control:y,defaultValue:!1,name:"composite"});L(async()=>n.roles.findOneById({id:o}),t=>{if(!t)throw new Error(a("notFound"));const r=ae(t);T(r),P(r.attributes)},[E]),L(async()=>n.clients.findOne({id:l}),t=>{l&&_(t?.access?.manage)},[]);const K=async t=>{try{const{attributes:r,...D}=t,f=D;f.name=f.name?.trim(),f.attributes=Ne(r),l?await n.clients.updateRole({id:l,roleName:t.name},f):await n.roles.updateById({id:o},f),P(r),I(a("roleSaveSuccess"),N.success)}catch(r){A("roleSaveError",r)}},S=O(Ee.path),d=O(Te.path),re=()=>{if(S)return W({realm:i});if(d)return U({realm:i,clientId:d.params.clientId,tab:"roles"});throw new Error("Roles overview route could not be determined.")},F=t=>{if(S)return Pe({realm:i,id:o,tab:t});if(d)return Be({realm:i,id:o,clientId:d.params.clientId,tab:t});throw new Error("Route could not be determined.")},u=t=>We(F(t)),oe=u("details"),ne=u("associated-roles"),ie=u("attributes"),le=u("users-in-role"),ce=u("permissions"),me=u("events"),[de,ue]=Se({titleKey:"roleDeleteConfirm",messageKey:a("roleDeleteConfirmDialog",{selectedRoleName:c||a("createRole")}
1),continueButtonLabel:"delete",continueButtonVariant:ke.danger,onConfirm:async()=>{try{l?await n.clients.delRole({id:l,roleName:c}):await n.roles.delById({id:o}),I(a("roleDeletedSuccess"),N.success),g(re())}catch(t){A("roleDeleteError",t)}}}),M=async t=>{try{await n.roles.createComposite({roleId:o,realm:v.realm},t),X(),g(F("associated-roles")),I(a("addAssociatedRolesSuccess"),N.success)}catch(r){A("addAssociatedRolesError",r)}},V=t=>v?.defaultRole&&v.defaultRole.name===t;return v?R(pe,{children:[e(ue,{}),ee&&e(Le,{id:o,type:"roles",name:c,onAssign:t=>M(t.map(r=>r.role)),onClose:()=>te(!1)}),e($e,{titleKey:c,badges:[{id:"composite-role-badge",text:se?a("composite"):"",readonly:!0}],actionsDropdownId:"roles-actions-dropdown",dropdownItems:[e(Ae,{component:"button",onClick:()=>{de()},children:a("deleteRole")},"delete-role")],divider:!1}),e(j,{variant:"light",className:"pf-v5-u-p-0",children:e(Fe,{...s,children:R(Ue,{isBox:!0,mountOnEnter:!0,defaultLocation:F("details"),children:[e(p,{title:e(b,{children:a("details")}),...oe,children:e(xe,{form:s,onSubmit:K,role:d?"manage-clients":"manage-realm",cancelLink:d?U({realm:i,clientId:l,tab:"roles"}):W({realm:i}),editMode:!0})}),e(p,{"data-testid":"associatedRolesTab",title:e(b,{children:a("associatedRolesText")}),...ne,children:e(Oe,{name:c,id:o,type:"roles",isManager:!0,save:t=>M(t.map(r=>r.role))})}),!V(c)&&e(p,{"data-testid":"attributesTab",className:"kc-attributes-tab",title:e(b,{children:a("attributes")}),...ie,children:e(Me,{form:s,save:K,fineGrainedAccess:Z,reset:()=>k("attributes",J,{shouldDirty:!1})})}),!V(c)&&e(p,{title:e(b,{children:a("usersInRole")}),...le,children:e(Qe,{"data-cy":"users-in-role-tab"})}),m(De.AdminFineGrainedAuthz)&&Y&&e(p,{title:e(b,{children:a("permissions")}),...ce,children:e(Ve,{id:o,type:"roles"})}),B("view-events")&&e(p,{"data-testid":"admin-events-tab",title:e(b,{children:a("adminEvents")}),...me,children:e(ze,{resourcePath:`roles-by-id/${o}`})})]})})})]}):e(Ie,{})}export{Dt as default}; 2//# sourceMappingURL=RealmRoleTabs-BueyQ0Ia.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.