theme.keycloak.v2.admin.resources.assets.AddMapper-C3Bbsam6.js Maven / Gradle / Ivy
import{jsxs as m,Fragment as T,jsx as r}from"react/jsx-runtime";import{useState as C}from"react";import{a as F,y as O,v as x,ac as B,ad as U,ae as q,b5 as E,b6 as H,U as K,u as L,g as j,f as N,d as z,s as G,c as Q,B as R,k as P,cx as I,w as $,a3 as J,P as W,D as X,F as Y,A as Z,i as S,L as _,S as ee,cz as re,x as te,Q as ae}from"./main-C7ps2lmX.js";import{u as ie}from"./ConfirmDialog-hx7XKLbN.js";import{D as oe}from"./DynamicComponents-DvaX3FJx.js";import{F as se}from"./FormAccess-DyLNkc18.js";import{V as pe}from"./ViewHeader-B7eeFzFA.js";import{u as ne}from"./useParams-B67lSY02.js";import"react-dom";import"./ClientSelect-B9UqjyP6.js";import"./FileUpload-CumNwlWc.js";import"./CodeEditor-C-nZkUJx.js";import"./copy-icon-ACZmDH8e.js";import"./EmptyStateFooter-DqmBOP2I.js";import"./EmptyStateActions-DWNUFByn.js";import"./GroupPickerDialog-C09EjRTA.js";import"./PaginatingTableToolbar-Cjsz5Jh4.js";import"./DataListItemRow-BC0LurDd.js";import"./FlexItem-BzZfUnQ1.js";import"./KeySelect-jKxsKqdI.js";import"./useToggle-K3Kx99tM.js";import"./MultiLineInput-DiPNQ1LE.js";import"./AddRoleMappingModal-DW8o4W0z.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";const de=({mapperTypes:p,mapperType:t,form:d,id:f,updateMapperType:u})=>{const{t:o}=F(),{control:M}=d,[g,l]=C(!1),a=["inherit","import","legacy","force"];return m(T,{children:[r(O,{name:"name",label:o("name"),labelIcon:o("addIdpMapperNameHelp"),readOnly:!!f,rules:{required:o("required")}}),r(x,{name:"config.syncMode",label:o("syncModeOverride"),labelIcon:o("syncModeOverrideHelp"),options:a.map(i=>({key:i.toUpperCase(),value:o(`syncModes.${i}`)})),controller:{defaultValue:a[0].toUpperCase()}}),r(B,{label:o("mapperType"),labelIcon:r(U,{helpText:t.helpText,fieldLabelId:"mapperType"}),fieldId:"identityProviderMapper",children:r(q,{name:"identityProviderMapper",defaultValue:p[0].id,control:M,render:({field:i})=>r(E,{toggleId:"identityProviderMapper","data-testid":"idp-mapper-select",isDisabled:!!f,onToggle:()=>l(!g),onSelect:e=>{const y=e;u(y),i.onChange(y.id),l(!1)},selections:t.name,variant:H.single,"aria-label":o("mapperType"),isOpen:g,children:p.map(e=>r(K,{selected:e===i.value,"datatest-id":e.id,value:e,children:e.name},e.name))})})})]})};function He(){const{adminClient:p}=L(),{t}=F(),d=j({shouldUnregister:!0}),{handleSubmit:f}=d,{addAlert:u,addError:o}=N(),M=z(),g=G(),{realm:l}=Q(),{id:a,providerId:i,alias:e}=ne(),[y,A]=C(),[v,h]=C(),V=async s=>{const b=ee(s),c={...b,config:{...b.config},identityProviderAlias:e};if(a)try{await p.identityProviders.updateMapper({id:a,alias:e},{...c,id:a}),u(t("mapperSaveSuccess"),P.success)}catch(n){o(t("mapperSaveError"),n)}else try{const n=await p.identityProviders.createMapper({identityProviderMapper:c,alias:e});u(t("mapperCreateSuccess"),P.success),M(re({realm:l,alias:e,providerId:i,id:n.id}))}catch(n){o(t("mapperCreateError"),n)}},[w,D]=ie({titleKey:"deleteProviderMapper",messageKey:t("deleteMapperConfirm",{mapper:v?.name}),continueButtonLabel:"delete",continueButtonVariant:R.danger,onConfirm:async()=>{try{await p.identityProviders.delMapper({alias:e,id:a}),u(t("deleteMapperSuccess"),P.success),M(I({providerId:i,alias:e,tab:"mappers",realm:l}))}catch(s){o("deleteErrorIdentityProvider",s)}}});$(()=>Promise.all([a?p.identityProviders.findOneMapper({alias:e,id:a}):null,p.identityProviders.findMapperTypes({alias:e})]),([s,b])=>{const c=g(Object.values(b),te("name"));s?(h(c.find(({id:n})=>n===s.identityProviderMapper)),k(s)):h(c[0]),A(c)},[a]);const k=s=>{ae(s,d.setValue)};return!y||!v?r(J,{}):m(W,{variant:"light",children:[r(D,{}),r(pe,{className:"kc-add-mapper-title",titleKey:a?t("editIdPMapper",{providerId:i[0].toUpperCase()+i.substring(1)}):t("addIdPMapper",{providerId:i[0].toUpperCase()+i.substring(1)}),dropdownItems:a?[r(X,{onClick:w,children:t("delete")},"delete")]:void 0,divider:!0}),m(se,{role:"manage-identity-providers",isHorizontal:!0,onSubmit:f(V),className:"pf-v5-u-mt-lg",children:[m(Y,{...d,children:[a&&r(O,{name:"id",label:t("id"),readOnly:!0,rules:{required:t("required")}}),v.properties&&m(T,{children:[r(de,{form:d,id:a,mapperTypes:y,updateMapperType:h,mapperType:v}),r(oe,{properties:v.properties})]})]}),m(Z,{children:[r(S,{"data-testid":"new-mapper-save-button",variant:"primary",type:"submit",children:t("save")}),r(S,{"data-testid":"new-mapper-cancel-button",variant:"link",component:s=>r(_,{...s,to:I({realm:l,providerId:i,alias:e,tab:"mappers"})}),children:t("cancel")})]})]})]})}export{He as default};
//# sourceMappingURL=AddMapper-C3Bbsam6.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy