/
snap
/
lxd
/
35210
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/35210/share/lxd-ui/assets/CreateNetworkAcl-DA6wcz4z.js
import{c as N,d as a,l as x,o as A,r as c,V as n,j as e,f as v,g as S,Y as R,i as b,q as l,R as L,e as F}from"./index-dL2n30-Z.js";import{y as q,c as I,o as Y}from"./YamlSwitch-BRMLXARm.js";import{B as $}from"./BaseLayout-DoX0qSEj.js";import{G as m,Y as u}from"./NetworkFormMenu-BKrf9oEV.js";import{F as E}from"./FormFooterLayout-Bmq4RXkd.js";import{t as T,N as U}from"./NetworkAclForm-Dr-zuoOV.js";import{c as B}from"./network-acls-DIVFiLIx.js";import"./FormMenuItem-DRePjRCl.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-CQuEMXHF.js";import"./scroll-Dmr9Jl9h.js";import"./instanceOptions-D4bz_1Ev.js";import"./ConfigFieldDescription-B5-bOr1x.js";import"./ScrollableTable-CQDmfMtz.js";import"./snapshots-AS6hXv2C.js";import"./ScrollableContainer-ceiHesUW.js";import"./ExpandableList-Cjp4v1_P.js";import"./UsedByItem-Ber64JUd.js";const oe=()=>{const i=N(),p=a.useNotify(),d=a.useToastNotification(),y=x(),{project:o}=A(),[r,k]=c.useState(n(m)),w=c.useState(null);if(!o)return e.jsx(e.Fragment,{children:"Missing project"});const j=v().shape({name:S().test("deduplicate","An ACL with this name already exists",async s=>R(s,o,w,"network-acls")).required("ACL name is required")}),t=b({initialValues:{readOnly:!1,isCreating:!0,name:"",egress:[],ingress:[],entityType:"network-acl"},validationSchema:j,onSubmit:s=>{const g=s.yaml?q(s.yaml):T(t.values);B(g,o).then(()=>{y.invalidateQueries({queryKey:[l.projects,o,l.networkAcls]}),i(`/ui/project/${encodeURIComponent(o)}/network-acls`),d.success(e.jsxs(e.Fragment,{children:["Network ACL"," ",e.jsx(L,{type:"network-acl",value:s.name,to:`/ui/project/${encodeURIComponent(o)}/network-acl/${encodeURIComponent(s.name)}`})," ","created."]}))}).catch(h=>{t.setSubmitting(!1),p.failure("Network ACL creation failed",h)})}}),f=s=>{k(n(s))},C=()=>{const s={name:t.values.name,description:t.values.description,ingress:t.values.ingress,egress:t.values.egress};return Y(s)};return e.jsxs($,{title:"Create a network ACL",contentClassName:"create-network-acl",children:[e.jsxs(a.Row,{children:[e.jsx(F,{}),e.jsx(U,{formik:t,getYaml:C,section:r})]}),e.jsxs(E,{children:[e.jsx("div",{className:"yaml-switch",children:e.jsx(I,{formik:t,section:r,setSection:()=>{f(r===n(u)?m:u)},disableReason:t.values.name?void 0:"Please enter a network ACL name to enable this section"})}),e.jsx(a.Button,{appearance:"base",onClick:async()=>i(`/ui/project/${encodeURIComponent(o)}/network-acls`),children:"Cancel"}),e.jsx(a.ActionButton,{appearance:"positive",loading:t.isSubmitting,disabled:t.values.name.length===0||t.isSubmitting,onClick:()=>void t.submitForm(),children:"Create"})]})]})};export{oe as default};
Copyright ©2k19 -
Hexid
|
Tex7ure