/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/CreateNetwork-DGPB8CiY.js
import{u as $,c as E,d as s,l as U,p as L,r as k,V as n,b as q,W as A,X as M,k as O,j as t,f as Y,g as B,Y as G,i as P,Z as w,_ as K,q as y,R as f,e as Q}from"./index-B3cgCbnJ.js";import{c as V,a as D,f as W,d as X}from"./networks-DBYE4DQa.js";import{t as h,N as Z,i as z}from"./NetworkForm-aRrAlWhU.js";import{y as H,c as J,o as ee}from"./YamlSwitch-Bng19N-X.js";import{B as te}from"./BaseLayout-DIbLs-hH.js";import{G as j,Y as N}from"./NetworkFormMenu-BjwriKKk.js";import{F as oe}from"./FormFooterLayout-ChlQYZN0.js";import{s as re}from"./scroll-BEbDVMxI.js";import"./FormMenuItem-BwEOqt61.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-BmFqLvbw.js";import"./instanceOptions-D4bz_1Ev.js";import"./ConfigFieldDescription-C9KDhW5s.js";import"./snapshots-Bt9cFkFc.js";import"./useNetworks-DC9cTd9P.js";import"./ClusterSpecificSelect-B7ug8YEi.js";import"./ClusterSpecificInput-C86z5N6a.js";import"./ExpandableList-DwC4iUKg.js";import"./UsedByItem-BtsI6fTe.js";import"./YamlNotification-C209eie-.js";import"./useNetworkAcls-n0o7vmIP.js";import"./network-acls-BrbgJ988.js";const Fe=()=>{const{isFineGrained:C}=$(),i=E(),x=s.useNotify(),m=s.useToastNotification(),g=U(),{project:o}=L(),[c,b]=k.useState(n(j)),S=k.useState(null),{data:p,isLoading:R}=q(),F=A(p),T=M(p),{data:u=[]}=O();if(!o)return t.jsx(t.Fragment,{children:"Missing project"});if(R)return t.jsx(s.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const I=Y().shape({name:B().test("deduplicate","A network with this name already exists",async e=>G(e,o,S,"networks")).required("Network name is required")}),r=P({initialValues:{readOnly:!1,isCreating:!0,name:"",networkType:T?w:K,entityType:"network",ipv4_address:"auto",ipv6_address:"auto",security_acls:[]},validationSchema:I,onSubmit:e=>{const a=e.yaml?H(e.yaml):h(e);(F&&e.networkType!==w?async()=>V(a,o,u,e.parentPerClusterMember,e.bridge_external_interfaces_per_member):async()=>D(a,o))().then(()=>{g.invalidateQueries({queryKey:[y.projects,o,y.networks]}),i(`/ui/project/${encodeURIComponent(o)}/networks`),m.success(t.jsxs(t.Fragment,{children:["Network"," ",t.jsx(f,{type:"network",value:e.name,to:`/ui/project/${encodeURIComponent(o)}/network/${encodeURIComponent(e.name)}`})," ","created."]}))}).catch(d=>{r.setSubmitting(!1),x.failure("Network creation failed",d),W(e.name,o,C).then(_=>{_.status==="Errored"&&X(e.name,o).catch(()=>{i(`/ui/project/${encodeURIComponent(o)}/networks`),m.failure("Error during network creation",d,t.jsxs(t.Fragment,{children:["Network"," ",t.jsx(f,{type:"network",value:e.name,to:`/ui/project/${encodeURIComponent(o)}/network/${encodeURIComponent(e.name)}`})," ","created with error status."]}))})}).catch(()=>{})})}}),v=()=>{const e=h(r.values);return ee(e)},l=(e,a)=>{b(n(e)),a==="click"&&re(n(e))};return t.jsxs(te,{title:"Create a network",contentClassName:"create-network",children:[t.jsxs(s.Row,{children:[t.jsx(Q,{}),t.jsx(Z,{formik:r,getYaml:v,project:o,section:c,setSection:l},r.values.networkType)]}),t.jsxs(oe,{children:[t.jsx("div",{className:"yaml-switch",children:t.jsx(J,{formik:r,section:c,setSection:()=>{l(c===n(N)?j:N,"click")},disableReason:r.values.name?void 0:"Please enter a network name to enable this section"})}),t.jsx(s.Button,{appearance:"base",onClick:async()=>i(`/ui/project/${encodeURIComponent(o)}/networks`),children:"Cancel"}),t.jsx(s.ActionButton,{appearance:"positive",loading:r.isSubmitting,disabled:z(r,u)||r.isSubmitting,onClick:()=>void r.submitForm(),children:"Create"})]})]})};export{Fe as default};
Copyright ©2k19 -
Hexid
|
Tex7ure