Your IP : 216.73.216.189


Current Path : /proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //proc/thread-self/root/snap/lxd/current/share/lxd-ui/assets/CreateNetworkAcl-BBpw6NYc.js

import{c as F,d as n,t as $,I as E,r as w,a5 as c,K as I,J as O,j as e,f as T,h as U,E as q,k as Y,R as l,y as B,p as Q,v as G,w as h}from"./index-BFGypnt-.js";import{y as K,d as P,o as M}from"./YamlSwitch-BQqYYI1i.js";import{B as _}from"./BaseLayout-ft99KK4_.js";import{G as y,Y as j}from"./NetworkFormMenu-CXUwfE9b.js";import{F as D}from"./FormFooterLayout-CMGxv4XX.js";import{t as H,N as J}from"./NetworkAclForm-Co7VPReH.js";import{c as V}from"./network-acls-DPo6Eh5Y.js";import"./FormMenuItem-fhYfVpHc.js";import"./AutoExpandingTextArea-WEdimI5c.js";import"./UsedByRow-oKHc8A5r.js";import"./UsedByItem-DETYWHDN.js";import"./useImages-DavKpFTt.js";import"./images-C6WqBeZG.js";import"./image-registries-YAuyq4CZ.js";import"./ProfileRichChip-XiLIeCE5.js";import"./ProfileResourceLimits-DkY60ueM.js";import"./useProfiles-CErbukD2.js";import"./ProjectRichChip-CtiU36yR.js";import"./ExpandableList-DK5_MQFC.js";const we=()=>{const m=F(),C=n.useNotify(),u=n.useToastNotification(),f=$(),{project:o}=E(),[r,g]=w.useState(c(y)),A=w.useState(null),{hasStorageAndNetworkOperations:x}=I(),v=O();if(!o)return e.jsx(e.Fragment,{children:"Missing project"});const N=T().shape({name:U().test("deduplicate","An ACL with this name already exists",async t=>q(t,o,A,"network-acls")).required("ACL name is required")}),S=t=>`${l}/ui/project/${encodeURIComponent(o)}/network-acl/${encodeURIComponent(t)}`,p=()=>{f.invalidateQueries({queryKey:[h.projects,o,h.networkAcls]})},d=t=>{p(),u.success(e.jsxs(e.Fragment,{children:["Network ACL"," ",e.jsx(G,{type:"network-acl",value:t,to:S(t)})," ","created."]}))},k=(t,a)=>{p(),s.setSubmitting(!1),C.failure(`Creation of network ACL ${t} failed`,a)},s=Y({initialValues:{readOnly:!1,isCreating:!0,name:"",egress:[],ingress:[],entityType:"network-acl"},validationSchema:N,onSubmit:t=>{const a=t.yaml?K(t.yaml):H(s.values);V(a,o).then(i=>{m(`${l}/ui/project/${encodeURIComponent(o)}/network-acls`),x?(u.info(e.jsxs(e.Fragment,{children:["Creation of Network ACL"," ",e.jsx(B,{bold:!0,type:"network-acl",value:a.name})," ","has started."]})),v.set(i.metadata.id,()=>{d(a.name)},R=>{k(a.name,new Error(R))})):d(a.name)}).catch(i=>{k(a.name,i)})}}),b=t=>{g(c(t))},L=()=>{const t={name:s.values.name,description:s.values.description,ingress:s.values.ingress,egress:s.values.egress};return M(t)};return e.jsxs(_,{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(n.Row,{children:[e.jsx(Q,{}),e.jsx(J,{formik:s,getYaml:L,section:r})]}),e.jsxs(D,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(P,{formik:s,section:r,setSection:()=>{b(r===c(j)?y:j)},disableReason:s.values.name?void 0:"Please enter a network ACL name to enable this section"})}),e.jsx(n.Button,{appearance:"base",onClick:async()=>m(`${l}/ui/project/${encodeURIComponent(o)}/network-acls`),children:"Cancel"}),e.jsx(n.ActionButton,{appearance:"positive",loading:s.isSubmitting,disabled:s.values.name.length===0||s.isSubmitting,onClick:()=>{s.submitForm()},children:"Create"})]})]})};export{we as default};