All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.RealmRoleTabs-DapqnsQK.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsx as e,jsxs as g,Fragment as Re}from"react/jsx-runtime";import{useState as E}from"react";import{u as q,d as X,c as Y,a as Z,at as he,P as _,a9 as fe,h,aC as T,bJ as ye,aH as ge,g as ve,bK as Ce,f as we,ab as j,v as Ae,aD as z,B as H,j as D,D as I,a3 as ke,F as Te,aR as Q,bL as G,aI as De,bh as Ie,bM as Fe,bN as Ne,bO as Ke,bz as Ee,bP as Be}from"./index-C1LIsRX7.js";import{u as J}from"./ConfirmDialog-B5qjiAuo.js";import{A as Se}from"./AttributeForm-DDUkni1v.js";import{P as Pe}from"./PermissionTab-DXe9jq3w.js";import{R as Le}from"./RoleForm-CyM9-qEe.js";import{A as xe,R as Me}from"./AddRoleMappingModal-Ds4yp8lg.js";import{R as Ve,u as Oe}from"./RoutableTabs-j5CUH0-6.js";import{V as Ue}from"./ViewHeader-qjLr6U82.js";import{u as ee}from"./useParams-n_2fXkN1.js";import{L as We}from"./PaginatingTableToolbar-CpMLQtqt.js";import{K as $e}from"./KeycloakDataTable-jyvvxdb8.js";import{Q as je}from"./question-circle-icon-Dbt6ViOg.js";import{a as f,b as y}from"./Tabs-CNBvRApH.js";import"react-dom";import"./FormAccess-BcY70QlP.js";import"./copy-icon-DOS8MmN7.js";import"./KeyValueInput-CoupoYmE.js";import"./KeySelect-B2uWUd6C.js";import"./useToggle-K3Kx99tM.js";import"./EmptyStateFooter-Cm2IMTi1.js";import"./Trans-DZTM8FLp.js";import"./Td-BwjBKSkH.js";import"./grip-vertical-icon-Bnn0MebT.js";import"./filter-icon-BVyMUArZ.js";import"./PageHandler-CFMh3rCu.js";import"./DynamicComponents-CIZcko9u.js";import"./ClientSelect-BTkwOwGP.js";import"./FileUpload-T43Q4AfB.js";import"./CodeEditor-CIeIZGz7.js";import"./EmptyStateActions-DBSnfkAA.js";import"./GroupPickerDialog-DmX3SBxL.js";import"./DataListItemRow-COCiEHyF.js";import"./FlexItem-DCAd8FXq.js";import"./MultiLineInput-AcwuO_FT.js";import"./PageList-D9zZFEpa.js";import"./_baseFlatten-BHAcGTxk.js";const ze=()=>{const{adminClient:l}=q(),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(je,{}),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}=q(),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:A}=we(),[L,x]=E(!1),ae=o=>{const{attributes:s,...K}=o;return{attributes:Be(s),...K}},n=j({control:v,defaultValue:void 0,name:"name"}),M=j({control:v,defaultValue:!1,name:"composite"});Ae(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){A("roleSaveError",s)}},O=z(Fe.path),u=z(Ne.path),se=()=>{if(O)return G({realm:d});if(u)return Q({realm:d,clientId:u.params.clientId,tab:"roles"});throw new Error("Roles overview route could not be determined.")},k=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(k(o)),re=b("details"),le=b("associated-roles"),ie=b("attributes"),ne=b("users-in-role"),ce=b("permissions"),[U,me]=J({titleKey:"roleDeleteConfirm",messageKey:t("roleDeleteConfirmDialog",{selectedRoleName:n||t("createRole")}),continueButtonLabel:"delete",continueButtonVariant:H.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){A("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]=J({titleKey:t("removeAllAssociatedRoles")+"?",messageKey:t("removeAllAssociatedRolesConfirmDialog",{name:n||t("createRole")}),continueButtonLabel:"delete",continueButtonVariant:H.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(k("details")),P()}catch(o){A("roleDeleteError",o)}}}),be=()=>{x(!L)},W=async o=>{try{await l.roles.createComposite({roleId:r,realm:C.realm},o),P(),p(k("associated-roles")),w(t("addAssociatedRolesSuccess"),D.success)}catch(s){A("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:k("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?Q({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(ze,{"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(ke,{})}export{Nt as default};
//# sourceMappingURL=RealmRoleTabs-DapqnsQK.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy