theme.keycloak.v2.admin.resources.assets.DetailProvider-MXbGsD3K.js Maven / Gradle / Ivy
import{jsx as e,jsxs as m,Fragment as k}from"react/jsx-runtime";import{useState as I}from"react";import{u as T,a as V,d as B,g as K,c as x,f as E,v as j,ab as H,B as L,aS as v,a3 as N,D as O,P as q,F as U,x as P,A as $,h,L as z,aT as G}from"./index-C1LIsRX7.js";import{u as W}from"./ConfirmDialog-B5qjiAuo.js";import{D as J}from"./DynamicComponents-CIZcko9u.js";import{F as M}from"./FormAccess-BcY70QlP.js";import{V as Q}from"./ViewHeader-qjLr6U82.js";import{u as X}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 Ae(){const{adminClient:n}=T(),{t}=V(),{id:r,providerId:s,subTab:c}=X(),d=B(),p=K({defaultValues:{providerId:s}}),{control:C,handleSubmit:b,reset:D}=p,{realm:l,realmRepresentation:R}=x(),{addAlert:u,addError:f}=E(),[g,S]=I();j(async()=>await Promise.all([n.realms.getClientRegistrationPolicyProviders({realm:l}),r?n.components.findOne({id:r}):Promise.resolve()]),([i,o])=>{S(i.find(a=>a.id===s)),D(o||{providerId:s})},[]);const y=H({control:C,defaultValue:"",name:"name"}),A=async i=>{i.config&&Object.entries(i.config).forEach(([o,a])=>i.config[o]=Array.isArray(a)?a:[a]);try{const o={...i,subType:c,parentId:R?.id,providerType:"org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy",providerId:s};if(r)await n.components.update({id:r},o);else{const{id:a}=await n.components.create(o);d(G({id:a,realm:l,subTab:c,providerId:s}))}u(t(`provider${r?"Updated":"Create"}Success`))}catch(o){f(`provider${r?"Updated":"Create"}Error`,o)}},[w,F]=W({titleKey:"clientRegisterPolicyDeleteConfirmTitle",messageKey:t("clientRegisterPolicyDeleteConfirm",{name:y}),continueButtonLabel:"delete",continueButtonVariant:L.danger,onConfirm:async()=>{try{await n.components.del({realm:l,id:r}),u(t("clientRegisterPolicyDeleteSuccess")),d(v({realm:l,subTab:c}))}catch(i){f("clientRegisterPolicyDeleteError",i)}}});return g?m(k,{children:[e(Q,{titleKey:r?y:"createPolicy",subKey:r,dropdownItems:r?[e(O,{"data-testid":"delete",onClick:w,children:t("delete")},"delete")]:void 0}),e(F,{}),e(q,{variant:"light",children:e(U,{...p,children:m(M,{role:"manage-clients",isHorizontal:!0,onSubmit:b(A),children:[e(P,{name:"providerId",label:t("provider"),readOnly:!0}),e(P,{name:"name",label:t("name"),labelIcon:t("clientPolicyNameHelp"),rules:{required:t("required")}}),e(J,{properties:g.properties}),m($,{children:[e(h,{"data-testid":"save",type:"submit",children:t("save")}),e(h,{variant:"link",component:i=>e(z,{...i,to:v({realm:l,subTab:c})}),children:t("cancel")})]})]})})})]}):e(N,{})}export{Ae as default};
//# sourceMappingURL=DetailProvider-MXbGsD3K.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy