|
|
@ -1317,40 +1317,46 @@ const NetworkInitForm = forwardRef< |
|
|
|
networks: pNetworks, |
|
|
|
networks: pNetworks, |
|
|
|
} = hostDetail as APIHostDetail; |
|
|
|
} = hostDetail as APIHostDetail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
|
|
[pDns, pGateway, pGatewayInterface, pNetworks].some( |
|
|
|
|
|
|
|
(condition) => !condition, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dnsCSVInputRef.current.setValue?.call(null, pDns); |
|
|
|
dnsCSVInputRef.current.setValue?.call(null, pDns); |
|
|
|
gatewayInputRef.current.setValue?.call(null, pGateway); |
|
|
|
gatewayInputRef.current.setValue?.call(null, pGateway); |
|
|
|
|
|
|
|
|
|
|
|
const applied: string[] = []; |
|
|
|
const applied: string[] = []; |
|
|
|
const inputs = Object.values(pNetworks).reduce<NetworkInput[]>( |
|
|
|
const inputs = Object.values(pNetworks as APIHostNetworkList).reduce< |
|
|
|
(previous, { ip, link1Uuid, link2Uuid = '', subnetMask, type }) => { |
|
|
|
NetworkInput[] |
|
|
|
const typeCount = |
|
|
|
>((previous, { ip, link1Uuid, link2Uuid = '', subnetMask, type }) => { |
|
|
|
getNetworkTypeCount(type, { inputs: previous }) + 1; |
|
|
|
const typeCount = getNetworkTypeCount(type, { inputs: previous }) + 1; |
|
|
|
const isRequired = requiredNetworks[type] === typeCount; |
|
|
|
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, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) => { |
|
|
|
setNetworkInterfaceInputMap((previous) => { |
|
|
|
const result = { ...previous }; |
|
|
|
const result = { ...previous }; |
|
|
@ -1369,11 +1375,9 @@ const NetworkInitForm = forwardRef< |
|
|
|
testInputToToggleSubmitDisabled(); |
|
|
|
testInputToToggleSubmitDisabled(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
createNetwork, |
|
|
|
|
|
|
|
expectHostDetail, |
|
|
|
expectHostDetail, |
|
|
|
getNetworkTypeCount, |
|
|
|
getNetworkTypeCount, |
|
|
|
hostDetail, |
|
|
|
hostDetail, |
|
|
|
networkInputs, |
|
|
|
|
|
|
|
networkInterfaceInputMap, |
|
|
|
networkInterfaceInputMap, |
|
|
|
requiredNetworks, |
|
|
|
requiredNetworks, |
|
|
|
testInputToToggleSubmitDisabled, |
|
|
|
testInputToToggleSubmitDisabled, |
|
|
|