/
proc
/
1387183
/
root
/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //proc/1387183/root/snap/lxd/current/share/lxd-ui/assets/CreateNetwork-Dp9R6Pn0.js
import{c as F,d as r,l as _,o as I,r as u,V as i,b as L,W as q,X as E,k as M,j as t,f as O,g as Y,Y as $,i as A,Z as d,_ as U,q as k,R as B,e as G}from"./index-dL2n30-Z.js";import{c as P,a as K}from"./networks-DWdMsnuF.js";import{t as y,N as Q,i as V}from"./NetworkForm-BDFSR-5t.js";import{y as D,c as W,o as X}from"./YamlSwitch-BRMLXARm.js";import{B as Z}from"./BaseLayout-DoX0qSEj.js";import{G as w,Y as f}from"./NetworkFormMenu-BKrf9oEV.js";import{F as z}from"./FormFooterLayout-Bmq4RXkd.js";import{s as H}from"./scroll-Dmr9Jl9h.js";import"./FormMenuItem-DRePjRCl.js";import"./limits-CLEFMbq-.js";import"./AutoExpandingTextArea-CQuEMXHF.js";import"./instanceOptions-D4bz_1Ev.js";import"./ConfigFieldDescription-B5-bOr1x.js";import"./ScrollableTable-CQDmfMtz.js";import"./snapshots-AS6hXv2C.js";import"./useNetworks-FA5tQKQK.js";import"./ClusterSpecificSelect-w4WndyK2.js";import"./ClusterSpecificInput-OscQ5yiR.js";import"./ExpandableList-Cjp4v1_P.js";import"./UsedByItem-Ber64JUd.js";import"./useNetworkAcls-ySbcb7T6.js";import"./network-acls-DIVFiLIx.js";import"./YamlNotification-BqA1Vb41.js";import"./ScrollableContainer-ceiHesUW.js";import"./debounce-DuKxa5-z.js";const Se=()=>{const c=F(),N=r.useNotify(),j=r.useToastNotification(),x=_(),{project:s}=I(),[n,C]=u.useState(i(w)),h=u.useState(null),{data:m,isLoading:g}=L(),b=q(m),S=E(m),{data:p=[]}=M();if(!s)return t.jsx(t.Fragment,{children:"Missing project"});if(g)return t.jsx(r.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0});const v=O().shape({name:Y().test("deduplicate","A network with this name already exists",async e=>$(e,s,h,"networks")).required("Network name is required")}),o=A({initialValues:{readOnly:!1,isCreating:!0,name:"",networkType:S?d:U,entityType:"network",ipv4_address:"auto",ipv6_address:"auto",security_acls:[]},validationSchema:v,onSubmit:e=>{const a=e.yaml?D(e.yaml):y(e);(b&&e.networkType!==d?async()=>P(a,s,p,e.parentPerClusterMember,e.bridge_external_interfaces_per_member):async()=>K(a,s))().then(()=>{x.invalidateQueries({queryKey:[k.projects,s,k.networks]}),c(`/ui/project/${encodeURIComponent(s)}/networks`),j.success(t.jsxs(t.Fragment,{children:["Network"," ",t.jsx(B,{type:"network",value:e.name,to:`/ui/project/${encodeURIComponent(s)}/network/${encodeURIComponent(e.name)}`})," ","created."]}))}).catch(T=>{o.setSubmitting(!1),N.failure("Network creation failed",T)})}}),R=()=>{const e=y(o.values);return X(e)},l=(e,a)=>{C(i(e)),a==="click"&&H(i(e))};return t.jsxs(Z,{title:"Create a network",contentClassName:"create-network",children:[t.jsxs(r.Row,{children:[t.jsx(G,{}),t.jsx(Q,{formik:o,getYaml:R,project:s,section:n,setSection:l},o.values.networkType)]}),t.jsxs(z,{children:[t.jsx("div",{className:"yaml-switch",children:t.jsx(W,{formik:o,section:n,setSection:()=>{l(n===i(f)?w:f,"click")},disableReason:o.values.name?void 0:"Please enter a network name to enable this section"})}),t.jsx(r.Button,{appearance:"base",onClick:async()=>c(`/ui/project/${encodeURIComponent(s)}/networks`),children:"Cancel"}),t.jsx(r.ActionButton,{appearance:"positive",loading:o.isSubmitting,disabled:V(o,p)||o.isSubmitting,onClick:()=>void o.submitForm(),children:"Create"})]})]})};export{Se as default};
Copyright ©2k19 -
Hexid
|
Tex7ure