|
|
@ -582,14 +582,8 @@ const NetworkInitForm = forwardRef< |
|
|
|
toggleSubmitDisabled?: (testResult: boolean) => void; |
|
|
|
toggleSubmitDisabled?: (testResult: boolean) => void; |
|
|
|
} |
|
|
|
} |
|
|
|
>(({ expectHostDetail = false, hostDetail, toggleSubmitDisabled }, ref) => { |
|
|
|
>(({ expectHostDetail = false, hostDetail, toggleSubmitDisabled }, ref) => { |
|
|
|
const { |
|
|
|
const { hostType, hostUUID = 'local' }: APIHostDetail = |
|
|
|
dns: previousDns, |
|
|
|
hostDetail ?? ({} as APIHostDetail); |
|
|
|
gateway: previousGateway, |
|
|
|
|
|
|
|
gatewayInterface: previousGatewayInterface, |
|
|
|
|
|
|
|
hostType, |
|
|
|
|
|
|
|
hostUUID = 'local', |
|
|
|
|
|
|
|
networks: previousNetworks, |
|
|
|
|
|
|
|
}: APIHostDetail = hostDetail ?? ({} as APIHostDetail); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const uninitRequiredNetworks: NetworkInput[] = useMemo( |
|
|
|
const uninitRequiredNetworks: NetworkInput[] = useMemo( |
|
|
|
() => |
|
|
|
() => |
|
|
@ -1180,15 +1174,29 @@ const NetworkInitForm = forwardRef< |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
Object.keys(networkInterfaceInputMap).length > 0 && |
|
|
|
[ |
|
|
|
expectHostDetail && |
|
|
|
Object.keys(networkInterfaceInputMap).length > 0, |
|
|
|
hostDetail && |
|
|
|
expectHostDetail, |
|
|
|
readHostDetailRef.current |
|
|
|
hostDetail, |
|
|
|
|
|
|
|
readHostDetailRef.current, |
|
|
|
|
|
|
|
dnsCSVInputRef.current, |
|
|
|
|
|
|
|
gatewayInputRef.current, |
|
|
|
|
|
|
|
].every((condition) => Boolean(condition)) |
|
|
|
) { |
|
|
|
) { |
|
|
|
readHostDetailRef.current = false; |
|
|
|
readHostDetailRef.current = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
dns: pDns, |
|
|
|
|
|
|
|
gateway: pGateway, |
|
|
|
|
|
|
|
gatewayInterface: pGatewayInterface, |
|
|
|
|
|
|
|
networks: pNetworks, |
|
|
|
|
|
|
|
} = hostDetail as APIHostDetail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dnsCSVInputRef.current.setValue?.call(null, pDns); |
|
|
|
|
|
|
|
gatewayInputRef.current.setValue?.call(null, pGateway); |
|
|
|
|
|
|
|
|
|
|
|
const applied: string[] = []; |
|
|
|
const applied: string[] = []; |
|
|
|
const inputs = Object.values(previousNetworks).reduce<NetworkInput[]>( |
|
|
|
const inputs = Object.values(pNetworks).reduce<NetworkInput[]>( |
|
|
|
(previous, { ip, link1Uuid, link2Uuid = '', subnetMask, type }) => { |
|
|
|
(previous, { ip, link1Uuid, link2Uuid = '', subnetMask, type }) => { |
|
|
|
const typeCount = getNetworkTypeCount(type, { inputs: previous }) + 1; |
|
|
|
const typeCount = getNetworkTypeCount(type, { inputs: previous }) + 1; |
|
|
|
const isRequired = requiredNetworks[type] === typeCount; |
|
|
|
const isRequired = requiredNetworks[type] === typeCount; |
|
|
@ -1216,7 +1224,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
[], |
|
|
|
[], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
setGatewayInterface(previousGatewayInterface); |
|
|
|
setGatewayInterface(pGatewayInterface); |
|
|
|
|
|
|
|
|
|
|
|
setNetworkInterfaceInputMap((previous) => { |
|
|
|
setNetworkInterfaceInputMap((previous) => { |
|
|
|
const result = { ...previous }; |
|
|
|
const result = { ...previous }; |
|
|
@ -1231,6 +1239,8 @@ const NetworkInitForm = forwardRef< |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
setNetworkInputs(inputs); |
|
|
|
setNetworkInputs(inputs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testInputToToggleSubmitDisabled(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
createNetwork, |
|
|
|
createNetwork, |
|
|
@ -1239,9 +1249,8 @@ const NetworkInitForm = forwardRef< |
|
|
|
hostDetail, |
|
|
|
hostDetail, |
|
|
|
networkInputs, |
|
|
|
networkInputs, |
|
|
|
networkInterfaceInputMap, |
|
|
|
networkInterfaceInputMap, |
|
|
|
previousGatewayInterface, |
|
|
|
|
|
|
|
previousNetworks, |
|
|
|
|
|
|
|
requiredNetworks, |
|
|
|
requiredNetworks, |
|
|
|
|
|
|
|
testInputToToggleSubmitDisabled, |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
@ -1492,7 +1501,6 @@ const NetworkInitForm = forwardRef< |
|
|
|
setGatewayInputMessage(); |
|
|
|
setGatewayInputMessage(); |
|
|
|
}} |
|
|
|
}} |
|
|
|
label="Gateway" |
|
|
|
label="Gateway" |
|
|
|
value={previousGateway} |
|
|
|
|
|
|
|
/> |
|
|
|
/> |
|
|
|
} |
|
|
|
} |
|
|
|
ref={gatewayInputRef} |
|
|
|
ref={gatewayInputRef} |
|
|
@ -1514,7 +1522,6 @@ const NetworkInitForm = forwardRef< |
|
|
|
setDnsInputMessage(); |
|
|
|
setDnsInputMessage(); |
|
|
|
}} |
|
|
|
}} |
|
|
|
label="Domain name server(s)" |
|
|
|
label="Domain name server(s)" |
|
|
|
value={previousDns} |
|
|
|
|
|
|
|
/> |
|
|
|
/> |
|
|
|
} |
|
|
|
} |
|
|
|
ref={dnsCSVInputRef} |
|
|
|
ref={dnsCSVInputRef} |
|
|
|