Your IP : 216.73.216.52


Current Path : /snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //snap/lxd/current/share/lxd-ui/assets/CreateNetworkAcl-Cc9vkS3t.js

import{c as A,d as o,v as N,C as v,r as l,a6 as n,j as e,f as b,h as R,a9 as S,k as L,x as m,R as i,w as F,p as $}from"./index-BsQN_SZU.js";import{y as T,Y as I,o as O}from"./YamlSwitch-BStSXJFs.js";import{B as Y}from"./BaseLayout-D3ZT4TU8.js";import{G as p,Y as u}from"./NetworkFormMenu-jasNljC3.js";import{F as q}from"./FormFooterLayout-CcbL_-PB.js";import{t as E,N as U}from"./NetworkAclForm-DkZJlYVE.js";import{c as B}from"./network-acls-bpCzo6oH.js";import"./SshKeyForm-BNz7yPwa.js";import"./limits-yeXZOxhv.js";import"./AutoExpandingTextArea-Bd-45rZK.js";import"./formFields-DzJouV_d.js";import"./scroll-Dc7Cgzms.js";import"./ProjectRichChip-DZzjTfq6.js";import"./ConfigFieldDescription-CjXKAIpa.js";import"./snapshots-LtzKNDw1.js";import"./UsedByRow-DlstYIKs.js";import"./UsedByItem-DYTdOZkC.js";import"./ExpandableList-DsGr0BpD.js";const oe=()=>{const c=A(),d=o.useNotify(),k=o.useToastNotification(),y=N(),{project:a}=v(),[r,j]=l.useState(n(p)),w=l.useState(null);if(!a)return e.jsx(e.Fragment,{children:"Missing project"});const h=b().shape({name:R().test("deduplicate","An ACL with this name already exists",async s=>S(s,a,w,"network-acls")).required("ACL name is required")}),t=L({initialValues:{readOnly:!1,isCreating:!0,name:"",egress:[],ingress:[],entityType:"network-acl"},validationSchema:h,onSubmit:s=>{const x=s.yaml?T(s.yaml):E(t.values);B(x,a).then(()=>{y.invalidateQueries({queryKey:[m.projects,a,m.networkAcls]}),c(`${i}/ui/project/${encodeURIComponent(a)}/network-acls`),k.success(e.jsxs(e.Fragment,{children:["Network ACL"," ",e.jsx(F,{type:"network-acl",value:s.name,to:`${i}/ui/project/${encodeURIComponent(a)}/network-acl/${encodeURIComponent(s.name)}`})," ","created."]}))}).catch(g=>{t.setSubmitting(!1),d.failure("Network ACL creation failed",g)})}}),C=s=>{j(n(s))},f=()=>{const s={name:t.values.name,description:t.values.description,ingress:t.values.ingress,egress:t.values.egress};return O(s)};return e.jsxs(Y,{title:e.jsxs(e.Fragment,{children:["Create a network ",e.jsx("abbr",{title:"Access Control List",children:"ACL"})]}),contentClassName:"create-network-acl",children:[e.jsxs(o.Row,{children:[e.jsx($,{}),e.jsx(U,{formik:t,getYaml:f,section:r})]}),e.jsxs(q,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(I,{formik:t,section:r,setSection:()=>{C(r===n(u)?p:u)},disableReason:t.values.name?void 0:"Please enter a network ACL name to enable this section"})}),e.jsx(o.Button,{appearance:"base",onClick:async()=>c(`${i}/ui/project/${encodeURIComponent(a)}/network-acls`),children:"Cancel"}),e.jsx(o.ActionButton,{appearance:"positive",loading:t.isSubmitting,disabled:t.values.name.length===0||t.isSubmitting,onClick:()=>{t.submitForm()},children:"Create"})]})]})};export{oe as default};