%PDF- %PDF-
Direktori : /snap/lxd/28373/share/lxd-ui/assets/ |
Current File : //snap/lxd/28373/share/lxd-ui/assets/CreateNetwork-9059effd.js |
import{e as v,d as r,i as x,m as S,r as l,G as d,n as q,f as F,j as t,L as O,z as B,B as L,b as M,q as i,p as A}from"./index-13b2882d.js";import{c as I,a as R,u as $}from"./index.esm-82c30f37.js";import{S as G}from"./updateMaxHeight-325b3cd4.js";import{c as K,a as Q}from"./networks-5caac489.js";import{N as T,M as V,t as p}from"./NetworkForm-ffe61c80.js";import{y as Y,d as z}from"./instanceValidation-45cfba9a.js";import{i as D,s as E}from"./settings-c23f9009.js";import{Y as U}from"./ProfileFormMenu-3458e77a.js";import"./FormMenuItem-c8a1a121.js";import"./ConfigurationTable-1a9d4d6f.js";import"./ConfigFieldDescription-00c1a193.js";import"./AutoExpandingTextArea-3a779a81.js";import"./instanceConfigInheritance-fbf987f8.js";const ne=()=>{const n=v(),o=r.useNotify(),y=x(),{project:a}=S(),[f,k]=l.useState(d(V)),N=l.useState(null),{data:c,isLoading:w}=q(),m=D(c),b=E(c),{data:h=[]}=F({queryKey:[i.cluster,i.members],queryFn:A,enabled:m});if(!a)return t.jsx(t.Fragment,{children:"Missing project"});if(w)return t.jsx(O,{});const j=I().shape({name:R().test("deduplicate","A network with this name already exists",e=>B(e,a,N,"networks")).required("Network name is required")}),s=$({initialValues:{readOnly:!1,isCreating:!0,name:"",type:b?"ovn":"bridge"},validationSchema:j,onSubmit:e=>{const u=e.yaml?Y(e.yaml):p(e);(m&&e.type!=="ovn"?()=>K(u,a,h):()=>Q(u,a))().then(()=>{y.invalidateQueries({queryKey:[i.networks]}),n(`/ui/project/${a}/networks`,o.queue(o.success(`Network ${e.name} created.`)))}).catch(C=>{s.setSubmitting(!1),o.failure("Network creation failed",C)})}}),g=()=>{const e=p(s.values);return z(e)};return t.jsxs(L,{title:"Create a network",contentClassName:"create-network",children:[t.jsx(M,{}),t.jsx(T,{formik:s,getYaml:g,project:a,section:f,setSection:e=>{s.values.yaml&&e!==U&&s.setFieldValue("yaml",void 0),k(d(e))}}),t.jsxs("div",{className:"p-bottom-controls",children:[t.jsx("hr",{}),t.jsx(r.Row,{className:"u-align--right",children:t.jsxs(r.Col,{size:12,children:[t.jsx(r.Button,{appearance:"base",onClick:()=>n(`/ui/project/${a}/networks`),children:"Cancel"}),t.jsx(G,{isSubmitting:s.isSubmitting,isDisabled:!s.isValid||!s.values.name||s.values.type==="ovn"&&!s.values.network,buttonLabel:"Create",onClick:()=>void s.submitForm()})]})})]})]})};export{ne as default};