From fb8e92ffb47f7e4c312a19a339ecff64372c1e06 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Mon, 13 Mar 2023 16:10:18 -0400 Subject: [PATCH] fix(striker-ui): consolidate network types --- striker-ui/components/NetworkInitForm.tsx | 24 ++++++++--------------- striker-ui/lib/consts/NETWORK_TYPES.ts | 2 ++ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/striker-ui/components/NetworkInitForm.tsx b/striker-ui/components/NetworkInitForm.tsx index 507454e1..db4a9e8d 100644 --- a/striker-ui/components/NetworkInitForm.tsx +++ b/striker-ui/components/NetworkInitForm.tsx @@ -34,6 +34,7 @@ import { v4 as uuidv4 } from 'uuid'; import API_BASE_URL from '../lib/consts/API_BASE_URL'; import { BLUE, GREY } from '../lib/consts/DEFAULT_THEME'; +import NETWORK_TYPES from '../lib/consts/NETWORK_TYPES'; import { REP_IPV4, REP_IPV4_CSV } from '../lib/consts/REG_EXP_PATTERNS'; import BriefNetworkInterface from './BriefNetworkInterface'; @@ -106,17 +107,6 @@ const CLASSES = { }; const INITIAL_IFACES = [undefined, undefined]; -const NETWORK_TYPES: Record = { - bcn: 'Back-Channel Network', - ifn: 'Internet-Facing Network', - sn: 'Storage Network', -}; - -const NODE_NETWORK_TYPES: Record = { - ...NETWORK_TYPES, - mn: 'Migration Network', -}; - const STRIKER_REQUIRED_NETWORKS: NetworkInput[] = [ { inputUUID: '30dd2ac5-8024-4a7e-83a1-6a3df7218972', @@ -349,11 +339,13 @@ const NetworkForm: FC<{ !isNode && networkInterfaceCount <= 2 ? [1] : NETWORK_INTERFACE_TEMPLATE, [isNode, networkInterfaceCount], ); - const netTypeList = useMemo( - () => - isNode && networkInterfaceCount >= 8 ? NODE_NETWORK_TYPES : NETWORK_TYPES, - [isNode, networkInterfaceCount], - ); + const netTypeList = useMemo(() => { + const { bcn, ifn, mn, sn } = NETWORK_TYPES; + + return isNode && networkInterfaceCount >= 8 + ? { bcn, ifn, mn, sn } + : { bcn, ifn, sn }; + }, [isNode, networkInterfaceCount]); useEffect(() => { const { ipAddressInputRef: ipRef, subnetMaskInputRef: maskRef } = diff --git a/striker-ui/lib/consts/NETWORK_TYPES.ts b/striker-ui/lib/consts/NETWORK_TYPES.ts index 6720774e..a1954860 100644 --- a/striker-ui/lib/consts/NETWORK_TYPES.ts +++ b/striker-ui/lib/consts/NETWORK_TYPES.ts @@ -1,6 +1,8 @@ const NETWORK_TYPES: Record = { bcn: 'Back-Channel Network', ifn: 'Internet-Facing Network', + mn: 'Migration Network', + sn: 'Storage Network', }; export default NETWORK_TYPES;