All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.ClientProfileForm-Bj_Zx5Ql.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{jsx as e,jsxs as o,Fragment as x}from"react/jsx-runtime";import{u as J,a as Q,d as U,g as W,b4 as X,f as Y,b as _,v as ee,B as te,j as T,dV as N,dT as y,a3 as re,o as ie,D as ae,P as oe,F as le,x as se,O as ne,A as ce,h as d,L as h,Z as w,$ as L,ad as S,e9 as de,as as me,ea as ue,ar as fe}from"./index-C1LIsRX7.js";import{useState as P,useMemo as pe,Fragment as xe}from"react";import{u as he}from"./ConfirmDialog-B5qjiAuo.js";import{F as Pe}from"./FormAccess-BcY70QlP.js";import{V as Ce}from"./ViewHeader-qjLr6U82.js";import{u as be}from"./useParams-n_2fXkN1.js";/* empty css                               */import{F as ge,a as V}from"./FlexItem-DCAd8FXq.js";import{d as ve,D as ke,a as Te,b as ye,c as Ee}from"./DataListItemRow-COCiEHyF.js";import{T as De}from"./trash-icon-DDaN0w_B.js";import"react-dom";import"./copy-icon-DOS8MmN7.js";const Fe={name:"",description:"",executors:[]};function $e(){const{adminClient:p}=J(),{t}=Q(),C=U(),E=W({defaultValues:Fe,mode:"onChange"}),{handleSubmit:A,setValue:b,getValues:B,formState:{isDirty:D},control:H}=E,{fields:g,remove:K}=X({name:"executors",control:H}),{addAlert:v,addError:k}=Y(),[m,G]=P(),[a,j]=P(!1),{realm:n,profileName:l}=be(),O=_(),$=pe(()=>O.componentTypes?.["org.keycloak.services.clientpolicy.executor.ClientPolicyExecutorProvider"],[]),[u,q]=P(),c=!!l,[F,z]=P(0),M=()=>z(F+1);ee(()=>p.clientPolicies.listProfiles({includeGlobalProfiles:!0}),r=>{G({globalProfiles:r.globalProfiles,profiles:r.profiles?.filter(f=>f.name!==l)});const s=r.globalProfiles?.find(f=>f.name===l),i=r.profiles?.find(f=>f.name===l);j(s!==void 0),b("name",s?.name??i?.name??""),b("description",s?.description??i?.description??""),b("executors",s?.executors??i?.executors??[])},[F]);const R=async r=>{const s=r;try{await p.clientPolicies.createProfiles({...m,profiles:[...m?.profiles||[],s]}),v(t(c?"updateClientProfileSuccess":"createClientProfileSuccess"),T.success),C(N({realm:n,profileName:r.name}))}catch(i){k(c?"updateClientProfileError":"createClientProfileError",i)}},[I,Z]=he({titleKey:u?.name?t("deleteExecutorProfileConfirmTitle"):t("deleteClientProfileConfirmTitle"),messageKey:u?.name?t("deleteExecutorProfileConfirm",{executorName:u.name}):t("deleteClientProfileConfirm",{profileName:l}),continueButtonLabel:t("delete"),continueButtonVariant:te.danger,onConfirm:async()=>{if(u?.name){K(u.idx);try{await p.clientPolicies.createProfiles({...m,profiles:[...m.profiles||[],B()]}),v(t("deleteExecutorSuccess"),T.success),C(N({realm:n,profileName:l}))}catch(r){k(t("deleteExecutorError"),r)}}else try{await p.clientPolicies.createProfiles(m),v(t("deleteClientSuccess"),T.success),C(y({realm:n,tab:"profiles"}))}catch(r){k(t("deleteClientError"),r)}}});return m?o(x,{children:[e(Z,{}),e(Ce,{titleKey:c?l:t("newClientProfile"),badges:[{id:"global-client-profile-badge",text:a?e(ie,{color:"blue",children:t("global")}):""}],divider:!0,dropdownItems:c&&!a?[e(ae,{value:"delete",onClick:I,"data-testid":"deleteClientProfileDropdown",children:t("deleteClientProfile")},"delete")]:void 0}),e(oe,{variant:"light",children:e(le,{...E,children:o(Pe,{isHorizontal:!0,role:"view-realm",className:"pf-v5-u-mt-lg",children:[e(se,{name:"name",label:t("newClientProfileName"),helperText:t("createClientProfileNameHelperText"),readOnly:a,rules:{required:t("required")}}),e(ne,{name:"description",label:t("description"),readOnly:a}),o(ce,{children:[!a&&e(d,{variant:"primary",onClick:()=>A(R)(),"data-testid":"saveCreateProfile",isDisabled:!D,children:t("save")}),c&&!a&&e(d,{id:"reloadProfile",variant:"link","data-testid":"reloadProfile",isDisabled:!D,onClick:M,children:t("reload")}),!c&&!a&&e(d,{id:"cancelCreateProfile",variant:"link",component:r=>e(h,{...r,to:y({realm:n,tab:"profiles"})}),"data-testid":"cancelCreateProfile",children:t("cancel")})]}),c&&o(x,{children:[o(ge,{children:[e(V,{children:o(w,{className:"kc-executors",component:L.h1,children:[t("executors"),e(S,{helpText:t("executorsHelpText"),fieldLabelId:"executors"})]})}),!a&&e(V,{align:{default:"alignRight"},children:e(d,{id:"addExecutor",component:r=>e(h,{...r,to:de({realm:n,profileName:l})}),variant:"link",className:"kc-addExecutor","data-testid":"addExecutor",icon:e(me,{}),children:t("addExecutor")})})]}),g.length>0&&o(x,{children:[e(ve,{"aria-label":t("executors"),isCompact:!0,children:g.map((r,s)=>e(ke,{"aria-labelledby":"executors-list-item",id:r.executor,children:e(Te,{"data-testid":"executors-list-row",children:e(ye,{dataListCells:[o(Ee,{"data-testid":"executor-type",children:[r.configuration?e(d,{component:i=>e(h,{...i,to:ue({realm:n,profileName:l,executorName:r.executor})}),variant:"link","data-testid":"editExecutor",children:r.executor}):e("span",{className:"kc-unclickable-executor",children:r.executor}),$?.filter(i=>i.id===r.executor).map(i=>o(xe,{children:[e(S,{helpText:i.helpText,fieldLabelId:"executorTypeTextHelpText"},i.id),!a&&e(d,{variant:"link",isInline:!0,icon:e(De,{className:"kc-executor-trash-icon","data-testid":"deleteExecutor"},`executorType-trash-icon-${i.id}`),onClick:()=>{I(),q({idx:s,name:i.id})},"aria-label":t("remove")})]},i.id))]},"executor")]})})},r.executor))}),a&&e(d,{id:"backToClientPolicies",component:r=>e(h,{...r,to:y({realm:n,tab:"profiles"})}),variant:"primary",className:"kc-backToPolicies","data-testid":"backToClientPolicies",children:t("back")})]}),g.length===0&&o(x,{children:[e(fe,{}),e(w,{className:"kc-emptyExecutors",component:L.h2,children:t("emptyExecutors")})]})]})]})})})]}):e(re,{})}export{$e as default};
//# sourceMappingURL=ClientProfileForm-Bj_Zx5Ql.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy