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

theme.keycloak.v2.admin.resources.assets.EditClientScope-C3GoH0xe.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsx as t,jsxs as S,Fragment as O}from"react/jsx-runtime";import{useState as w}from"react";import{u as j,a as L,d as N,c as U,f as z,at as H,w as _,B as q,k 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"./main-C7ps2lmX.js";import{c as Z,C as v,A as $}from"./ClientScopeTypes-BnGjMgG5.js";import{u as ee}from"./ConfirmDialog-hx7XKLbN.js";import{R as te}from"./AddRoleMappingModal-DW8o4W0z.js";import{R as oe,u as ae}from"./RoutableTabs-T8JTILEW.js";import{V as ie}from"./ViewHeader-B7eeFzFA.js";import{u as se}from"./useParams-B67lSY02.js";import{M as ne}from"./MapperList-c_RL-W3b.js";import{S as re}from"./ScopeForm-CeG_pANI.js";import{a as g,b as h}from"./Tabs-CMdqT4Cg.js";import"react-dom";import"./PaginatingTableToolbar-Cjsz5Jh4.js";import"./EmptyStateFooter-DqmBOP2I.js";import"./EmptyStateActions-DWNUFByn.js";import"./KeycloakDataTable-DbY4la1D.js";import"./Td-D2hVFK0Z.js";import"./grip-vertical-icon-BxF7V59o.js";import"./_baseFlatten-eIEJR-AJ.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"./copy-icon-ACZmDH8e.js";import"./GroupPickerDialog-C09EjRTA.js";import"./DataListItemRow-BC0LurDd.js";import"./FlexItem-BzZfUnQ1.js";import"./KeySelect-jKxsKqdI.js";import"./useToggle-K3Kx99tM.js";import"./MultiLineInput-DiPNQ1LE.js";import"./PageList-s9OtSlkz.js";import"./utils-DeGqqWSp.js";import"./SwitchControl-C_9Y74oV.js";import"./FormAccess-DyLNkc18.js";function Je(){const{adminClient:n}=j(),{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,k]=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)}}}),B=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)}},F=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}))}},K=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(O,{children:[t(k,{}),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:F,onDelete:K,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:B})]})]})})]}):t(J,{})}export{Je as default};
//# sourceMappingURL=EditClientScope-C3GoH0xe.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy