theme.keycloak.v2.admin.resources.assets.NewClientPolicyCondition-BGdDHdFi.js Maven / Gradle / Ivy
import{jsxs as f,Fragment as K,jsx as n}from"react/jsx-runtime";import{u as U,a as $,f as J,d as M,c as Q,e as W,b as X,g as Y,w as Z,P as _,ac as ii,ad as oi,ae as ei,b5 as ni,b6 as ti,U as ri,F as si,A as ai,i as g,dT as P,L as ci,k as di}from"./main-C7ps2lmX.js";import{useState as a}from"react";import{D as li}from"./DynamicComponents-DvaX3FJx.js";import{F as pi}from"./FormAccess-DyLNkc18.js";import{V as mi}from"./ViewHeader-B7eeFzFA.js";import{c as S}from"./camelCase-BNIoyGq8.js";import"react-dom";import"./ClientSelect-B9UqjyP6.js";import"./FileUpload-CumNwlWc.js";import"./CodeEditor-C-nZkUJx.js";import"./copy-icon-ACZmDH8e.js";import"./EmptyStateFooter-DqmBOP2I.js";import"./EmptyStateActions-DWNUFByn.js";import"./GroupPickerDialog-C09EjRTA.js";import"./PaginatingTableToolbar-Cjsz5Jh4.js";import"./DataListItemRow-BC0LurDd.js";import"./FlexItem-BzZfUnQ1.js";import"./KeySelect-jKxsKqdI.js";import"./useToggle-K3Kx99tM.js";import"./MultiLineInput-DiPNQ1LE.js";import"./AddRoleMappingModal-DW8o4W0z.js";import"./KeycloakDataTable-DbY4la1D.js";import"./Td-D2hVFK0Z.js";import"./grip-vertical-icon-BxF7V59o.js";import"./_baseFlatten-eIEJR-AJ.js";import"./ConfirmDialog-hx7XKLbN.js";import"./filter-icon-DO0QNij3.js";import"./capitalize-Dxqk2Vco.js";import"./_baseSlice-F8doVSIJ.js";function Ki(){const{adminClient:v}=U(),{t:e}=$(),{addAlert:I,addError:w}=J(),h=M(),{realm:C}=Q(),[x,b]=a(!1),[d,D]=a(!1),[N,T]=a([]),[G,H]=a([]),[V,O]=a(),[p,B]=a(""),[k,A]=a([]),{policyName:c,conditionName:t}=W(),E=X(),m=Y(),F=E.componentTypes?.["org.keycloak.services.clientpolicy.condition.ClientPolicyConditionProvider"],L=r=>{m.reset({config:r.configuration||{}})};Z(()=>v.clientPolicies.listPolicies({includeGlobalPolicies:!0}),r=>{if(T(r.policies??[]),t){let i=r.policies?.find(o=>o.name===c);i===void 0&&(i=r.globalPolicies?.find(o=>o.name===c),D(i!==void 0));const l=i?.conditions?.find(o=>o.condition===t),u=F?.find(o=>o.id===t);O(l),A(u?.properties),L(l)}},[]);const j=async r=>{const i=r.config,l=()=>k.reduce((o,s)=>(o[s.name]=i[s.name],o),{}),u=N.map(o=>{if(o.name!==c)return o;let s=o.conditions??[];if(t){const z={condition:V?.condition,configuration:l()},y=s.findIndex(q=>t===q.condition);if(y===-1)return;const R=[...s.slice(0,y),z,...s.slice(y+1)];return{...o,conditions:R}}return s=s.concat({condition:G[0].condition,configuration:l()}),{...o,conditions:s}});try{await v.clientPolicies.updatePolicy({policies:u}),T(u),h(P({realm:C,policyName:c})),I(e(t?"updateClientConditionSuccess":"createClientConditionSuccess"),di.success)}catch(o){w("createClientConditionError",o)}};return f(K,{children:[n(mi,{titleKey:e(t?d?"viewCondition":"editCondition":"addCondition"),divider:!0}),f(_,{variant:"light",children:[f(pi,{isHorizontal:!0,role:"manage-realm",isReadOnly:d,className:"pf-v5-u-mt-lg",onSubmit:m.handleSubmit(j),children:[n(ii,{label:e("conditionType"),fieldId:"conditionType",labelIcon:n(oi,{helpText:p?`${S(p.replace(/-/g," "))}Help`:"conditionsHelp",fieldLabelId:"conditionType"}),children:n(ei,{name:"conditions",defaultValue:"any-client",control:m.control,render:({field:r})=>n(ni,{placeholderText:e("selectACondition"),className:"kc-conditionType-select","data-testid":"conditionType-select",toggleId:"provider",isDisabled:!!t,onToggle:i=>b(i),onSelect:i=>{r.onChange(i),A(i.properties),B(i.id),H([{condition:i.id}]),b(!1)},selections:t||p,variant:ti.single,"aria-label":e("conditionType"),isOpen:x,children:F?.map(i=>n(ri,{selected:i.id===r.value,description:e(S(i.id.replace(/-/g," "))),value:i,children:i.id},i.id))})})}),n(si,{...m,children:n(li,{properties:k})}),!d&&f(ai,{children:[n(g,{variant:"primary",type:"submit","data-testid":"addCondition-saveBtn",isDisabled:p===""&&!t&&d,children:e(t?"save":"add")}),n(g,{variant:"link","data-testid":"addCondition-cancelBtn",onClick:()=>h(P({realm:C,policyName:c})),children:e("cancel")})]})]}),d&&n("div",{className:"kc-backToProfile",children:n(g,{component:r=>n(ci,{...r,to:P({realm:C,policyName:c})}),variant:"primary",children:e("back")})})]})]})}export{Ki as default};
//# sourceMappingURL=NewClientPolicyCondition-BGdDHdFi.js.map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy