From dfd07bb7f591860e4936e5ba88a4466fc67e66af Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Tue, 28 Mar 2023 23:14:55 -0400 Subject: [PATCH] fix(striker-ui): export input id builders in host input group --- .../ManageManifest/AnHostInputGroup.tsx | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/striker-ui/components/ManageManifest/AnHostInputGroup.tsx b/striker-ui/components/ManageManifest/AnHostInputGroup.tsx index ade7425a..b4be0baa 100644 --- a/striker-ui/components/ManageManifest/AnHostInputGroup.tsx +++ b/striker-ui/components/ManageManifest/AnHostInputGroup.tsx @@ -16,10 +16,19 @@ import { BodyText } from '../Text'; const INPUT_ID_PREFIX_AN_HOST = 'an-host-input'; -const INPUT_CELL_ID_PREFIX_AN_HOST = `${INPUT_ID_PREFIX_AN_HOST}-cell`; +const INPUT_CELL_ID_PREFIX_AH = `${INPUT_ID_PREFIX_AN_HOST}-cell`; const GRID_SPACING = '1em'; +const buildInputIdAHFencePort = (fenceId: string): string => + `${INPUT_ID_PREFIX_AN_HOST}-${fenceId}-port`; + +const buildInputIdAHNetworkIp = (networkId: string): string => + `${INPUT_ID_PREFIX_AN_HOST}-${networkId}-ip`; + +const buildInputIdAHUpsPowerHost = (upsId: string): string => + `${INPUT_ID_PREFIX_AN_HOST}-${upsId}-power-host`; + const AnHostInputGroup = ({ formUtils: { buildFinishInputTestBatchFunction, @@ -61,11 +70,9 @@ const AnHostInputGroup = ({ () => fenceListEntries.reduce( (previous, [fenceId, { fenceName, fencePort }]) => { - const idPostfix = `${fenceId}-port`; - - const cellId = `${INPUT_CELL_ID_PREFIX_AN_HOST}-${idPostfix}`; + const cellId = `${INPUT_CELL_ID_PREFIX_AH}-${fenceId}-port`; - const inputId = `${INPUT_ID_PREFIX_AN_HOST}-${idPostfix}`; + const inputId = buildInputIdAHFencePort(fenceId); const inputLabel = `Port on ${fenceName}`; setMsgSetter(inputId); @@ -113,11 +120,9 @@ const AnHostInputGroup = ({ () => networkListEntries.reduce( (previous, [networkId, { networkIp, networkNumber, networkType }]) => { - const idPostfix = `${networkId}-ip`; + const cellId = `${INPUT_CELL_ID_PREFIX_AH}-${networkId}-ip`; - const cellId = `${INPUT_CELL_ID_PREFIX_AN_HOST}-${idPostfix}`; - - const inputId = `${INPUT_ID_PREFIX_AN_HOST}-${idPostfix}`; + const inputId = buildInputIdAHNetworkIp(networkIp); const inputLabel = `${NETWORK_TYPES[networkType]} ${networkNumber}`; setMsgSetter(inputId); @@ -165,11 +170,10 @@ const AnHostInputGroup = ({ () => upsListEntries.reduce( (previous, [upsId, { isUsed, upsName }]) => { - const idPostfix = `${upsId}-power-host`; - - const cellId = `${INPUT_CELL_ID_PREFIX_AN_HOST}-${idPostfix}`; + const cellId = `${INPUT_CELL_ID_PREFIX_AH}-${upsId}-power-host`; - const inputId = `${INPUT_ID_PREFIX_AN_HOST}-${idPostfix}`; + const inputId = buildInputIdAHUpsPowerHost(upsId); + const inputLabel = `Uses ${upsName}`; previous[cellId] = { children: ( @@ -178,7 +182,7 @@ const AnHostInputGroup = ({ } @@ -238,6 +242,10 @@ const AnHostInputGroup = ({ ); }; -export { INPUT_ID_PREFIX_AN_HOST }; +export { + buildInputIdAHFencePort, + buildInputIdAHNetworkIp, + buildInputIdAHUpsPowerHost, +}; export default AnHostInputGroup;