fix(striker-ui): export input id builders in host input group

main
Tsu-ba-me 2 years ago
parent 195348c6c7
commit dfd07bb7f5
  1. 38
      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_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 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 = <M extends MapToInputTestID>({ const AnHostInputGroup = <M extends MapToInputTestID>({
formUtils: { formUtils: {
buildFinishInputTestBatchFunction, buildFinishInputTestBatchFunction,
@ -61,11 +70,9 @@ const AnHostInputGroup = <M extends MapToInputTestID>({
() => () =>
fenceListEntries.reduce<GridLayout>( fenceListEntries.reduce<GridLayout>(
(previous, [fenceId, { fenceName, fencePort }]) => { (previous, [fenceId, { fenceName, fencePort }]) => {
const idPostfix = `${fenceId}-port`; const cellId = `${INPUT_CELL_ID_PREFIX_AH}-${fenceId}-port`;
const cellId = `${INPUT_CELL_ID_PREFIX_AN_HOST}-${idPostfix}`;
const inputId = `${INPUT_ID_PREFIX_AN_HOST}-${idPostfix}`; const inputId = buildInputIdAHFencePort(fenceId);
const inputLabel = `Port on ${fenceName}`; const inputLabel = `Port on ${fenceName}`;
setMsgSetter(inputId); setMsgSetter(inputId);
@ -113,11 +120,9 @@ const AnHostInputGroup = <M extends MapToInputTestID>({
() => () =>
networkListEntries.reduce<GridLayout>( networkListEntries.reduce<GridLayout>(
(previous, [networkId, { networkIp, networkNumber, networkType }]) => { (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 = buildInputIdAHNetworkIp(networkIp);
const inputId = `${INPUT_ID_PREFIX_AN_HOST}-${idPostfix}`;
const inputLabel = `${NETWORK_TYPES[networkType]} ${networkNumber}`; const inputLabel = `${NETWORK_TYPES[networkType]} ${networkNumber}`;
setMsgSetter(inputId); setMsgSetter(inputId);
@ -165,11 +170,10 @@ const AnHostInputGroup = <M extends MapToInputTestID>({
() => () =>
upsListEntries.reduce<GridLayout>( upsListEntries.reduce<GridLayout>(
(previous, [upsId, { isUsed, upsName }]) => { (previous, [upsId, { isUsed, upsName }]) => {
const idPostfix = `${upsId}-power-host`; const cellId = `${INPUT_CELL_ID_PREFIX_AH}-${upsId}-power-host`;
const cellId = `${INPUT_CELL_ID_PREFIX_AN_HOST}-${idPostfix}`;
const inputId = `${INPUT_ID_PREFIX_AN_HOST}-${idPostfix}`; const inputId = buildInputIdAHUpsPowerHost(upsId);
const inputLabel = `Uses ${upsName}`;
previous[cellId] = { previous[cellId] = {
children: ( children: (
@ -178,7 +182,7 @@ const AnHostInputGroup = <M extends MapToInputTestID>({
<SwitchWithLabel <SwitchWithLabel
checked={isUsed} checked={isUsed}
id={inputId} id={inputId}
label={`Uses ${upsName}`} label={inputLabel}
flexBoxProps={{ height: '3.5em' }} flexBoxProps={{ height: '3.5em' }}
/> />
} }
@ -238,6 +242,10 @@ const AnHostInputGroup = <M extends MapToInputTestID>({
); );
}; };
export { INPUT_ID_PREFIX_AN_HOST }; export {
buildInputIdAHFencePort,
buildInputIdAHNetworkIp,
buildInputIdAHUpsPowerHost,
};
export default AnHostInputGroup; export default AnHostInputGroup;

Loading…
Cancel
Save