theme.keycloak.v2.admin.resources.assets.EditClientScope-Cg-ESnK4.js Maven / Gradle / Ivy
import{jsx as t,jsxs as S,Fragment as j}from"react/jsx-runtime";import{useState as w}from"react";import{u as k,a as L,d as N,c as U,f as z,at as H,v as _,B as q,j as l,aw as G,a3 as J,D as Q,P as f,ax as T,ay as W,az as X,S as Y}from"./index-C1LIsRX7.js";import{c as Z,C as v,A as $}from"./ClientScopeTypes-B5zNo17b.js";import{u as ee}from"./ConfirmDialog-B5qjiAuo.js";import{R as te}from"./AddRoleMappingModal-Ds4yp8lg.js";import{R as oe,u as ae}from"./RoutableTabs-j5CUH0-6.js";import{V as ie}from"./ViewHeader-qjLr6U82.js";import{u as se}from"./useParams-n_2fXkN1.js";import{M as ne}from"./MapperList-BvJ2XhLk.js";import{S as re}from"./ScopeForm-C9VixkBN.js";import{a as g,b as h}from"./Tabs-CNBvRApH.js";import"react-dom";import"./PaginatingTableToolbar-CpMLQtqt.js";import"./EmptyStateFooter-Cm2IMTi1.js";import"./EmptyStateActions-DBSnfkAA.js";import"./KeycloakDataTable-jyvvxdb8.js";import"./Td-BwjBKSkH.js";import"./grip-vertical-icon-Bnn0MebT.js";import"./_baseFlatten-BHAcGTxk.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"./copy-icon-DOS8MmN7.js";import"./GroupPickerDialog-DmX3SBxL.js";import"./DataListItemRow-COCiEHyF.js";import"./FlexItem-DCAd8FXq.js";import"./KeySelect-B2uWUd6C.js";import"./useToggle-K3Kx99tM.js";import"./MultiLineInput-AcwuO_FT.js";import"./PageList-D9zZFEpa.js";import"./utils-DeGqqWSp.js";import"./SwitchControl-C3zDl-9W.js";import"./FormAccess-BcY70QlP.js";function Je(){const{adminClient:n}=k(),{t:a}=L(),y=N(),{realm:d}=U(),{id:r}=se(),{addAlert:c,addError:p}=z(),{enabled:D}=H(),[i,M]=w(),[C,A]=w(0),b=()=>A(C+1);_(async()=>{const e=await n.clientScopes.findOne({id:r});if(!e)throw new Error(a("notFound"));return{...e,type:await R(e)}},e=>{M(e)},[C,r]);async function R(e){return(await n.clientScopes.listDefaultClientScopes()).find(u=>u.name===e.name)?v.default:(await n.clientScopes.listDefaultOptionalClientScopes()).find(u=>u.name===e.name)?v.optional:$.none}const m=e=>ae(X({realm:d,id:r,tab:e})),E=m("settings"),x=m("mappers"),I=m("scope"),P=async e=>{const o=Y({...e,name:e.name?.trim().replace(/ /g,"_")});try{await n.clientScopes.update({id:r},o),await Z(n,{...o,id:r},o.type),c(a("updateSuccessClientScope"),l.success)}catch(s){p("updateErrorClientScope",s)}},[V,B]=ee({titleKey:a("deleteClientScope",{count:1,name:i?.name}),messageKey:"deleteConfirmClientScopes",continueButtonLabel:"delete",continueButtonVariant:q.danger,onConfirm:async()=>{try{await n.clientScopes.del({id:r}),c(a("deletedSuccessClientScope"),l.success),y(G({realm:d}))}catch(e){p("deleteErrorClientScope",e)}}}),F=async e=>{try{const o=e.filter(s=>s.client===void 0).map(s=>s.role).flat();await n.clientScopes.addRealmScopeMappings({id:r},o),await Promise.all(e.filter(s=>s.client!==void 0).map(s=>n.clientScopes.addClientScopeMappings({id:r,client:s.client.id},[s.role]))),c(a("roleMappingUpdatedSuccess"),l.success)}catch(o){p("roleMappingUpdatedError",o)}},K=async e=>{if(Array.isArray(e))try{await n.clientScopes.addMultipleProtocolMappers({id:i.id},e),b(),c(a("mappingCreatedSuccess"),l.success)}catch(o){p("mappingCreatedError",o)}else{const o=e;y(T({realm:d,id:i.id,mapperId:o.id}))}},O=async e=>{try{await n.clientScopes.delProtocolMapper({id:i.id,mapperId:e.id}),c(a("mappingDeletedSuccess"),l.success),b()}catch(o){p("mappingDeletedError",o)}return!0};return i?S(j,{children:[t(B,{}),t(ie,{titleKey:i.name,dropdownItems:[t(Q,{onClick:V,children:a("delete")},"delete")],badges:[{text:i.protocol}],divider:!1}),t(f,{variant:"light",className:"pf-v5-u-p-0",children:S(oe,{isBox:!0,children:[t(g,{id:"settings","data-testid":"settings",title:t(h,{children:a("settings")}),...E,children:t(f,{variant:"light",children:t(re,{save:P,clientScope:i})})}),t(g,{id:"mappers","data-testid":"mappers",title:t(h,{children:a("mappers")}),...x,children:t(ne,{model:i,onAdd:K,onDelete:O,detailLink:e=>T({realm:d,id:i.id,mapperId:e})})}),S(g,{id:"scope","data-testid":"scopeTab",title:t(h,{children:a("scope")}),...I,children:[D&&t(f,{children:t(W,{variant:"info",isInline:!0,title:a("clientScopesRolesScope"),component:"h2"})}),t(te,{id:i.id,name:i.name,type:"clientScopes",save:F})]})]})})]}):t(J,{})}export{Je as default};
//# sourceMappingURL=EditClientScope-Cg-ESnK4.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy