Your IP : 216.73.217.13


Current Path : /snap/lxd/current/share/lxd-ui/assets/
Upload File :
Current File : //snap/lxd/current/share/lxd-ui/assets/CreateNetworkForward-CMJYjjfx.js

import{c as k,d as i,v as N,C,r as h,k as j,x as d,R as u,j as r,L as x,ac as y}from"./index-BsQN_SZU.js";import{N as g,t as F,a as v}from"./NetworkForwardForm-D9GKhsgS.js";import{c as b}from"./network-forwards-CAuMAfcF.js";import{B as L}from"./BaseLayout-D3ZT4TU8.js";import{H as R}from"./HelpLink-BJF9zWZL.js";import{F as $}from"./FormFooterLayout-CcbL_-PB.js";import{u as A}from"./useNetworks-1j5RF-bH.js";import"./formFields-DzJouV_d.js";import"./ClusterMemberSelector-o7hg9ebZ.js";const D=()=>{const m=k(),c=i.useNotify(),f=i.useToastNotification(),w=N(),{network:s,project:t}=C(),{data:o,error:a}=A(s??"",t??"");h.useEffect(()=>{a&&c.failure("Loading networks failed",a)},[a]);const e=j({initialValues:{listenAddress:y(o)?o?.config["ipv4.address"]!=="none"?"0.0.0.0":o?.config["ipv6.address"]!=="none"?"::":"":"",ports:[]},validationSchema:g,onSubmit:l=>{const p=F(l);b(s??"",p,t??"").then(n=>{w.invalidateQueries({queryKey:[d.projects,t,d.networks,o,d.forwards]}),m(`${u}/ui/project/${encodeURIComponent(t??"")}/network/${encodeURIComponent(s??"")}/forwards`),f.success(`Network forward with listen address ${n} created.`)}).catch(n=>{e.setSubmitting(!1),c.failure("Network forward creation failed",n)})}});return r.jsxs(L,{title:r.jsx(R,{docPath:"/howto/network_forwards/",title:"Learn more about network forwards",children:"Create a network forward"}),contentClassName:"create-network",children:[r.jsx(v,{formik:e,network:o}),r.jsxs($,{children:[r.jsx(x,{className:"p-button--base",to:`${u}/ui/project/${encodeURIComponent(t??"")}/network/${encodeURIComponent(s??"")}/forwards`,children:"Cancel"}),r.jsx(i.ActionButton,{loading:e.isSubmitting,disabled:!e.isValid||e.isSubmitting||!e.values.listenAddress,onClick:()=>{e.submitForm()},children:"Create"})]})]})};export{D as default};