|
|
@ -261,6 +261,7 @@ const createNetworkInterfaceTableColumns = ( |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
const NetworkForm: FC<{ |
|
|
|
const NetworkForm: FC<{ |
|
|
|
|
|
|
|
allowMigrationNetwork?: boolean; |
|
|
|
createDropMouseUpHandler?: ( |
|
|
|
createDropMouseUpHandler?: ( |
|
|
|
interfaces: (NetworkInterfaceOverviewMetadata | undefined)[], |
|
|
|
interfaces: (NetworkInterfaceOverviewMetadata | undefined)[], |
|
|
|
interfaceIndex: number, |
|
|
|
interfaceIndex: number, |
|
|
@ -280,6 +281,7 @@ const NetworkForm: FC<{ |
|
|
|
testInput: (options?: TestInputFunctionOptions) => boolean; |
|
|
|
testInput: (options?: TestInputFunctionOptions) => boolean; |
|
|
|
testInputToToggleSubmitDisabled: TestInputToToggleSubmitDisabled; |
|
|
|
testInputToToggleSubmitDisabled: TestInputToToggleSubmitDisabled; |
|
|
|
}> = ({ |
|
|
|
}> = ({ |
|
|
|
|
|
|
|
allowMigrationNetwork, |
|
|
|
createDropMouseUpHandler, |
|
|
|
createDropMouseUpHandler, |
|
|
|
getNetworkTypeCount, |
|
|
|
getNetworkTypeCount, |
|
|
|
hostDetail: { hostType, sequence } = {}, |
|
|
|
hostDetail: { hostType, sequence } = {}, |
|
|
@ -341,10 +343,34 @@ const NetworkForm: FC<{ |
|
|
|
const netTypeList = useMemo(() => { |
|
|
|
const netTypeList = useMemo(() => { |
|
|
|
const { bcn, ifn, mn, sn } = NETWORK_TYPES; |
|
|
|
const { bcn, ifn, mn, sn } = NETWORK_TYPES; |
|
|
|
|
|
|
|
|
|
|
|
return isNode && networkInterfaceCount >= 8 |
|
|
|
return isNode && |
|
|
|
|
|
|
|
networkInterfaceCount >= 8 && |
|
|
|
|
|
|
|
(allowMigrationNetwork || type === 'mn') |
|
|
|
? { bcn, ifn, mn, sn } |
|
|
|
? { bcn, ifn, mn, sn } |
|
|
|
: { bcn, ifn, sn }; |
|
|
|
: { bcn, ifn, sn }; |
|
|
|
}, [isNode, networkInterfaceCount]); |
|
|
|
}, [allowMigrationNetwork, isNode, networkInterfaceCount, type]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const setIpAndMask = useCallback( |
|
|
|
|
|
|
|
(nInput: NetworkInput, ip: string, mask: string) => { |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
current: { getIsChangedByUser: getIpModded, setValue: setIp }, |
|
|
|
|
|
|
|
} = ipAddressInputRef; |
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
current: { getIsChangedByUser: getMaskModded, setValue: setMask }, |
|
|
|
|
|
|
|
} = subnetMaskInputRef; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!getIpModded?.call(null)) { |
|
|
|
|
|
|
|
nInput.ipAddress = ip; |
|
|
|
|
|
|
|
setIp?.call(null, ip); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!getMaskModded?.call(null)) { |
|
|
|
|
|
|
|
nInput.subnetMask = mask; |
|
|
|
|
|
|
|
setMask?.call(null, mask); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
useEffect((): void => { |
|
|
|
useEffect((): void => { |
|
|
|
if (hostType !== 'striker' || type === 'ifn') return; |
|
|
|
if (hostType !== 'striker' || type === 'ifn') return; |
|
|
@ -399,6 +425,12 @@ const NetworkForm: FC<{ |
|
|
|
onChange: ({ target: { value } }) => { |
|
|
|
onChange: ({ target: { value } }) => { |
|
|
|
const networkType = String(value); |
|
|
|
const networkType = String(value); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (networkType === 'mn') { |
|
|
|
|
|
|
|
setIpAndMask(networkInput, '10.199.', '255.255.0.0'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setIpAndMask(networkInput, '', ''); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
networkInput.type = networkType; |
|
|
|
networkInput.type = networkType; |
|
|
|
|
|
|
|
|
|
|
|
const networkTypeCount = getNetworkTypeCount(networkType, { |
|
|
|
const networkTypeCount = getNetworkTypeCount(networkType, { |
|
|
@ -580,6 +612,7 @@ const NetworkForm: FC<{ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
NetworkForm.defaultProps = { |
|
|
|
NetworkForm.defaultProps = { |
|
|
|
|
|
|
|
allowMigrationNetwork: true, |
|
|
|
createDropMouseUpHandler: undefined, |
|
|
|
createDropMouseUpHandler: undefined, |
|
|
|
hostDetail: undefined, |
|
|
|
hostDetail: undefined, |
|
|
|
}; |
|
|
|
}; |
|
|
@ -726,6 +759,13 @@ const NetworkInitForm = forwardRef< |
|
|
|
() => expectHostDetail && !hostDetail, |
|
|
|
() => expectHostDetail && !hostDetail, |
|
|
|
[expectHostDetail, hostDetail], |
|
|
|
[expectHostDetail, hostDetail], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Allow user to add migration network only if none exists. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const allowMigrationNetwork: boolean = useMemo( |
|
|
|
|
|
|
|
() => networkInputs.every(({ type }) => type !== 'mn'), |
|
|
|
|
|
|
|
[networkInputs], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const setMessage = useCallback( |
|
|
|
const setMessage = useCallback( |
|
|
|
(key: string, message?: Message) => |
|
|
|
(key: string, message?: Message) => |
|
|
@ -1508,6 +1548,7 @@ const NetworkInitForm = forwardRef< |
|
|
|
<NetworkForm |
|
|
|
<NetworkForm |
|
|
|
key={`network-${inputUUID}`} |
|
|
|
key={`network-${inputUUID}`} |
|
|
|
{...{ |
|
|
|
{...{ |
|
|
|
|
|
|
|
allowMigrationNetwork, |
|
|
|
createDropMouseUpHandler, |
|
|
|
createDropMouseUpHandler, |
|
|
|
getNetworkTypeCount, |
|
|
|
getNetworkTypeCount, |
|
|
|
hostDetail: { hostType, sequence }, |
|
|
|
hostDetail: { hostType, sequence }, |
|
|
|