import{f as x,d as s,k as A,l as C,o as S,r as c,J as m,j as t,M as g,c as b,q as l}from"./index-BTX30BGB.js";import{c as v,a as F}from"./index.esm-BV12eBbn.js";import{b as L}from"./networks-CpaxpXQg.js";import{M as q,N as R,t as p}from"./NetworkAclForm-DrbkjQdi.js";import{N as $}from"./NotificationRow-BrFpgHY8.js";import{c as B,y as M,d as O}from"./YamlSwitch-DkgRZQ-2.js";import{B as T}from"./BaseLayout-C9qzVjMS.js";import{F as E}from"./FormFooterLayout-C8pm2C5J.js";import{R as I}from"./ResourceLink-O9uDwzG_.js";import"./FormMenuItem-DWiPu6Qh.js";import"./instanceOptions-BVjIWe7l.js";import"./ConfigFieldDescription-BRIgBWxu.js";import"./AutoExpandingTextArea-DKXPgS_L.js";import"./ScrollableTable-CbBkBQ-n.js";import"./formFields-BDRvqvBI.js";import"./snapshots-L1dGj61Z.js";import"./YamlNotification-tLZQVPt8.js";import"./ScrollableContainer-BFMZMaL4.js";import"./ResourceIcon-ppn0Y8QG.js";const st=()=>{const r=x(),u=s.useNotify(),d=A(),k=C(),{project:o}=S(),[i,f]=c.useState(m(q)),w=c.useState(null);if(!o)return t.jsx(t.Fragment,{children:"Missing project"});const y=v().shape({name:F().test("deduplicate","A network ACL with this name already exists",e=>g(e,o,w,"network-acls")).required("Network ACL name is required")}),a=b({initialValues:{readOnly:!1,isCreating:!0,name:"",entityType:"networkAcl"},validationSchema:y,onSubmit:e=>{const j=e.yaml?M(e.yaml):p(e);L(j,o).then(()=>{k.invalidateQueries({queryKey:[l.projects,o,l.networkAcls]}),r(`/ui/project/${o}/network-acls`),d.success(t.jsxs(t.Fragment,{children:["Network ACL"," ",t.jsx(I,{type:"network-acl",value:e.name,to:`/ui/project/${o}/network-acls/${e.name}`})," ","created."]}))}).catch(h=>{a.setSubmitting(!1),u.failure("Network ACL creation failed",h)})}}),N=()=>{const e=p(a.values);return O(e)},n=e=>{f(m(e))};return t.jsxs(T,{title:"Create a network ACL",contentClassName:"create-network",children:[t.jsx($,{}),t.jsx(R,{formik:a,getYaml:N,section:i,setSection:n}),t.jsxs(E,{children:[t.jsx("div",{className:"yaml-switch",children:t.jsx(B,{formik:a,section:i,setSection:n,disableReason:a.values.name?void 0:"Please enter a network ACL name to enable this section"})}),t.jsx(s.Button,{appearance:"base",onClick:()=>r(`/ui/project/${o}/network-acls`),children:"Cancel"}),t.jsx(s.ActionButton,{appearance:"positive",loading:a.isSubmitting,disabled:!a.isValid||!a.values.name,onClick:()=>void a.submitForm(),children:"Create"})]})]})};export{st as default};
