theme.keycloak.v2.admin.resources.assets.MappingDetails-C358gupk.js Maven / Gradle / Ivy
import{jsxs as d,Fragment as B,jsx as p}from"react/jsx-runtime";import{useState as w}from"react";import{u as O,a as j,f as k,g as K,d as G,c as H,b as L,aD as N,v as $,B as q,j as v,D as z,P as R,F as U,ac as Q,am as J,x as W,A as X,h as F,L as Y,aE as Z,az as _,aF as ee,S as oe,Q as te}from"./index-C1LIsRX7.js";import{u as ae}from"./ConfirmDialog-B5qjiAuo.js";import{D as re}from"./DynamicComponents-CIZcko9u.js";import{F as pe}from"./FormAccess-BcY70QlP.js";import{V as ie}from"./ViewHeader-qjLr6U82.js";import{u as ne}from"./useParams-n_2fXkN1.js";import"react-dom";import"./ClientSelect-BTkwOwGP.js";import"./FileUpload-T43Q4AfB.js";import"./CodeEditor-CIeIZGz7.js";import"./copy-icon-DOS8MmN7.js";import"./EmptyStateFooter-Cm2IMTi1.js";import"./EmptyStateActions-DBSnfkAA.js";import"./GroupPickerDialog-DmX3SBxL.js";import"./PaginatingTableToolbar-CpMLQtqt.js";import"./DataListItemRow-COCiEHyF.js";import"./FlexItem-DCAd8FXq.js";import"./KeySelect-B2uWUd6C.js";import"./useToggle-K3Kx99tM.js";import"./MultiLineInput-AcwuO_FT.js";import"./AddRoleMappingModal-Ds4yp8lg.js";import"./KeycloakDataTable-jyvvxdb8.js";import"./Td-BwjBKSkH.js";import"./grip-vertical-icon-Bnn0MebT.js";import"./_baseFlatten-BHAcGTxk.js";import"./filter-icon-BVyMUArZ.js";function ke(){const{adminClient:i}=O(),{t:o}=j(),{addAlert:u,addError:f}=k(),{id:t,mapperId:a}=ne(),g=K(),{setValue:S,handleSubmit:D}=g,[m,T]=w(),[b,C]=w(),P=G(),{realm:y}=H(),M=L(),A=/^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$/,s=!!a.match(A),c=!!N(Z.path),h=()=>c?_({realm:y,id:t,tab:"mappers"}):ee({realm:y,clientId:t,tab:"mappers"});$(async()=>{let e;if(s){if(c?e=await i.clientScopes.findProtocolMapper({id:t,mapperId:a}):e=await i.clients.findProtocolMapperById({id:t,mapperId:a}),!e)throw new Error(o("notFound"));const r=M.protocolMapperTypes[e.protocol].find(l=>l.id===e.protocolMapper);return{config:{protocol:e.protocol,protocolMapper:e.protocolMapper},mapping:r,data:e}}else{const n=c?await i.clientScopes.findOne({id:t}):await i.clients.findOne({id:t});if(!n)throw new Error(o("notFound"));const l=M.protocolMapperTypes[n.protocol].find(x=>x.id===a);if(!l)throw new Error(o("notFound"));return{mapping:l,config:{protocol:n.protocol,protocolMapper:a}}}},({config:e,mapping:n,data:r})=>{C(e),T(n),r&&te(r,S)},[]);const[I,V]=ae({titleKey:"deleteMappingTitle",messageKey:"deleteMappingConfirm",continueButtonLabel:"delete",continueButtonVariant:q.danger,onConfirm:async()=>{try{c?await i.clientScopes.delProtocolMapper({id:t,mapperId:a}):await i.clients.delProtocolMapper({id:t,mapperId:a}),u(o("mappingDeletedSuccess"),v.success),P(h())}catch(e){f("mappingDeletedError",e)}}}),E=async e=>{const n=s?"Updated":"Created";try{const r={...b,...oe(e)};s?c?await i.clientScopes.updateProtocolMapper({id:t,mapperId:a},{id:a,...r}):await i.clients.updateProtocolMapper({id:t,mapperId:a},{id:a,...r}):c?await i.clientScopes.addProtocolMapper({id:t},r):await i.clients.addProtocolMapper({id:t},r),u(o(`mapping${n}Success`),v.success)}catch(r){f(`mapping${n}Error`,r)}};return d(B,{children:[p(V,{}),p(ie,{titleKey:s?m?.name:o("addMapper"),subKey:s?a:"addMapperExplain",dropdownItems:s?[p(z,{value:"delete",onClick:I,children:o("delete")},"delete")]:void 0}),p(R,{variant:"light",children:p(U,{...g,children:d(pe,{isHorizontal:!0,onSubmit:D(E),role:"manage-clients",children:[p(Q,{label:o("mapperType"),fieldId:"mapperType",children:p(J,{type:"text",id:"mapperType",name:"mapperType",readOnlyVariant:"default",value:m?.name})}),p(W,{name:"name",label:o("name"),labelIcon:o("mapperNameHelp"),readOnlyVariant:s?"default":void 0,rules:{required:{value:!0,message:o("required")}}}),p(re,{properties:m?.properties||[],isNew:!s}),d(X,{children:[p(F,{variant:"primary",type:"submit",children:o("save")}),p(F,{variant:"link",component:e=>p(Y,{...e,to:h()}),children:o("cancel")})]})]})})})]})}export{ke as default};
//# sourceMappingURL=MappingDetails-C358gupk.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy