fix(striker-ui): export input id builders for an-network inputs

main
Tsu-ba-me 2 years ago
parent dfd07bb7f5
commit 8110a3daaf
  1. 13
      striker-ui/components/ManageManifest/AnNetworkConfigInputGroup.tsx
  2. 58
      striker-ui/components/ManageManifest/AnNetworkInputGroup.tsx
  3. 5
      striker-ui/types/ManageManifest.d.ts

@ -225,14 +225,6 @@ const AnNetworkConfigInputGroup = <
) => {
const cellId = `${INPUT_CELL_ID_PREFIX_ANC}-${networkId}`;
const idPrefix = `an-network-${networkId}`;
const inputIdPrefix = `${INPUT_ID_PREFIX_AN_NETWORK_CONFIG}-${networkId}`;
const inputGatewayId = `${inputIdPrefix}-gateway`;
const inputMinIpId = `${inputIdPrefix}-min-ip`;
const inputNetworkTypeId = `${inputIdPrefix}-network-type`;
const inputSubnetMaskId = `${inputIdPrefix}-subnet-mask`;
const isFirstNetwork = networkNumber === 1;
const isIfn = assertIfn(networkType);
const isMn = assertMn(networkType);
@ -242,11 +234,6 @@ const AnNetworkConfigInputGroup = <
children: (
<AnNetworkInputGroup
formUtils={formUtils}
idPrefix={idPrefix}
inputGatewayId={inputGatewayId}
inputMinIpId={inputMinIpId}
inputNetworkTypeId={inputNetworkTypeId}
inputSubnetMaskId={inputSubnetMaskId}
networkId={networkId}
networkNumber={networkNumber}
networkType={networkType}

@ -10,6 +10,22 @@ import { InnerPanel, InnerPanelBody, InnerPanelHeader } from '../Panels';
import SelectWithLabel from '../SelectWithLabel';
import { buildIPAddressTestBatch } from '../../lib/test_input';
const INPUT_ID_PREFIX_AN_NETWORK = 'an-network-input';
const INPUT_CELL_ID_PREFIX_AN = `${INPUT_ID_PREFIX_AN_NETWORK}-cell`;
const buildInputIdANGateway = (networkId: string): string =>
`${INPUT_ID_PREFIX_AN_NETWORK}-${networkId}-gateway`;
const buildInputIdANMinIp = (networkId: string): string =>
`${INPUT_ID_PREFIX_AN_NETWORK}-${networkId}-min-ip`;
const buildInputIdANNetworkType = (networkId: string): string =>
`${INPUT_ID_PREFIX_AN_NETWORK}-${networkId}-network-type`;
const buildInputIdANSubnetMask = (networkId: string): string =>
`${INPUT_ID_PREFIX_AN_NETWORK}-${networkId}-subnet-mask`;
const AnNetworkInputGroup = <M extends MapToInputTestID>({
formUtils: {
buildFinishInputTestBatchFunction,
@ -17,13 +33,8 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
msgSetters,
setMsgSetter,
},
idPrefix,
inputGatewayId,
inputGatewayLabel = 'Gateway',
inputMinIpId,
inputMinIpLabel = 'IP address',
inputNetworkTypeId,
inputSubnetMaskId,
inputSubnetMaskLabel = 'Subnet mask',
networkId,
networkNumber,
@ -46,13 +57,33 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
);
const inputCellGatewayId = useMemo(
() => `${idPrefix}-input-cell-gateway`,
[idPrefix],
() => `${INPUT_CELL_ID_PREFIX_AN}-${networkId}-gateway`,
[networkId],
);
const inputCellIpId = useMemo(
() => `${INPUT_CELL_ID_PREFIX_AN}-${networkId}-ip`,
[networkId],
);
const inputCellIpId = useMemo(() => `${idPrefix}-input-cell-ip`, [idPrefix]);
const inputCellSubnetMaskId = useMemo(
() => `${idPrefix}-input-cell-subnet-mask`,
[idPrefix],
() => `${INPUT_CELL_ID_PREFIX_AN}-${networkId}-subnet-mask`,
[networkId],
);
const inputGatewayId = useMemo(
() => buildInputIdANGateway(networkId),
[networkId],
);
const inputMinIpId = useMemo(
() => buildInputIdANMinIp(networkId),
[networkId],
);
const inputNetworkTypeId = useMemo(
() => buildInputIdANNetworkType(networkId),
[networkId],
);
const inputSubnetMaskId = useMemo(
() => buildInputIdANSubnetMask(networkId),
[networkId],
);
const inputCellGatewayDisplay = useMemo(
@ -217,4 +248,11 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
);
};
export {
buildInputIdANGateway,
buildInputIdANMinIp,
buildInputIdANNetworkType,
buildInputIdANSubnetMask,
};
export default AnNetworkInputGroup;

@ -87,7 +87,6 @@ type AnNetworkTypeChangeEventHandler = (
) => ReturnType<SelectChangeEventHandler>;
type AnNetworkInputGroupOptionalProps = {
inputGatewayId?: string;
inputGatewayLabel?: string;
inputMinIpLabel?: string;
inputSubnetMaskLabel?: string;
@ -106,10 +105,6 @@ type AnNetworkInputGroupOptionalProps = {
type AnNetworkInputGroupProps<M extends MapToInputTestID> =
AnNetworkInputGroupOptionalProps & {
formUtils: FormUtils<M>;
idPrefix: string;
inputMinIpId: string;
inputNetworkTypeId: string;
inputSubnetMaskId: string;
networkId: string;
networkNumber: number;
networkType: string;

Loading…
Cancel
Save