fix(striker-ui): don't show network link 2 when not enough NICs

main
Tsu-ba-me 2 years ago
parent 73d04b7078
commit b756b2ac74
  1. 13
      striker-ui/components/NetworkInitForm.tsx

@ -272,6 +272,7 @@ const NetworkForm: FC<{
interfaceIndex: number, interfaceIndex: number,
) => MUIBoxProps['onMouseUp']; ) => MUIBoxProps['onMouseUp'];
getNetworkTypeCount: GetNetworkTypeCountFunction; getNetworkTypeCount: GetNetworkTypeCountFunction;
hostDetail?: APIHostDetail;
networkIndex: number; networkIndex: number;
networkInput: NetworkInput; networkInput: NetworkInput;
networkInterfaceInputMap: NetworkInterfaceInputMap; networkInterfaceInputMap: NetworkInterfaceInputMap;
@ -286,6 +287,7 @@ const NetworkForm: FC<{
}> = ({ }> = ({
createDropMouseUpHandler, createDropMouseUpHandler,
getNetworkTypeCount, getNetworkTypeCount,
hostDetail: { hostType } = {},
networkIndex, networkIndex,
networkInput, networkInput,
networkInterfaceInputMap, networkInterfaceInputMap,
@ -334,6 +336,14 @@ const NetworkForm: FC<{
[inputTestPrefix], [inputTestPrefix],
); );
const netIfTemplate = useMemo(
() =>
hostType !== 'node' && Object.keys(networkInterfaceInputMap).length <= 2
? [1]
: NETWORK_INTERFACE_TEMPLATE,
[hostType, networkInterfaceInputMap],
);
useEffect(() => { useEffect(() => {
const { ipAddressInputRef: ipRef, subnetMaskInputRef: maskRef } = const { ipAddressInputRef: ipRef, subnetMaskInputRef: maskRef } =
networkInput; networkInput;
@ -417,7 +427,7 @@ const NetworkForm: FC<{
}, },
}} }}
> >
{NETWORK_INTERFACE_TEMPLATE.map((linkNumber) => { {netIfTemplate.map((linkNumber) => {
const linkName = `Link ${linkNumber}`; const linkName = `Link ${linkNumber}`;
const networkInterfaceIndex = linkNumber - 1; const networkInterfaceIndex = linkNumber - 1;
const networkInterface = interfaces[networkInterfaceIndex]; const networkInterface = interfaces[networkInterfaceIndex];
@ -555,6 +565,7 @@ const NetworkForm: FC<{
NetworkForm.defaultProps = { NetworkForm.defaultProps = {
createDropMouseUpHandler: undefined, createDropMouseUpHandler: undefined,
hostDetail: undefined,
}; };
const NetworkInitForm = forwardRef< const NetworkInitForm = forwardRef<

Loading…
Cancel
Save