You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
22 KiB
1 lines
22 KiB
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[784],{42458:function(e,t,n){var l=n(85893),r=n(14440),a=n(77831);let o="Decorator",s={ok:"".concat(o,"-ok"),warning:"".concat(o,"-warning"),error:"".concat(o,"-error"),off:"".concat(o,"-off")};t.Z=e=>{let{colour:t,sx:n,...o}=e;return(0,l.jsx)(r.Z,{...o,className:s[t],sx:{borderRadius:a.n_,height:"100%",width:"1.4em",["&.".concat(s.ok)]:{backgroundColor:a.Ej},["&.".concat(s.warning)]:{backgroundColor:a.Wd},["&.".concat(s.error)]:{backgroundColor:a.hM},["&.".concat(s.off)]:{backgroundColor:a.s7},...n}})}},28293:function(e,t,n){n.d(t,{Z:function(){return p}});var l=n(23279),r=n.n(l),a=n(67294),o=n(14879),s=function(){let{postSet:e,preSet:t,set:n,setType:l="string",valueKey:r="value"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a=>{let{target:{[r]:s}}=a,i=o.Z[l](s);null==t||t.call(null,a),null==n||n.call(null,i),null==e||e.call(null,a)}},i=n(52675);let u="input",c={boolean:!1,number:0,string:""},d={createInputOnChangeHandlerOptions:{},debounceWait:500,required:!1,valueType:"string"},f=(0,a.forwardRef)((e,t)=>{let{debounceWait:n=d.debounceWait,input:l,inputTestBatch:o,onBlurAppend:f,onFirstRender:p,onFocusAppend:v,onUnmount:g,required:m=d.required,valueKey:h,valueType:k=d.valueType,createInputOnChangeHandlerOptions:{postSet:x,valueKey:b=h,...w}=d.createInputOnChangeHandlerOptions}=e,{props:C}=l,y=(0,a.useMemo)(()=>null!=b?b:"checked"in C?"checked":"value",[C,b]),{onBlur:I,onChange:M,onFocus:j,[y]:S=c[k],...Z}=C,[R,N]=(0,a.useState)(S),[A,V]=(0,a.useState)(!1),[D,P]=(0,a.useState)(!1),q=(0,a.useCallback)(e=>{N(e)},[]),U=(0,a.useMemo)(()=>{let e;return o&&(o.isRequired=m,e=(0,i.LT)({[u]:o})),e},[o,m]),O=(0,a.useCallback)(e=>{var t;let n=null!==(t=null==U?void 0:U.call(null,{inputs:{[u]:{value:e}},isIgnoreOnCallbacks:!0}))&&void 0!==t&&t;null==p||p.call(null,{isValid:n}),P(n)},[p,U]),E=(0,a.useMemo)(()=>r()(O,n),[n,O]),L=(0,a.useMemo)(()=>null!=I?I:U&&function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let{0:{target:{value:l}}}=t;P(U({inputs:{[u]:{value:l}}})),null==f||f.call(null,...t)},[I,f,U]),F=(0,a.useMemo)(()=>s({postSet:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];V(!0),null==M||M.call(null,...t),null==x||x.call(null,...t)},set:e=>{q(e),E(e)},setType:k,valueKey:y,...w}),[E,M,x,w,q,y,k]),H=(0,a.useMemo)(()=>null!=j?j:o&&function(){for(var e,t,n=arguments.length,l=Array(n),r=0;r<n;r++)l[r]=arguments[r];null===(t=o.defaults)||void 0===t||null===(e=t.onSuccess)||void 0===e||e.call(null,{append:{}}),null==v||v.call(null,...l)},[j,o,v]);return(0,a.useEffect)(()=>(O(R),g),[]),(0,a.useEffect)(()=>{!A&&R!==S&&S&&(O(S),N(S))},[O,S,R,A]),(0,a.useImperativeHandle)(t,()=>({getIsChangedByUser:()=>A,getValue:()=>R,isValid:()=>D,setValue:q}),[R,A,D,q]),(0,a.cloneElement)(l,{...Z,onBlur:L,onChange:F,onFocus:H,required:m,[y]:R})});f.defaultProps=d,f.displayName="InputWithRef";var p=f},86549:function(e,t,n){var l=n(85893),r=n(11632),a=n(77574),o=n(77831),s=n(56903);t.Z=e=>{let{children:t,sx:n,...i}=e;return(0,l.jsx)(a.Z,{underline:"hover",variant:"subtitle1",...i,sx:{color:o.lD,textDecorationColor:o.s7,...n},children:(0,l.jsxs)(s.Z,{row:!0,children:[t,(0,l.jsx)(r.Z,{sx:{marginLeft:".3em"}})]})})}},4244:function(e,t,n){n.d(t,{Z:function(){return $}});var l=n(85893),r=n(14440),a=n(49360),o=n(63885),s=n(80543),i=n(26540),u=n(74443),c=n(12641),d=n(31530),f=n(37574),p=n(73490),v=n(28951),g=n(67294),m=n(25934),h=n(92230),k=n(77831),x=n(26339),b=n(38189),w=n(80594),C=n(59278);let y=e=>{let{isFloating:t,networkInterface:{networkInterfaceName:n},onClose:a,sx:o,...s}=e,i=t?{borderColor:k.s7,borderRadius:k.n_,borderStyle:"solid",borderWidth:"1px",backgroundColor:k.E5,padding:".6em 1.2em"}:{};return(0,l.jsxs)(r.Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center","& > :not(:first-child)":{marginLeft:".5em"},...i,...o},...s,children:[(0,l.jsx)(C.$_,{children:n}),a&&(0,l.jsx)(w.Z,{onClick:a,size:"small",sx:{color:k.s7},children:(0,l.jsx)(c.Z,{})})]})};y.defaultProps={isFloating:!1,onClose:void 0};var I=n(42458);let M=(0,n(89262).ZP)(r.Z)(()=>({borderColor:k.s7,borderStyle:"dashed",borderWidth:"4px",display:"flex",flexDirection:"column",padding:".6em","& > :not(:first-child)":{marginTop:".3em"}}));var j=n(56903),S=n(65895),Z=n(28293),R=n(81208),N=n(91029),A=n(23930),V=n(48430),D=n(6189),P=n(25137),q=n(52675);let U={ifaceNotApplied:"".concat("NetworkInitForm","-network-interface-not-applied")},O=[void 0,void 0],E={dnsCSV:"dns",gateway:"gateway",networkInterfaces:e=>"".concat(e,"Interface"),networkIPAddress:e=>"".concat(e,"IPAddress"),networkName:e=>"".concat(e,"Name"),networkSubnetMask:e=>"".concat(e,"SubnetMask"),networkSubnetConflict:e=>"".concat(e,"NetworkSubnetConflict")},L=Array.from({length:2},(e,t)=>t+1),F={bcn:{ip:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"10.20".concat(e,".").concat(t)},mask:"255.255.0.0"},ifn:{ip:()=>"",mask:""},mn:{ip:()=>"10.199.",mask:"255.255.0.0"},sn:{ip:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"10.10".concat(e,".").concat(t)},mask:"255.255.0.0"}},H=e=>"network".concat(e),T=function(){let{inputUUID:e=(0,m.Z)(),interfaces:t=[...O],ipAddress:n="",name:l,subnetMask:r="",type:a="",typeCount:o=0,...s}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=l;return l||(i=x.default[a]&&o>0?"".concat(x.default[a]," ").concat(o):"Unknown Network"),{inputUUID:e,interfaces:t,ipAddress:n,name:i,subnetMask:r,type:a,typeCount:o,...s}},B=(e,t)=>[{align:"center",field:"",renderCell:n=>{var a;let{row:o}=n,{isApplied:s}=null!==(a=t[o.networkInterfaceUUID])&&void 0!==a&&a,c="grab",d=function(){for(var t=arguments.length,n=Array(t),l=0;l<t;l++)n[l]=arguments[l];e(o,...n)},f=(0,l.jsx)(i.Z,{});return s&&(c="auto",d=void 0,f=(0,l.jsx)(u.Z,{sx:{color:k.Ej}})),(0,l.jsx)(r.Z,{onMouseDown:d,sx:{alignItems:"center",display:"flex",flexDirection:"row","&:hover":{cursor:c}},children:f})},sortable:!1,width:1},{field:"networkInterfaceName",flex:1,headerName:"Name",renderCell:e=>{let{row:{networkInterfaceState:t}={},value:n}=e;return(0,l.jsxs)(r.Z,{sx:{display:"flex",flexDirection:"row","& > :not(:first-child)":{marginLeft:".5em"}},children:[(0,l.jsx)(I.Z,{colour:"up"===t?"ok":"off",sx:{height:"auto"}}),(0,l.jsx)(C.$_,{children:n})]})}},{field:"networkInterfaceMACAddress",flex:1,headerName:"MAC",renderCell:e=>{let{value:t}=e;return(0,l.jsx)(C.$_,{text:t})}},{field:"networkInterfaceState",flex:1,headerName:"State",renderCell:e=>{let{value:t}=e,n=String(t);return(0,l.jsx)(C.KI,{text:"".concat(n.charAt(0).toUpperCase()).concat(n.substring(1))})}},{field:"networkInterfaceSpeed",flex:1,headerName:"Speed",renderCell:e=>{let{value:t}=e;return(0,l.jsx)(C.KI,{text:"".concat(parseFloat(t).toLocaleString()," Mbps")})}},{field:"networkInterfaceOrder",flex:1,headerName:"Order"}],_=e=>{let{allowMigrationNetwork:t,createDropMouseUpHandler:n,getNetworkTypeCount:s,hostDetail:{hostType:i,sequence:u}={},networkIndex:f,networkInput:p,networkInterfaceCount:v,networkInterfaceInputMap:m,removeNetwork:h,setMessageRe:b,setNetworkInputs:w,setNetworkInterfaceInputMap:I,testInput:j,testInputToToggleSubmitDisabled:R}=e,V=(0,a.Z)(),P=(0,o.Z)(V.breakpoints.up("md")),q=(0,o.Z)(V.breakpoints.up("lg")),U=(0,g.useRef)({}),O=(0,g.useRef)({}),{inputUUID:T,interfaces:B,ipAddress:_,isRequired:W,subnetMask:$,type:G,typeCount:J}=p,K=(0,g.useMemo)(()=>H(T),[T]),z=(0,g.useMemo)(()=>E.networkInterfaces(K),[K]),X=(0,g.useMemo)(()=>E.networkIPAddress(K),[K]),Q=(0,g.useMemo)(()=>E.networkSubnetMask(K),[K]),Y=(0,g.useMemo)(()=>E.networkSubnetConflict(K),[K]),ee=(0,g.useMemo)(()=>"node"===i,[i]),et=(0,g.useMemo)(()=>!ee&&v<=2?[1]:L,[ee,v]),en=(0,g.useMemo)(()=>{let{bcn:e,ifn:n,mn:l,sn:r}=x.default;return ee&&v>=8&&(t||"mn"===G)?{bcn:e,ifn:n,mn:l,sn:r}:{bcn:e,ifn:n,sn:r}},[t,ee,v,G]),el=(0,g.useCallback)((e,t,n)=>{let{current:{getIsChangedByUser:l,setValue:r}}=U,{current:{getIsChangedByUser:a,setValue:o}}=O;(null==l?void 0:l.call(null))||(e.ipAddress=t,null==r||r.call(null,t)),(null==a?void 0:a.call(null))||(e.subnetMask=n,null==o||o.call(null,n))},[]);return(0,g.useEffect)(()=>{var e,t;"striker"===i&&"ifn"!==G&&!(null===(e=U.current.getIsChangedByUser)||void 0===e?void 0:e.call(null))&&Number(u)&&(null===(t=U.current.setValue)||void 0===t||t.call(null,_.replace(/^((?:\d+\.){3})\d*$/,"$1".concat(u))))},[i,_,u,G]),(0,g.useEffect)(()=>{let{ipAddressInputRef:e,subnetMaskInputRef:t}=p;(e!==U||t!==O)&&(p.ipAddressInputRef=U,p.subnetMaskInputRef=O,w(e=>[...e]))},[p,w]),(0,l.jsxs)(A.Lg,{children:[(0,l.jsxs)(A.CH,{children:[(0,l.jsx)(D.Z,{id:"network-".concat(T,"-name"),isReadOnly:W,inputLabelProps:{isNotifyRequired:!0},label:"Network name",selectItems:Object.entries(en).map(e=>{let[t,n]=e,l=s(t,{lastIndex:f});return t!==G&&(l+=1),{value:t,displayValue:"".concat(n," ").concat(l)}}),selectProps:{onChange:e=>{let{target:{value:t}}=e,n=String(t);p.type=n;let l=s(n,{lastIndex:f});p.typeCount=l,p.name="".concat(x.default[n]," ").concat(l);let r=F[n];if(r){let e;let{ip:t,mask:a}=r;"striker"===i&&"bcn"===n&&(e="4."),el(p,t(l,e),a)}w(e=>[...e])},renderValue:q?void 0:e=>"".concat(String(e).toUpperCase()," ").concat(J),value:G}}),!W&&(0,l.jsx)(S.Z,{onClick:()=>{h(f)},sx:{padding:".2em",position:"absolute",right:"-9px",top:"-4px"},children:(0,l.jsx)(c.Z,{fontSize:"small"})})]}),(0,l.jsxs)(r.Z,{sx:{display:"flex",flexDirection:"column",margin:".6em","& > :not(:first-child)":{marginTop:"1em"}},children:[et.map(e=>{let t="Link ".concat(e),a=e-1,o=B[a],{networkInterfaceUUID:s=""}=null!=o?o:{},i=P?(0,l.jsx)(C.Ac,{text:"Drop to add interface."}):(0,l.jsx)(d.Z,{sx:{alignSelf:"center",color:k.s7}});return(0,l.jsxs)(r.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row","& > :not(:first-child)":{marginLeft:"1em"},"& > :last-child":{flexGrow:1}},children:[(0,l.jsx)(C.Ac,{sx:{whiteSpace:"nowrap"},text:t}),(0,l.jsx)(M,{onMouseUp:function(){for(var e,t=arguments.length,l=Array(t),r=0;r<t;r++)l[r]=arguments[r];null==n||null===(e=n.call(null,B,a))||void 0===e||e.call(null,...l),R({inputs:{[z]:{isIgnoreOnCallbacks:!1}},isContinueOnFailure:!0})},children:o?(0,l.jsx)(y,{networkInterface:o,onClose:()=>{B[a]=void 0,m[s].isApplied=!1,I(e=>({...e})),R({inputs:{[z]:{isIgnoreOnCallbacks:!1}},isContinueOnFailure:!0})}},"network-interface-".concat(s)):i})]},"network-".concat(T,"-link-").concat(e))}),(0,l.jsx)(Z.Z,{input:(0,l.jsx)(N.Z,{id:"network-".concat(T,"-ip-address"),inputProps:{onBlur:e=>{let{target:{value:t}}=e;j({inputs:{[X]:{value:t}}})}},inputLabelProps:{isNotifyRequired:!0},label:"IP address",onChange:e=>{let{target:{value:t}}=e;R({inputs:{[X]:{value:t}}}),b(RegExp("(?:^(?:".concat(X,"|").concat(Y,")|").concat(T,"$)")))},value:_}),ref:U}),(0,l.jsx)(Z.Z,{input:(0,l.jsx)(N.Z,{id:"network-".concat(T,"-subnet-mask"),inputProps:{onBlur:e=>{let{target:{value:t}}=e;j({inputs:{[Q]:{value:t}}})}},inputLabelProps:{isNotifyRequired:!0},label:"Subnet mask",onChange:e=>{let{target:{value:t}}=e;R({inputs:{[Q]:{value:t}}}),b(RegExp("(?:^(?:".concat(Q,"|").concat(Y,")|").concat(T,"$)")))},value:$}),ref:O})]})]})};_.defaultProps={allowMigrationNetwork:!0,createDropMouseUpHandler:void 0,hostDetail:void 0};let W=(0,g.forwardRef)((e,t)=>{let n,{expectHostDetail:a=!1,hostDetail:o,hostSequence:i,toggleSubmitDisabled:u}=e,c="local",w=i;a?o&&({hostType:n,hostUUID:c,sequence:w}=o):n="striker";let C=(0,g.useMemo)(()=>{let e=[];if("striker"===n){let t=w?"10.201.4.".concat(w):"10.201.4.";return e.push(T({ipAddress:t,isRequired:!0,subnetMask:"255.255.0.0",type:"bcn",typeCount:1}),T({isRequired:!0,type:"ifn",typeCount:1})),e}return e.push(T({ipAddress:"10.201.",isRequired:!0,subnetMask:"255.255.0.0",type:"bcn",typeCount:1}),T({isRequired:!0,type:"ifn",typeCount:1}),T({ipAddress:"10.101.",isRequired:!0,subnetMask:"255.255.0.0",type:"sn",typeCount:1})),e},[n,w]),I=(0,g.useMemo)(()=>"node"===n?{bcn:1,ifn:1,sn:1}:{bcn:1,ifn:1},[n]),[M,A]=(0,g.useState)({x:0,y:0}),[D,O]=(0,g.useState)({}),[L,F]=(0,g.useState)(C),[W,$]=(0,g.useState)(),[G,J]=(0,g.useState)(""),K=(0,g.useRef)({}),z=(0,g.useRef)({}),X=(0,g.useRef)(!0),Q=(0,g.useRef)({}),{data:Y=[],isLoading:ee}=(0,V.Z)("".concat(h.Z,"/init/network-interface/").concat(c),{refreshInterval:2e3,onSuccess:e=>{O(e.reduce((e,t)=>{var n;let{networkInterfaceUUID:l}=t;return e[l]=null!==(n=D[l])&&void 0!==n?n:{metadata:t},e},{}))}}),et=(0,g.useMemo)(()=>L.length>=Y.length||Object.values(D).every(e=>{let{isApplied:t}=e;return t})||"node"===n&&Y.length<=6,[n,L,Y,D]),en=(0,g.useMemo)(()=>a&&!o,[a,o]),el=(0,g.useMemo)(()=>L.every(e=>{let{type:t}=e;return"mn"!==t}),[L]),er=(0,g.useCallback)((e,t)=>{var n;return null===(n=Q.current.setMessage)||void 0===n?void 0:n.call(null,e,t)},[]),ea=(0,g.useCallback)((e,t)=>{var n;return null===(n=Q.current.setMessageRe)||void 0===n?void 0:n.call(null,e,t)},[]),eo=(0,g.useCallback)(e=>er(E.dnsCSV,e),[er]),es=(0,g.useCallback)(e=>er(E.gateway,e),[er]),ei=(0,g.useCallback)(e=>{let t,{fn:n="every",ip:l="",mask:r="",isNegateMatch:a="every"===n,onMatch:o,onMiss:s,skipUUID:i}=e,u="every"===n,c=(e,t)=>{let{b:n,bIP:l=""}=t;return e.contains(null!=n?n:l)||void 0!==n&&n.contains(e)};try{t=new v.Netmask("".concat(l,"/").concat(r))}catch(e){}return L[n](e=>{var n,r;let{inputUUID:d,ipAddressInputRef:f,subnetMaskInputRef:p}=e;if(d===i)return u;let g=null==f?void 0:null===(n=f.current.getValue)||void 0===n?void 0:n.call(null),m=null==p?void 0:null===(r=p.current.getValue)||void 0===r?void 0:r.call(null),h=!1;try{let e=new v.Netmask("".concat(g,"/").concat(m));h=c(e,{b:t,bIP:l})}catch(e){}return h?null==o||o.call(null,e):null==s||s.call(null,e),a?!h:h})},[L]),eu=(0,g.useMemo)(()=>{let e={[E.dnsCSV]:{defaults:{getValue:()=>{var e;return null===(e=K.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:()=>{eo()}},isRequired:!0,tests:[{onFailure:()=>{eo({children:"Domain name servers should be a comma-separated list of IPv4 addresses without trailing comma(s)."})},test:e=>{let{value:t}=e;return b.ah.test(t)}},{test:q.HJ}]},[E.gateway]:{defaults:{getValue:()=>{var e;return null===(e=z.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:()=>{es()}},isRequired:!0,tests:[{onFailure:()=>{es({children:"Gateway should be a valid IPv4 address."})},test:e=>{let{value:t}=e;return b.tf.test(t)}},{test:e=>{let{value:t}=e,n=!0,l=ei({fn:"some",ip:t,onMatch:e=>{let{ipAddress:l,name:r,type:a,typeCount:o}=e;if(t===l){n=!1,es({children:"Gateway cannot be the same as IP address in ".concat(r,".")});return}J("".concat(a).concat(o))}});return l||es({children:"Gateway must be in one network's subnet."}),l&&n}},{test:q.HJ}]}};return L.forEach(t=>{var n,l;let{inputUUID:r,interfaces:a,ipAddressInputRef:o,name:s,subnetMaskInputRef:i}=t,u=H(r),c=E.networkInterfaces(u),d=E.networkIPAddress(u),f=E.networkSubnetMask(u),p=e=>er(c,e),v=e=>er(d,e),g=e=>er(f,e),m=(e,t,n)=>{var l;let r="".concat(E.networkSubnetConflict(u),"-").concat(t),a="".concat(E.networkSubnetConflict(H(t)),"-").concat(e);er((null===(l=Q.current.exists)||void 0===l?void 0:l.call(null,a))?a:r,n)},h=e=>{let{ip:t=null==o?void 0:null===(n=o.current.getValue)||void 0===n?void 0:n.call(null),mask:a=null==i?void 0:null===(l=i.current.getValue)||void 0===l?void 0:l.call(null)}=e;return ei({ip:t,mask:a,onMatch:e=>{let{inputUUID:t,name:n}=e;m(r,t,{children:'"'.concat(s,'" and "').concat(n,'" cannot be in the same subnet.')})},onMiss:e=>{let{inputUUID:t}=e;m(r,t)},skipUUID:r})};e[c]={defaults:{getCompare:()=>a.map(e=>void 0!==e),onSuccess:()=>{p()}},isRequired:!0,tests:[{onFailure:()=>{p({children:"".concat(s," must have at least 1 interface.")})},test:e=>{let{compare:t}=e;return t.some(e=>e)}},{onFailure:()=>{p({children:"".concat(s," must have a Link 1 interface.")})},test:e=>{let{compare:[t,n]}=e;return!(n&&!t)}}]},e[d]={defaults:{getValue:()=>{var e;return null==o?void 0:null===(e=o.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:()=>{v()}},isRequired:!0,tests:[{onFailure:()=>{v({children:"IP address in ".concat(s," must be a valid IPv4 address.")})},test:e=>{let{value:t}=e;return b.tf.test(t)}},{test:e=>{let{value:t}=e;return h({ip:t})}},{test:q.HJ}]},e[E.networkName(u)]={defaults:{value:s},isRequired:!0,tests:[{test:q.HJ}]},e[f]={defaults:{getValue:()=>{var e;return null==i?void 0:null===(e=i.current.getValue)||void 0===e?void 0:e.call(null)},onSuccess:()=>{g()}},isRequired:!0,tests:[{onFailure:()=>{g({children:"Subnet mask in ".concat(s," must be a valid IPv4 address.")})},test:e=>{let{value:t}=e;return b.tf.test(t)}},{test:e=>{let{value:t}=e;return h({mask:t})}},{test:q.HJ}]}}),e},[L,eo,es,er,ei]),ec=(0,g.useMemo)(()=>(0,q.LT)(eu),[eu]),ed=(0,g.useCallback)(e=>{null==u||u.call(null,ec({isIgnoreOnCallbacks:!0,isTestAll:!0,...e}))},[ec,u]),ef=(0,g.useCallback)(()=>{$(void 0)},[]),ep=(0,g.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};L.unshift(T(e)),null==u||u.call(null,!1),F([...L])},[L,u]),ev=(0,g.useCallback)(e=>{let[{inputUUID:t,interfaces:n}]=L.splice(e,1);n.forEach(e=>{if(void 0===e)return;let{networkInterfaceUUID:t}=e;D[t].isApplied=!1}),ed({excludeTestIdsRe:RegExp(t)}),F([...L]),O(e=>({...e}))},[L,D,ed]),eg=(0,g.useCallback)(function(e){let{inputs:t=L,lastIndex:n=0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=0;for(let r=t.length-1;r>=n;r-=1)t[r].type===e&&(l+=1);return l},[L]),em=(0,g.useMemo)(()=>{if(void 0===W)return;let{networkInterfaceUUID:e}=W;return(t,n)=>()=>{var l;let{networkInterfaceUUID:r}=null!==(l=t[n])&&void 0!==l?l:{};r&&r!==e&&(D[r].isApplied=!1),t[n]=W,D[e].isApplied=!0}},[W,D]),eh=(0,g.useMemo)(()=>W?{cursor:"grabbing",userSelect:"none"}:{},[W]),ek=(0,g.useMemo)(()=>{if(void 0===W)return(0,l.jsx)(l.Fragment,{});let{x:e,y:t}=M;return(0,l.jsx)(y,{isFloating:!0,networkInterface:W,sx:{left:"calc(".concat(e,"px + .4em)"),position:"absolute",top:"calc(".concat(t,"px - 1.6em)"),zIndex:20}})},[M,W]),ex=(0,g.useMemo)(()=>W?()=>{ef()}:void 0,[ef,W]),eb=(0,g.useMemo)(()=>W?e=>{let{currentTarget:t,nativeEvent:{clientX:n,clientY:l}}=e,{left:r,top:a}=t.getBoundingClientRect();A({x:n-r,y:l-a})}:void 0,[W]),ew=(0,g.useMemo)(()=>W?()=>{ef()}:void 0,[ef,W]);(0,g.useEffect)(()=>{if([Object.keys(D).length>0,a,o,X.current,K.current,z.current].every(e=>!!e)){var e,t;X.current=!1;let{dns:n,gateway:l,gatewayInterface:r,networks:a}=o;if([n,l,r,a].some(e=>!e))return;null===(e=K.current.setValue)||void 0===e||e.call(null,n),null===(t=z.current.setValue)||void 0===t||t.call(null,l);let s=[],i=Object.values(a).reduce((e,t)=>{var n,l;let{ip:r,link1Uuid:a,link2Uuid:o="",subnetMask:i,type:u}=t,c=eg(u,{inputs:e})+1,d=I[u]===c,f="".concat(x.default[u]," ").concat(c);return s.push(a,o),e.push({inputUUID:(0,m.Z)(),interfaces:[null===(n=D[a])||void 0===n?void 0:n.metadata,null===(l=D[o])||void 0===l?void 0:l.metadata],ipAddress:r,isRequired:d,name:f,subnetMask:i,type:u,typeCount:c}),e},[]);J(r),O(e=>{let t={...e};return s.forEach(e=>{t[e]&&(t[e].isApplied=!0)}),t}),F(i),ed()}},[a,eg,o,D,I,ed]),(0,g.useImperativeHandle)(t,()=>({...Q.current,get:()=>{var e,t;return{dns:null===(e=K.current.getValue)||void 0===e?void 0:e.call(null),gateway:null===(t=z.current.getValue)||void 0===t?void 0:t.call(null),gatewayInterface:G,networks:L.map(e=>{var t,n,l,r;let{inputUUID:a,interfaces:o,ipAddressInputRef:s,name:i,subnetMaskInputRef:u,type:c,typeCount:d}=e;return{inputUUID:a,interfaces:o,ipAddress:null!==(l=null==s?void 0:null===(t=s.current.getValue)||void 0===t?void 0:t.call(null))&&void 0!==l?l:"",name:i,subnetMask:null!==(r=null==u?void 0:null===(n=u.current.getValue)||void 0===n?void 0:n.call(null))&&void 0!==r?r:"",type:c,typeCount:d}})}}}),[G,L]);let eC="13em";return ee?(0,l.jsx)(P.Z,{}):(0,l.jsxs)(r.Z,{onMouseDown:e=>{let{clientX:t,clientY:n,currentTarget:l}=e,{left:r,top:a}=l.getBoundingClientRect();A({x:t-r,y:n-a})},onMouseLeave:ex,onMouseMove:eb,onMouseUp:ew,sx:{position:"relative",...eh},children:[ek,(0,l.jsxs)(r.Z,{sx:{display:"flex",flexDirection:"column","& > :not(:first-child, :nth-child(3))":{marginTop:"1em"}},children:[(0,l.jsx)(f._,{autoHeight:!0,columns:B(e=>{$(e)},D),componentsProps:{row:{onMouseDown:e=>{let{target:{parentElement:{dataset:{id:t}={}}={}}={}}=e;if(t){let{isApplied:e,metadata:n}=D[t];e||$(n)}}}},disableColumnMenu:!0,disableSelectionOnClick:!0,getRowClassName:e=>{var t;let{row:{networkInterfaceUUID:n}}=e,{isApplied:l}=null!==(t=D[n])&&void 0!==t&&t,r="";return l||(r+=" ".concat(U.ifaceNotApplied)),r},getRowId:e=>{let{networkInterfaceUUID:t}=e;return t},hideFooter:!0,initialState:{sorting:{sortModel:[{field:"networkInterfaceName",sort:"asc"}]}},rows:Y,sx:{color:k.s7,["& .".concat(s.Z.root)]:{color:"inherit"},["& .".concat(p._.cell,":focus")]:{outline:"none"},["& .".concat(p._.row,".").concat(U.ifaceNotApplied,":hover")]:{cursor:"grab",["& .".concat(p._.cell," p")]:{cursor:"auto"}}}}),!en&&(0,l.jsx)(j.Z,{row:!0,sx:{"& > :first-child":{alignSelf:"start",marginTop:".7em"},"& > :last-child":{flexGrow:1}},children:(0,l.jsx)(r.Z,{sx:{alignItems:"strech",display:"flex",flexDirection:"row",overflowX:"auto",paddingLeft:".3em","& > div":{marginBottom:".8em",marginTop:".4em",minWidth:eC,width:"25%"},"& > :not(:first-child)":{marginLeft:"1em"}},children:L.map((e,t)=>{let{inputUUID:r}=e;return(0,l.jsx)(_,{allowMigrationNetwork:el,createDropMouseUpHandler:em,getNetworkTypeCount:eg,hostDetail:{hostType:n,sequence:w},networkIndex:t,networkInput:e,networkInterfaceCount:Y.length,networkInterfaceInputMap:D,removeNetwork:ev,setMessageRe:ea,setNetworkInputs:F,setNetworkInterfaceInputMap:O,testInput:ec,testInputToToggleSubmitDisabled:ed},"network-".concat(r))})})}),(0,l.jsxs)(j.Z,{sm:"row",sx:{marginTop:".2em","& > :not(button)":{minWidth:eC,width:{sm:"25%"}}},children:[(0,l.jsx)(S.Z,{disabled:et,onClick:()=>{ep()},children:(0,l.jsx)(d.Z,{})}),(0,l.jsx)(Z.Z,{input:(0,l.jsx)(N.Z,{id:"network-init-gateway",inputProps:{onBlur:e=>{let{target:{value:t}}=e;ec({inputs:{[E.gateway]:{value:t}}})}},inputLabelProps:{isNotifyRequired:!0},onChange:e=>{let{target:{value:t}}=e;ed({inputs:{[E.gateway]:{value:t}}}),es()},label:"Gateway"}),ref:z}),(0,l.jsx)(Z.Z,{input:(0,l.jsx)(N.Z,{id:"network-init-dns-csv",inputProps:{onBlur:e=>{let{target:{value:t}}=e;ec({inputs:{[E.dnsCSV]:{value:t}}})}},inputLabelProps:{isNotifyRequired:!0},onChange:e=>{let{target:{value:t}}=e;ed({inputs:{[E.dnsCSV]:{value:t}}}),eo()},label:"Domain name server(s)"}),ref:K})]}),(0,l.jsx)(R.Z,{count:1,defaultMessageType:"warning",ref:Q})]})]})});W.defaultProps={expectHostDetail:!1,hostDetail:void 0,hostSequence:void 0,toggleSubmitDisabled:void 0},W.displayName="NetworkInitForm";var $=W},26339:function(e,t){t.default={bcn:"Back-Channel Network",ifn:"Internet-Facing Network",mn:"Migration Network",sn:"Storage Network"}}}]); |