diff --git a/striker-ui/components/NetworkInitForm.tsx b/striker-ui/components/NetworkInitForm.tsx index b955015f..d9492998 100644 --- a/striker-ui/components/NetworkInitForm.tsx +++ b/striker-ui/components/NetworkInitForm.tsx @@ -1317,40 +1317,46 @@ const NetworkInitForm = forwardRef< networks: pNetworks, } = hostDetail as APIHostDetail; + if ( + [pDns, pGateway, pGatewayInterface, pNetworks].some( + (condition) => !condition, + ) + ) { + return; + } + dnsCSVInputRef.current.setValue?.call(null, pDns); gatewayInputRef.current.setValue?.call(null, pGateway); const applied: string[] = []; - const inputs = Object.values(pNetworks).reduce( - (previous, { ip, link1Uuid, link2Uuid = '', subnetMask, type }) => { - const typeCount = - getNetworkTypeCount(type, { inputs: previous }) + 1; - const isRequired = requiredNetworks[type] === typeCount; - - const name = `${NETWORK_TYPES[type]} ${typeCount}`; - - applied.push(link1Uuid, link2Uuid); - - previous.push({ - inputUUID: uuidv4(), - interfaces: [ - networkInterfaceInputMap[link1Uuid]?.metadata, - networkInterfaceInputMap[link2Uuid]?.metadata, - ], - ipAddress: ip, - isRequired, - name, - subnetMask, - type, - typeCount, - }); + const inputs = Object.values(pNetworks as APIHostNetworkList).reduce< + NetworkInput[] + >((previous, { ip, link1Uuid, link2Uuid = '', subnetMask, type }) => { + const typeCount = getNetworkTypeCount(type, { inputs: previous }) + 1; + const isRequired = requiredNetworks[type] === typeCount; - return previous; - }, - [], - ); + const name = `${NETWORK_TYPES[type]} ${typeCount}`; + + applied.push(link1Uuid, link2Uuid); - setGatewayInterface(pGatewayInterface); + previous.push({ + inputUUID: uuidv4(), + interfaces: [ + networkInterfaceInputMap[link1Uuid]?.metadata, + networkInterfaceInputMap[link2Uuid]?.metadata, + ], + ipAddress: ip, + isRequired, + name, + subnetMask, + type, + typeCount, + }); + + return previous; + }, []); + + setGatewayInterface(pGatewayInterface as string); setNetworkInterfaceInputMap((previous) => { const result = { ...previous }; @@ -1369,11 +1375,9 @@ const NetworkInitForm = forwardRef< testInputToToggleSubmitDisabled(); } }, [ - createNetwork, expectHostDetail, getNetworkTypeCount, hostDetail, - networkInputs, networkInterfaceInputMap, requiredNetworks, testInputToToggleSubmitDisabled, diff --git a/striker-ui/types/APIHost.d.ts b/striker-ui/types/APIHost.d.ts index 5176f6ed..c7df4c96 100644 --- a/striker-ui/types/APIHost.d.ts +++ b/striker-ui/types/APIHost.d.ts @@ -39,24 +39,28 @@ type APIHostOverviewList = { [hostUUID: string]: APIHostOverview; }; +type APIHostNetwork = { + createBridge?: NumberBoolean; + ip: string; + link1MacToSet: string; + link1Uuid: string; + link2MacToSet?: string; + link2Uuid?: string; + subnetMask: string; + type: NetworkType; +}; + +type APIHostNetworkList = { + [networkId: string]: APIHostNetwork; +}; + type APIHostDetail = APIHostOverview & { - dns: string; + dns?: string; domain?: string; - gateway: string; - gatewayInterface: string; - installTarget: APIHostInstallTarget; - networks: { - [networkId: string]: { - createBridge?: NumberBoolean; - ip: string; - link1MacToSet: string; - link1Uuid: string; - link2MacToSet?: string; - link2Uuid?: string; - subnetMask: string; - type: NetworkType; - }; - }; + gateway?: string; + gatewayInterface?: string; + installTarget?: APIHostInstallTarget; + networks?: APIHostNetworkList; organization?: string; prefix?: string; sequence?: string;