|
|
@ -110,42 +110,6 @@ const CLASSES = { |
|
|
|
const INITIAL_IFACES = [undefined, undefined]; |
|
|
|
const INITIAL_IFACES = [undefined, undefined]; |
|
|
|
const MSG_ID_API = 'api'; |
|
|
|
const MSG_ID_API = 'api'; |
|
|
|
|
|
|
|
|
|
|
|
const STRIKER_REQUIRED_NETWORKS: NetworkInput[] = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
inputUUID: '30dd2ac5-8024-4a7e-83a1-6a3df7218972', |
|
|
|
|
|
|
|
interfaces: [...INITIAL_IFACES], |
|
|
|
|
|
|
|
ipAddress: '10.200.1.1', |
|
|
|
|
|
|
|
isRequired: true, |
|
|
|
|
|
|
|
name: `${NETWORK_TYPES.bcn} 1`, |
|
|
|
|
|
|
|
subnetMask: '255.255.0.0', |
|
|
|
|
|
|
|
type: 'bcn', |
|
|
|
|
|
|
|
typeCount: 1, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
inputUUID: 'e7ef3af5-5602-440c-87f8-69c242e3d7f3', |
|
|
|
|
|
|
|
interfaces: [...INITIAL_IFACES], |
|
|
|
|
|
|
|
ipAddress: '10.201.1.1', |
|
|
|
|
|
|
|
isRequired: true, |
|
|
|
|
|
|
|
name: `${NETWORK_TYPES.ifn} 1`, |
|
|
|
|
|
|
|
subnetMask: '255.255.0.0', |
|
|
|
|
|
|
|
type: 'ifn', |
|
|
|
|
|
|
|
typeCount: 1, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
const NODE_REQUIRED_NETWORKS: NetworkInput[] = [ |
|
|
|
|
|
|
|
...STRIKER_REQUIRED_NETWORKS, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
inputUUID: '525e4847-f929-44a7-83b2-28eb289ffb57', |
|
|
|
|
|
|
|
interfaces: [...INITIAL_IFACES], |
|
|
|
|
|
|
|
ipAddress: '10.202.1.1', |
|
|
|
|
|
|
|
isRequired: true, |
|
|
|
|
|
|
|
name: `${NETWORK_TYPES.sn} 1`, |
|
|
|
|
|
|
|
subnetMask: '255.255.0.0', |
|
|
|
|
|
|
|
type: 'sn', |
|
|
|
|
|
|
|
typeCount: 1, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const MAX_INTERFACES_PER_NETWORK = 2; |
|
|
|
const MAX_INTERFACES_PER_NETWORK = 2; |
|
|
|
const IT_IDS = { |
|
|
|
const IT_IDS = { |
|
|
|
dnsCSV: 'dns', |
|
|
|
dnsCSV: 'dns', |
|
|
@ -161,9 +125,56 @@ const NETWORK_INTERFACE_TEMPLATE = Array.from( |
|
|
|
{ length: MAX_INTERFACES_PER_NETWORK }, |
|
|
|
{ length: MAX_INTERFACES_PER_NETWORK }, |
|
|
|
(unused, index) => index + 1, |
|
|
|
(unused, index) => index + 1, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
const MAP_TO_NETWORK_TYPE_DEFAULTS: Record< |
|
|
|
|
|
|
|
string, |
|
|
|
|
|
|
|
{ ip: (sequence: number | string, postfix?: string) => string; mask: string } |
|
|
|
|
|
|
|
> = { |
|
|
|
|
|
|
|
bcn: { |
|
|
|
|
|
|
|
ip: (sequence, postfix = '') => `10.20${sequence}.${postfix}`, |
|
|
|
|
|
|
|
mask: '255.255.0.0', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
ifn: { ip: () => '', mask: '' }, |
|
|
|
|
|
|
|
mn: { ip: () => '10.199.', mask: '255.255.0.0' }, |
|
|
|
|
|
|
|
sn: { |
|
|
|
|
|
|
|
ip: (sequence, postfix = '') => `10.10${sequence}.${postfix}`, |
|
|
|
|
|
|
|
mask: '255.255.0.0', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const createInputTestPrefix = (uuid: string) => `network${uuid}`; |
|
|
|
const createInputTestPrefix = (uuid: string) => `network${uuid}`; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const createNetworkInput = ({ |
|
|
|
|
|
|
|
inputUUID = uuidv4(), |
|
|
|
|
|
|
|
interfaces = [...INITIAL_IFACES], |
|
|
|
|
|
|
|
ipAddress = '', |
|
|
|
|
|
|
|
name: initName, |
|
|
|
|
|
|
|
subnetMask = '', |
|
|
|
|
|
|
|
type = '', |
|
|
|
|
|
|
|
typeCount = 0, |
|
|
|
|
|
|
|
...rest |
|
|
|
|
|
|
|
}: Partial<NetworkInput> = {}): NetworkInput => { |
|
|
|
|
|
|
|
let name = initName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!initName) { |
|
|
|
|
|
|
|
if (NETWORK_TYPES[type] && typeCount > 0) { |
|
|
|
|
|
|
|
name = `${NETWORK_TYPES[type]} ${typeCount}`; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
name = 'Unknown Network'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
inputUUID, |
|
|
|
|
|
|
|
interfaces, |
|
|
|
|
|
|
|
ipAddress, |
|
|
|
|
|
|
|
name, |
|
|
|
|
|
|
|
subnetMask, |
|
|
|
|
|
|
|
type, |
|
|
|
|
|
|
|
typeCount, |
|
|
|
|
|
|
|
...rest, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const createNetworkInterfaceTableColumns = ( |
|
|
|
const createNetworkInterfaceTableColumns = ( |
|
|
|
handleDragMouseDown: ( |
|
|
|
handleDragMouseDown: ( |
|
|
|
row: NetworkInterfaceOverviewMetadata, |
|
|
|
row: NetworkInterfaceOverviewMetadata, |
|
|
@ -265,12 +276,13 @@ const createNetworkInterfaceTableColumns = ( |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
const NetworkForm: FC<{ |
|
|
|
const NetworkForm: FC<{ |
|
|
|
|
|
|
|
allowMigrationNetwork?: boolean; |
|
|
|
createDropMouseUpHandler?: ( |
|
|
|
createDropMouseUpHandler?: ( |
|
|
|
interfaces: (NetworkInterfaceOverviewMetadata | undefined)[], |
|
|
|
interfaces: (NetworkInterfaceOverviewMetadata | undefined)[], |
|
|
|
interfaceIndex: number, |
|
|
|
interfaceIndex: number, |
|
|
|
) => MUIBoxProps['onMouseUp']; |
|
|
|
) => MUIBoxProps['onMouseUp']; |
|
|
|
getNetworkTypeCount: GetNetworkTypeCountFunction; |
|
|
|
getNetworkTypeCount: GetNetworkTypeCountFunction; |
|
|
|
hostDetail?: APIHostDetail; |
|
|
|
hostDetail?: Partial<Pick<APIHostDetail, 'hostType' | 'sequence'>>; |
|
|
|
networkIndex: number; |
|
|
|
networkIndex: number; |
|
|
|
networkInput: NetworkInput; |
|
|
|
networkInput: NetworkInput; |
|
|
|
networkInterfaceCount: number; |
|
|
|
networkInterfaceCount: number; |
|
|
@ -284,9 +296,10 @@ const NetworkForm: FC<{ |
|
|
|
testInput: (options?: TestInputFunctionOptions) => boolean; |
|
|
|
testInput: (options?: TestInputFunctionOptions) => boolean; |
|
|
|
testInputToToggleSubmitDisabled: TestInputToToggleSubmitDisabled; |
|
|
|
testInputToToggleSubmitDisabled: TestInputToToggleSubmitDisabled; |
|
|
|
}> = ({ |
|
|
|
}> = ({ |
|
|
|
|
|
|
|
allowMigrationNetwork, |
|
|
|
createDropMouseUpHandler, |
|
|
|
createDropMouseUpHandler, |
|
|
|
getNetworkTypeCount, |
|
|
|
getNetworkTypeCount, |
|
|
|
hostDetail: { hostType } = {}, |
|
|
|
hostDetail: { hostType, sequence } = {}, |
|
|
|
networkIndex, |
|
|
|
networkIndex, |
|
|
|
networkInput, |
|
|
|
networkInput, |
|
|
|
networkInterfaceCount, |
|
|
|
networkInterfaceCount, |
|
|
@ -345,10 +358,48 @@ 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 => { |
|
|
|
|
|
|
|
if (hostType !== 'striker' || type === 'ifn') return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const changedByUser = |
|
|
|
|
|
|
|
ipAddressInputRef.current.getIsChangedByUser?.call(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (changedByUser || !Number(sequence)) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ipAddressInputRef.current.setValue?.call( |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
ipAddress.replace(/^((?:\d+\.){3})\d*$/, `$1${sequence}`), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, [hostType, ipAddress, sequence, type]); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
const { ipAddressInputRef: ipRef, subnetMaskInputRef: maskRef } = |
|
|
|
const { ipAddressInputRef: ipRef, subnetMaskInputRef: maskRef } = |
|
|
@ -398,6 +449,21 @@ const NetworkForm: FC<{ |
|
|
|
networkInput.typeCount = networkTypeCount; |
|
|
|
networkInput.typeCount = networkTypeCount; |
|
|
|
networkInput.name = `${NETWORK_TYPES[networkType]} ${networkTypeCount}`; |
|
|
|
networkInput.name = `${NETWORK_TYPES[networkType]} ${networkTypeCount}`; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const networkTypeDefaults = |
|
|
|
|
|
|
|
MAP_TO_NETWORK_TYPE_DEFAULTS[networkType]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (networkTypeDefaults) { |
|
|
|
|
|
|
|
const { ip, mask } = networkTypeDefaults; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let postfix: string | undefined; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hostType === 'striker' && networkType === 'bcn') { |
|
|
|
|
|
|
|
postfix = '4.'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setIpAndMask(networkInput, ip(networkTypeCount, postfix), mask); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setNetworkInputs((previous) => [...previous]); |
|
|
|
setNetworkInputs((previous) => [...previous]); |
|
|
|
}, |
|
|
|
}, |
|
|
|
renderValue: breakpointLarge |
|
|
|
renderValue: breakpointLarge |
|
|
@ -570,6 +636,7 @@ const NetworkForm: FC<{ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
NetworkForm.defaultProps = { |
|
|
|
NetworkForm.defaultProps = { |
|
|
|
|
|
|
|
allowMigrationNetwork: true, |
|
|
|
createDropMouseUpHandler: undefined, |
|
|
|
createDropMouseUpHandler: undefined, |
|
|
|
hostDetail: undefined, |
|
|
|
hostDetail: undefined, |
|
|
|
}; |
|
|
|
}; |
|
|
@ -579,18 +646,78 @@ const NetworkInitForm = forwardRef< |
|
|
|
{ |
|
|
|
{ |
|
|
|
expectHostDetail?: boolean; |
|
|
|
expectHostDetail?: boolean; |
|
|
|
hostDetail?: APIHostDetail; |
|
|
|
hostDetail?: APIHostDetail; |
|
|
|
|
|
|
|
hostSequence?: string; |
|
|
|
toggleSubmitDisabled?: (testResult: boolean) => void; |
|
|
|
toggleSubmitDisabled?: (testResult: boolean) => void; |
|
|
|
} |
|
|
|
} |
|
|
|
>(({ expectHostDetail = false, hostDetail, toggleSubmitDisabled }, ref) => { |
|
|
|
>( |
|
|
|
const { hostType, hostUUID = 'local' }: APIHostDetail = |
|
|
|
( |
|
|
|
hostDetail ?? ({} as APIHostDetail); |
|
|
|
{ |
|
|
|
|
|
|
|
expectHostDetail = false, |
|
|
|
|
|
|
|
hostDetail, |
|
|
|
|
|
|
|
hostSequence, |
|
|
|
|
|
|
|
toggleSubmitDisabled, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
ref, |
|
|
|
|
|
|
|
) => { |
|
|
|
|
|
|
|
let hostType: string | undefined; |
|
|
|
|
|
|
|
let hostUUID = 'local'; |
|
|
|
|
|
|
|
let sequence = hostSequence; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!expectHostDetail) { |
|
|
|
|
|
|
|
hostType = 'striker'; |
|
|
|
|
|
|
|
} else if (hostDetail) { |
|
|
|
|
|
|
|
({ hostType, hostUUID, sequence } = hostDetail); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const uninitRequiredNetworks: NetworkInput[] = useMemo( |
|
|
|
const initRequiredNetworks: NetworkInput[] = useMemo(() => { |
|
|
|
() => |
|
|
|
const result: NetworkInput[] = []; |
|
|
|
hostType === 'node' ? NODE_REQUIRED_NETWORKS : STRIKER_REQUIRED_NETWORKS, |
|
|
|
|
|
|
|
[hostType], |
|
|
|
if (hostType === 'striker') { |
|
|
|
|
|
|
|
const ipAddress = sequence ? `10.201.4.${sequence}` : '10.201.4.'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.push( |
|
|
|
|
|
|
|
createNetworkInput({ |
|
|
|
|
|
|
|
ipAddress, |
|
|
|
|
|
|
|
isRequired: true, |
|
|
|
|
|
|
|
subnetMask: '255.255.0.0', |
|
|
|
|
|
|
|
type: 'bcn', |
|
|
|
|
|
|
|
typeCount: 1, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
createNetworkInput({ |
|
|
|
|
|
|
|
isRequired: true, |
|
|
|
|
|
|
|
type: 'ifn', |
|
|
|
|
|
|
|
typeCount: 1, |
|
|
|
|
|
|
|
}), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.push( |
|
|
|
|
|
|
|
createNetworkInput({ |
|
|
|
|
|
|
|
ipAddress: '10.201.', |
|
|
|
|
|
|
|
isRequired: true, |
|
|
|
|
|
|
|
subnetMask: '255.255.0.0', |
|
|
|
|
|
|
|
type: 'bcn', |
|
|
|
|
|
|
|
typeCount: 1, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
createNetworkInput({ |
|
|
|
|
|
|
|
isRequired: true, |
|
|
|
|
|
|
|
type: 'ifn', |
|
|
|
|
|
|
|
typeCount: 1, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
createNetworkInput({ |
|
|
|
|
|
|
|
ipAddress: '10.101.', |
|
|
|
|
|
|
|
isRequired: true, |
|
|
|
|
|
|
|
subnetMask: '255.255.0.0', |
|
|
|
|
|
|
|
type: 'sn', |
|
|
|
|
|
|
|
typeCount: 1, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
}, [hostType, sequence]); |
|
|
|
|
|
|
|
|
|
|
|
const requiredNetworks = useMemo<Partial<Record<NetworkType, number>>>( |
|
|
|
const requiredNetworks = useMemo<Partial<Record<NetworkType, number>>>( |
|
|
|
() => |
|
|
|
() => |
|
|
|
hostType === 'node' ? { bcn: 1, ifn: 1, sn: 1 } : { bcn: 1, ifn: 1 }, |
|
|
|
hostType === 'node' ? { bcn: 1, ifn: 1, sn: 1 } : { bcn: 1, ifn: 1 }, |
|
|
@ -603,9 +730,8 @@ const NetworkInitForm = forwardRef< |
|
|
|
}>({ x: 0, y: 0 }); |
|
|
|
}>({ x: 0, y: 0 }); |
|
|
|
const [networkInterfaceInputMap, setNetworkInterfaceInputMap] = |
|
|
|
const [networkInterfaceInputMap, setNetworkInterfaceInputMap] = |
|
|
|
useState<NetworkInterfaceInputMap>({}); |
|
|
|
useState<NetworkInterfaceInputMap>({}); |
|
|
|
const [networkInputs, setNetworkInputs] = useState<NetworkInput[]>( |
|
|
|
const [networkInputs, setNetworkInputs] = |
|
|
|
uninitRequiredNetworks, |
|
|
|
useState<NetworkInput[]>(initRequiredNetworks); |
|
|
|
); |
|
|
|
|
|
|
|
const [networkInterfaceHeld, setNetworkInterfaceHeld] = useState< |
|
|
|
const [networkInterfaceHeld, setNetworkInterfaceHeld] = useState< |
|
|
|
NetworkInterfaceOverviewMetadata | undefined |
|
|
|
NetworkInterfaceOverviewMetadata | undefined |
|
|
|
>(); |
|
|
|
>(); |
|
|
@ -657,6 +783,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) => |
|
|
@ -845,7 +978,8 @@ const NetworkInitForm = forwardRef< |
|
|
|
const inputTestPrefix = createInputTestPrefix(inputUUID); |
|
|
|
const inputTestPrefix = createInputTestPrefix(inputUUID); |
|
|
|
const inputTestIDIfaces = IT_IDS.networkInterfaces(inputTestPrefix); |
|
|
|
const inputTestIDIfaces = IT_IDS.networkInterfaces(inputTestPrefix); |
|
|
|
const inputTestIDIPAddress = IT_IDS.networkIPAddress(inputTestPrefix); |
|
|
|
const inputTestIDIPAddress = IT_IDS.networkIPAddress(inputTestPrefix); |
|
|
|
const inputTestIDSubnetMask = IT_IDS.networkSubnetMask(inputTestPrefix); |
|
|
|
const inputTestIDSubnetMask = |
|
|
|
|
|
|
|
IT_IDS.networkSubnetMask(inputTestPrefix); |
|
|
|
|
|
|
|
|
|
|
|
const setNetworkIfacesInputMessage = (message?: Message) => |
|
|
|
const setNetworkIfacesInputMessage = (message?: Message) => |
|
|
|
setMessage(inputTestIDIfaces, message); |
|
|
|
setMessage(inputTestIDIfaces, message); |
|
|
@ -1010,24 +1144,8 @@ const NetworkInitForm = forwardRef< |
|
|
|
setNetworkInterfaceHeld(undefined); |
|
|
|
setNetworkInterfaceHeld(undefined); |
|
|
|
}, []); |
|
|
|
}, []); |
|
|
|
const createNetwork = useCallback( |
|
|
|
const createNetwork = useCallback( |
|
|
|
({ |
|
|
|
(args: Partial<NetworkInput> = {}) => { |
|
|
|
inputUUID = uuidv4(), |
|
|
|
networkInputs.unshift(createNetworkInput(args)); |
|
|
|
interfaces = [...INITIAL_IFACES], |
|
|
|
|
|
|
|
ipAddress = '', |
|
|
|
|
|
|
|
name = 'Unknown Network', |
|
|
|
|
|
|
|
subnetMask = '', |
|
|
|
|
|
|
|
type = '', |
|
|
|
|
|
|
|
typeCount = 0, |
|
|
|
|
|
|
|
}: Partial<NetworkInput> = {}) => { |
|
|
|
|
|
|
|
networkInputs.unshift({ |
|
|
|
|
|
|
|
inputUUID, |
|
|
|
|
|
|
|
interfaces, |
|
|
|
|
|
|
|
ipAddress, |
|
|
|
|
|
|
|
name, |
|
|
|
|
|
|
|
subnetMask, |
|
|
|
|
|
|
|
type, |
|
|
|
|
|
|
|
typeCount, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toggleSubmitDisabled?.call(null, false); |
|
|
|
toggleSubmitDisabled?.call(null, false); |
|
|
|
setNetworkInputs([...networkInputs]); |
|
|
|
setNetworkInputs([...networkInputs]); |
|
|
@ -1036,7 +1154,10 @@ const NetworkInitForm = forwardRef< |
|
|
|
); |
|
|
|
); |
|
|
|
const removeNetwork = useCallback( |
|
|
|
const removeNetwork = useCallback( |
|
|
|
(networkIndex: number) => { |
|
|
|
(networkIndex: number) => { |
|
|
|
const [{ inputUUID, interfaces }] = networkInputs.splice(networkIndex, 1); |
|
|
|
const [{ inputUUID, interfaces }] = networkInputs.splice( |
|
|
|
|
|
|
|
networkIndex, |
|
|
|
|
|
|
|
1, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
interfaces.forEach((iface) => { |
|
|
|
interfaces.forEach((iface) => { |
|
|
|
if (iface === undefined) { |
|
|
|
if (iface === undefined) { |
|
|
@ -1056,7 +1177,11 @@ const NetworkInitForm = forwardRef< |
|
|
|
...previous, |
|
|
|
...previous, |
|
|
|
})); |
|
|
|
})); |
|
|
|
}, |
|
|
|
}, |
|
|
|
[networkInputs, networkInterfaceInputMap, testInputToToggleSubmitDisabled], |
|
|
|
[ |
|
|
|
|
|
|
|
networkInputs, |
|
|
|
|
|
|
|
networkInterfaceInputMap, |
|
|
|
|
|
|
|
testInputToToggleSubmitDisabled, |
|
|
|
|
|
|
|
], |
|
|
|
); |
|
|
|
); |
|
|
|
const getNetworkTypeCount: GetNetworkTypeCountFunction = useCallback( |
|
|
|
const getNetworkTypeCount: GetNetworkTypeCountFunction = useCallback( |
|
|
|
( |
|
|
|
( |
|
|
@ -1198,7 +1323,8 @@ const NetworkInitForm = forwardRef< |
|
|
|
const applied: string[] = []; |
|
|
|
const applied: string[] = []; |
|
|
|
const inputs = Object.values(pNetworks).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; |
|
|
|
|
|
|
|
|
|
|
|
const name = `${NETWORK_TYPES[type]} ${typeCount}`; |
|
|
|
const name = `${NETWORK_TYPES[type]} ${typeCount}`; |
|
|
@ -1299,7 +1425,8 @@ const NetworkInitForm = forwardRef< |
|
|
|
interfaces, |
|
|
|
interfaces, |
|
|
|
ipAddress: ipAddressInputRef?.current.getValue?.call(null) ?? '', |
|
|
|
ipAddress: ipAddressInputRef?.current.getValue?.call(null) ?? '', |
|
|
|
name, |
|
|
|
name, |
|
|
|
subnetMask: subnetMaskInputRef?.current.getValue?.call(null) ?? '', |
|
|
|
subnetMask: |
|
|
|
|
|
|
|
subnetMaskInputRef?.current.getValue?.call(null) ?? '', |
|
|
|
type, |
|
|
|
type, |
|
|
|
typeCount, |
|
|
|
typeCount, |
|
|
|
}), |
|
|
|
}), |
|
|
@ -1445,9 +1572,10 @@ const NetworkInitForm = forwardRef< |
|
|
|
<NetworkForm |
|
|
|
<NetworkForm |
|
|
|
key={`network-${inputUUID}`} |
|
|
|
key={`network-${inputUUID}`} |
|
|
|
{...{ |
|
|
|
{...{ |
|
|
|
|
|
|
|
allowMigrationNetwork, |
|
|
|
createDropMouseUpHandler, |
|
|
|
createDropMouseUpHandler, |
|
|
|
getNetworkTypeCount, |
|
|
|
getNetworkTypeCount, |
|
|
|
hostDetail, |
|
|
|
hostDetail: { hostType, sequence }, |
|
|
|
networkIndex, |
|
|
|
networkIndex, |
|
|
|
networkInput, |
|
|
|
networkInput, |
|
|
|
networkInterfaceCount: networkInterfaces.length, |
|
|
|
networkInterfaceCount: networkInterfaces.length, |
|
|
@ -1535,11 +1663,13 @@ const NetworkInitForm = forwardRef< |
|
|
|
</MUIBox> |
|
|
|
</MUIBox> |
|
|
|
</MUIBox> |
|
|
|
</MUIBox> |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
NetworkInitForm.defaultProps = { |
|
|
|
NetworkInitForm.defaultProps = { |
|
|
|
expectHostDetail: false, |
|
|
|
expectHostDetail: false, |
|
|
|
hostDetail: undefined, |
|
|
|
hostDetail: undefined, |
|
|
|
|
|
|
|
hostSequence: undefined, |
|
|
|
toggleSubmitDisabled: undefined, |
|
|
|
toggleSubmitDisabled: undefined, |
|
|
|
}; |
|
|
|
}; |
|
|
|
NetworkInitForm.displayName = 'NetworkInitForm'; |
|
|
|
NetworkInitForm.displayName = 'NetworkInitForm'; |
|
|
|