theme.keycloak.v2.admin.resources.assets.AddMapper-DoJCFyFk.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,x as O,y as k,ac as B,ad as U,ae as j,b5 as q,b6 as E,U as H,u as K,g as L,f as N,d as z,s as G,c as Q,B as R,j as P,cx as I,v as $,a3 as J,P as W,D as X,F as Y,A as Z,h as S,L as _,S as ee,cz as re,w as te,Q as ae}from"./index-C1LIsRX7.js";import{u as ie}from"./ConfirmDialog-B5qjiAuo.js";import{D as oe}from"./DynamicComponents-CIZcko9u.js";import{F as se}from"./FormAccess-BcY70QlP.js";import{V as pe}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";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(k,{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(j,{name:"identityProviderMapper",defaultValue:p[0].id,control:M,render:({field:i})=>r(q,{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:E.single,"aria-label":o("mapperType"),isOpen:g,children:p.map(e=>r(H,{selected:e===i.value,"datatest-id":e.id,value:e,children:e.name},e.name))})})})]})};function Ee(){const{adminClient:p}=K(),{t}=F(),d=L({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,b]=C(),V=async s=>{const h=ee(s),c={...h,config:{...h.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,h])=>{const c=g(Object.values(h),te("name"));s?(b(c.find(({id:n})=>n===s.identityProviderMapper)),x(s)):b(c[0]),A(c)},[a]);const x=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:b,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{Ee as default};
//# sourceMappingURL=AddMapper-DoJCFyFk.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy