theme.keycloak.v2.admin.resources.assets.ExecutorForm-0KJaNCix.js Maven / Gradle / Ivy
import{jsxs as u,Fragment as R,jsx as o}from"react/jsx-runtime";import{u as U,a as J,d as Q,f as W,b as X,g as Y,v as Z,P as _,ac as $,ad as V,ae as ee,b5 as te,b6 as oe,U as re,F as ce,A as ie,h as g,L as k,dV as h,j as se}from"./index-C1LIsRX7.js";import{useState as l}from"react";import{D as ae}from"./DynamicComponents-CIZcko9u.js";import{F as ne}from"./FormAccess-BcY70QlP.js";import{V as le}from"./ViewHeader-qjLr6U82.js";import{u as F}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"./ConfirmDialog-B5qjiAuo.js";import"./filter-icon-BVyMUArZ.js";const I={config:{},executor:""};function we(){const{adminClient:v}=U(),{t:i}=J(),A=Q(),{realm:d,profileName:a}=F(),{executorName:n}=F(),{addAlert:C,addError:H}=W(),[N,P]=l(!1),p=X().componentTypes?.["org.keycloak.services.clientpolicy.executor.ClientPolicyExecutorProvider"],[m,O]=l([]),[D,G]=l([]),[T,L]=l([]),[j,B]=l([]),f=Y({defaultValues:I}),{control:w,reset:y,handleSubmit:z}=f,c=!!n,E=e=>{const r=e.find(s=>s.name===a)?.executors?.find(s=>s.executor===n);r&&y({config:r.configuration})};Z(()=>v.clientPolicies.listProfiles({includeGlobalProfiles:!0}),e=>{L(e.globalProfiles),B(e.profiles),E(e.profiles),E(e.globalProfiles)},[]);const q=async()=>{const e=f.getValues(),t=j.map(r=>{if(r.name!==a)return r;const s=(r.executors??[]).concat({executor:e.executor,configuration:e.config||{}});if(c){const S=r.executors.find(M=>M.executor===n);S.configuration={...S.configuration,...e.config}}return c?r:{...r,executors:s}});try{await v.clientPolicies.createProfiles({profiles:t,globalProfiles:T}),C(i(c?"updateExecutorSuccess":"addExecutorSuccess"),se.success),A(h({realm:d,profileName:a}))}catch(r){H(c?"updateExecutorError":"addExecutorError",r)}},x=T.find(e=>e.name===a),b=p?.find(e=>e.id===n),K=b?.properties.map(e=>{const t=c?e.defaultValue:"";return{...e,defaultValue:t}});return u(R,{children:[o(le,{titleKey:c?n:i("addExecutor"),divider:!0}),u(_,{variant:"light",children:[u(ne,{isHorizontal:!0,role:"manage-realm",className:"pf-v5-u-mt-lg",isReadOnly:!!x,children:[o($,{label:i("executorType"),fieldId:"kc-executorType",labelIcon:m.length>0&&m[0].helpText!==""?o(V,{helpText:m[0].helpText,fieldLabelId:"executorTypeHelpText"}):c?o(V,{helpText:b?.helpText,fieldLabelId:"executorTypeHelpText"}):void 0,children:o(ee,{name:"executor",defaultValue:"",control:w,render:({field:e})=>o(te,{toggleId:"kc-executor",placeholderText:"Select an executor",onToggle:t=>P(t),onSelect:t=>{y({...I,executor:t.toString()});const r=p?.filter(s=>s.id===t);O(r??[]),G(r?.[0].properties??[]),P(!1)},selections:c?n:e.value,variant:oe.single,"data-testid":"executorType-select","aria-label":i("executorType"),isOpen:N,maxHeight:580,isDisabled:c,children:p?.map(t=>o(re,{selected:t.id===e.value,value:t.id,description:t.helpText,children:t.id},t.id))})})}),o(ce,{...f,children:o(ae,{properties:c?K:D})}),!x&&u(ie,{children:[o(g,{variant:"primary",onClick:()=>z(q)(),"data-testid":"addExecutor-saveBtn",children:i(c?"save":"add")}),o(g,{variant:"link",component:e=>o(k,{...e,to:h({realm:d,profileName:a})}),"data-testid":"addExecutor-cancelBtn",children:i("cancel")})]})]}),c&&x&&o("div",{className:"kc-backToProfile",children:o(g,{component:e=>o(k,{...e,to:h({realm:d,profileName:a})}),variant:"primary",children:i("back")})})]})]})}export{we as default};
//# sourceMappingURL=ExecutorForm-0KJaNCix.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy