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

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

There is a newer version: 25.0.1
Show newest version
import{b as H,c as Y,u as J,Y as be,j as e,P as X,M as Re,B as f,a8 as A,a$ as he,g as l,e as fe,b0 as ye,r as k,d as xe,Q as W,q as ge,a9 as $,l as Q,A as T,G as D,K as je,ab as G,b1 as q,aD as ve,b2 as we,b3 as Ce,b4 as Ae,aQ as ke,b5 as Te}from"./index-f33eb656.js";import{u as z}from"./ConfirmDialog-cc2aa7b4.js";import{A as De}from"./AttributeForm-71f684c4.js";import{P as Ie}from"./PermissionTab-2be61a29.js";import{R as Fe}from"./RoleForm-91537dac.js";import{A as Ne,R as Ee}from"./AddRoleMappingModal-d36df11e.js";import{R as Ke,u as Se}from"./RoutableTabs-8ba6475e.js";import{V as Be}from"./ViewHeader-5aaa6ccc.js";import{u as Pe,F as Le}from"./useIsFeatureEnabled-4167e6f3.js";import{u as Z}from"./useParams-74754a7c.js";import{L as Me}from"./PaginatingTableToolbar-2e41cd99.js";import{K as Ve}from"./KeycloakDataTable-82a4b6c2.js";import{Q as Oe}from"./question-circle-icon-096c9b7f.js";import{a as y,b as x}from"./Tabs-5aebe4ec.js";import"./Modal-e76dd76f.js";import"./FormAccess-29b78a4e.js";import"./copy-icon-c00ff2e0.js";import"./Form-6c170f69.js";import"./GridItem-8422f423.js";import"./KeyValueInput-7823c1d9.js";import"./KeycloakTextInput-e2751b88.js";import"./useToggle-d322044d.js";import"./Select-802cd710.js";import"./check-fc57dbe1.js";import"./star-icon-d7615f00.js";import"./minus-icon-9eecb50c.js";import"./minus-circle-icon-cb05a6be.js";import"./ActionListItem-96f54559.js";import"./plus-circle-icon-2ea0b4ed.js";import"./EmptyStateBody-de699127.js";import"./useLocaleSort-22b9cad8.js";import"./Trans-3f58860b.js";import"./Card-1b46a6d0.js";import"./CardTitle-f50befe6.js";import"./CardBody-a335088c.js";import"./Td-137060bd.js";import"./grip-vertical-icon-90ec69d5.js";import"./Checkbox-8826c1eb.js";import"./KeycloakTextArea-b4f2aa51.js";import"./resource-db8462e3.js";import"./admin-ui-endpoint-9ec5dfbd.js";import"./getAuthorizationHeaders-f2376d1a.js";import"./filter-icon-16b4a4ff.js";import"./ToolbarContent-f1a19b22.js";import"./Text-83f5a4d7.js";import"./EmptyStateSecondaryActions-7a33984f.js";import"./TableToolbar-8e38cfad.js";import"./plus-icon-6a98b80b.js";import"./MenuList-b32c7668.js";const Ue=()=>{const m=H(),{realm:o}=Y(),{t:s}=J("roles"),{id:g,clientId:I}=Z(),F=async(a,i)=>{const d=await l.roles.findOneById({id:g});if(!d)throw new Error(s("common:notFound"));return d.clientRole?l.clients.findUsersWithRole({roleName:d.name,id:I,first:a,max:i}):l.roles.findUsersWithRole({name:d.name,first:a,max:i})},{enabled:b}=be();return e.jsx(X,{"data-testid":"users-page",variant:"light",children:e.jsx(Ve,{isPaginated:!0,loader:F,ariaLabelKey:"roles:roleList",searchPlaceholderKey:"",toolbarItem:b&&e.jsx(Re,{"aria-label":"Basic popover",position:"bottom",bodyContent:e.jsxs("div",{children:[s("roles:whoWillAppearPopoverText"),e.jsx(f,{className:"kc-groups-link",variant:"link",onClick:()=>m(`/${o}/groups`),children:s("common:groups")}),s("or"),e.jsxs(f,{className:"kc-users-link",variant:"link",onClick:()=>m(`/${o}/users`),children:[s("users"),"."]})]}),footerContent:s("roles:whoWillAppearPopoverFooterText"),children:e.jsx(f,{variant:"link",className:"kc-who-will-appear-button",icon:e.jsx(Oe,{}),children:s("roles:whoWillAppearLinkText")},"who-will-appear-button")}),emptyState:e.jsx(Me,{hasIcon:!0,message:s("noDirectUsers"),instructions:e.jsxs("div",{children:[s("noUsersEmptyStateDescription"),e.jsx(f,{className:"kc-groups-link-empty-state",variant:"link",onClick:()=>m(`/${o}/groups`),children:s("common:groups")}),s("or"),e.jsx(f,{className:"kc-users-link-empty-state",variant:"link",onClick:()=>m(`/${o}/users`),children:s("users")}),s("noUsersEmptyStateDescriptionContinued")]})}),columns:[{name:"username",displayKey:"roles:userName",cellFormatters:[A()]},{name:"email",displayKey:"roles:email",cellFormatters:[A()]},{name:"lastName",displayKey:"roles:lastName",cellFormatters:[A()]},{name:"firstName",displayKey:"roles:firstName",cellFormatters:[he(),A()]}]})})};function Lt(){const m=Pe(),{t:o}=J("roles"),s=fe({mode:"onChange"}),{control:g,reset:I,setValue:F}=s,b=H(),{id:a,clientId:i}=Z(),{pathname:d}=ye(),{realm:c}=Y(),[N,_]=k.useState(0),[ee,E]=k.useState(),K=()=>_(N+1),{addAlert:j,addError:v}=xe(),[S,B]=k.useState(!1),te=t=>{const{attributes:r,...p}=t;return{attributes:Te(r),...p}},n=W({control:g,defaultValue:void 0,name:"name"}),P=W({control:g,defaultValue:!1,name:"composite"}),[w,oe]=k.useState();ge(async()=>{const[t,r]=await Promise.all([l.realms.findOne({realm:c}),l.roles.findOneById({id:a})]);return{realm:t,role:r}},({realm:t,role:r})=>{if(!t||!r)throw new Error(o("common:notFound"));const p=te(r);I(p),E(p.attributes),oe(t)},[N]);const L=async t=>{try{const{attributes:r,...p}=t,h=p;h.name=h.name?.trim(),h.attributes=ve(r),i?await l.clients.updateRole({id:i,roleName:t.name},h):await l.roles.updateById({id:a},h),E(r),j(o("roleSaveSuccess"),T.success)}catch(r){v("roles:roleSaveError",r)}},M=$(we.path),u=$(Ce.path),se=()=>{if(M)return q({realm:c});if(u)return G({realm:c,clientId:u.params.clientId,tab:"roles"});throw new Error("Roles overview route could not be determined.")},C=t=>{if(M)return Ae({realm:c,id:a,tab:t});if(u)return ke({realm:c,id:a,clientId:u.params.clientId,tab:t});throw new Error("Route could not be determined.")},R=t=>Se(C(t)),re=R("details"),ae=R("associated-roles"),le=R("attributes"),ie=R("users-in-role"),ne=R("permissions"),[V,ce]=z({titleKey:"roles:roleDeleteConfirm",messageKey:o("roles:roleDeleteConfirmDialog",{selectedRoleName:n||o("createRole")}),continueButtonLabel:"common:delete",continueButtonVariant:Q.danger,onConfirm:async()=>{try{i?await l.clients.delRole({id:i,roleName:n}):await l.roles.delById({id:a}),j(o("roleDeletedSuccess"),T.success),b(se())}catch(t){v("roles:roleDeleteError",t)}}}),me=d.includes("associated-roles")?[e.jsx(D,{component:"button",onClick:()=>de(),children:o("roles:removeAllAssociatedRoles")},"delete-all-associated"),e.jsx(D,{component:"button",onClick:()=>{V()},children:o("deleteRole")},"delete-role")]:[e.jsx(D,{"data-testid":"add-roles",component:"button",onClick:()=>pe(),children:o("addAssociatedRolesText")},"toggle-modal"),e.jsx(D,{component:"button",onClick:()=>V(),children:o("deleteRole")},"delete-role")],[de,ue]=z({titleKey:o("roles:removeAllAssociatedRoles")+"?",messageKey:o("roles:removeAllAssociatedRolesConfirmDialog",{name:n||o("createRole")}),continueButtonLabel:"common:delete",continueButtonVariant:Q.danger,onConfirm:async()=>{try{const t=await l.roles.getCompositeRoles({id:a});await l.roles.delCompositeRoles({id:a},t),j(o("compositeRoleOff"),T.success,o("compositesRemovedAlertDescription")),b(C("details")),K()}catch(t){v("roles:roleDeleteError",t)}}}),pe=()=>{B(!S)},O=async t=>{try{await l.roles.createComposite({roleId:a,realm:w.realm},t),K(),b(C("associated-roles")),j(o("addAssociatedRolesSuccess"),T.success)}catch(r){v("roles:addAssociatedRolesError",r)}},U=t=>w?.defaultRole&&w.defaultRole.name===t;return w?e.jsxs(e.Fragment,{children:[e.jsx(ce,{}),e.jsx(ue,{}),S&&e.jsx(Ne,{id:a,type:"roles",name:n,onAssign:t=>O(t.map(r=>r.role)),onClose:()=>B(!1)}),e.jsx(Be,{titleKey:n,badges:[{id:"composite-role-badge",text:P?o("composite"):"",readonly:!0}],actionsDropdownId:"roles-actions-dropdown",dropdownItems:me,divider:!1}),e.jsx(X,{variant:"light",className:"pf-u-p-0",children:e.jsxs(Ke,{isBox:!0,mountOnEnter:!0,defaultLocation:C("details"),children:[e.jsx(y,{title:e.jsx(x,{children:o("common:details")}),...re,children:e.jsx(Fe,{form:s,onSubmit:L,role:u?"manage-clients":"manage-realm",cancelLink:u?G({realm:c,clientId:i,tab:"roles"}):q({realm:c}),editMode:!0})}),P&&e.jsx(y,{"data-testid":"associatedRolesTab",title:e.jsx(x,{children:o("associatedRolesText")}),...ae,children:e.jsx(Ee,{name:n,id:a,type:"roles",isManager:!0,save:t=>O(t.map(r=>r.role))})}),!U(n)&&e.jsx(y,{"data-testid":"attributesTab",className:"kc-attributes-tab",title:e.jsx(x,{children:o("common:attributes")}),...le,children:e.jsx(De,{form:s,save:L,reset:()=>F("attributes",ee,{shouldDirty:!1})})}),!U(n)&&e.jsx(y,{title:e.jsx(x,{children:o("usersInRole")}),...ie,children:e.jsx(Ue,{"data-cy":"users-in-role-tab"})}),m(Le.AdminFineGrainedAuthz)&&e.jsx(y,{title:e.jsx(x,{children:o("common:permissions")}),...ne,children:e.jsx(Ie,{id:a,type:"roles"})})]})})]}):e.jsx(je,{})}export{Lt as default};
//# sourceMappingURL=RealmRoleTabs-85b7f088.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy