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

theme.keycloak.v2.admin.resources.assets.NewClientPolicyCondition-MihnKT7Z.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,v 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,h as g,dS as v,L as ci,j as di}from"./index-C1LIsRX7.js";import{useState as a}from"react";import{D as li}from"./DynamicComponents-CIZcko9u.js";import{F as pi}from"./FormAccess-BcY70QlP.js";import{V as mi}from"./ViewHeader-qjLr6U82.js";import{c as F}from"./camelCase-DE7svHxp.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";import"./capitalize-CrycxS-t.js";import"./_baseSlice-F8doVSIJ.js";function Ki(){const{adminClient:P}=U(),{t:e}=$(),{addAlert:I,addError:x}=J(),h=M(),{realm:C}=Q(),[D,b]=a(!1),[d,N]=a(!1),[w,T]=a([]),[G,H]=a([]),[V,O]=a(),[p,j]=a(""),[S,k]=a([]),{policyName:c,conditionName:t}=W(),B=X(),m=Y(),A=B.componentTypes?.["org.keycloak.services.clientpolicy.condition.ClientPolicyConditionProvider"],E=r=>{m.reset({config:r.configuration||{}})};Z(()=>P.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),N(i!==void 0));const l=i?.conditions?.find(o=>o.condition===t),u=A?.find(o=>o.id===t);O(l),k(u?.properties),E(l)}},[]);const L=async r=>{const i=r.config,l=()=>S.reduce((o,s)=>(o[s.name]=i[s.name],o),{}),u=w.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 P.clientPolicies.updatePolicy({policies:u}),T(u),h(v({realm:C,policyName:c})),I(e(t?"updateClientConditionSuccess":"createClientConditionSuccess"),di.success)}catch(o){x("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(L),children:[n(ii,{label:e("conditionType"),fieldId:"conditionType",labelIcon:n(oi,{helpText:p?`${F(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),k(i.properties),j(i.id),H([{condition:i.id}]),b(!1)},selections:t||p,variant:ti.single,"aria-label":e("conditionType"),isOpen:D,children:A?.map(i=>n(ri,{selected:i.id===r.value,description:e(F(i.id.replace(/-/g," "))),value:i,children:i.id},i.id))})})}),n(si,{...m,children:n(li,{properties:S})}),!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(v({realm:C,policyName:c})),children:e("cancel")})]})]}),d&&n("div",{className:"kc-backToProfile",children:n(g,{component:r=>n(ci,{...r,to:v({realm:C,policyName:c})}),variant:"primary",children:e("back")})})]})]})}export{Ki as default};
//# sourceMappingURL=NewClientPolicyCondition-MihnKT7Z.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy