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

theme.keycloak.v2.admin.resources.assets.ClientProfileForm-D1d6omqT.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 W,a as Z,d as J,g as Q,b4 as X,f as Y,b as _,w as ee,B as te,k as y,dW as N,dU as T,a3 as re,p as ie,D as ae,P as oe,F as le,y as se,O as ne,A as ce,i as d,L as P,Z as w,$ as L,ad as S,eb as de,as as me,ec as ue,ar as fe}from"./main-C7ps2lmX.js";import{useState as h,useMemo as pe,Fragment as xe}from"react";import{u as Pe}from"./ConfirmDialog-hx7XKLbN.js";import{F as he}from"./FormAccess-DyLNkc18.js";import{V as Ce}from"./ViewHeader-B7eeFzFA.js";import{u as be}from"./useParams-B67lSY02.js";/* empty css                               */import{F as ge,a as A}from"./FlexItem-BzZfUnQ1.js";import{d as ve,D as ke,a as ye,b as Te,c as Ee}from"./DataListItemRow-BC0LurDd.js";import{T as De}from"./trash-icon-BkuEbPwb.js";import"react-dom";import"./copy-icon-ACZmDH8e.js";const Fe={name:"",description:"",executors:[]};function je(){const{adminClient:p}=W(),{t}=Z(),C=J(),E=Q({defaultValues:Fe,mode:"onChange"}),{handleSubmit:V,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]=h(),[a,O]=h(!1),{realm:n,profileName:l}=be(),$=_(),j=pe(()=>$.componentTypes?.["org.keycloak.services.clientpolicy.executor.ClientPolicyExecutorProvider"],[]),[u,q]=h(),c=!!l,[F,z]=h(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);O(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"),y.success),C(N({realm:n,profileName:r.name}))}catch(i){k(c?"updateClientProfileError":"createClientProfileError",i)}},[I,U]=Pe({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"),y.success),C(N({realm:n,profileName:l}))}catch(r){k(t("deleteExecutorError"),r)}}else try{await p.clientPolicies.createProfiles(m),v(t("deleteClientSuccess"),y.success),C(T({realm:n,tab:"profiles"}))}catch(r){k(t("deleteClientError"),r)}}});return m?o(x,{children:[e(U,{}),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(he,{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:()=>V(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(P,{...r,to:T({realm:n,tab:"profiles"})}),"data-testid":"cancelCreateProfile",children:t("cancel")})]}),c&&o(x,{children:[o(ge,{children:[e(A,{children:o(w,{className:"kc-executors",component:L.h1,children:[t("executors"),e(S,{helpText:t("executorsHelpText"),fieldLabelId:"executors"})]})}),!a&&e(A,{align:{default:"alignRight"},children:e(d,{id:"addExecutor",component:r=>e(P,{...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(ye,{"data-testid":"executors-list-row",children:e(Te,{dataListCells:[o(Ee,{"data-testid":"executor-type",children:[r.configuration?e(d,{component:i=>e(P,{...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}),j?.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(P,{...r,to:T({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{je as default};
//# sourceMappingURL=ClientProfileForm-D1d6omqT.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy