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 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 isFirstNetwork = networkNumber === 1;
const isIfn = assertIfn(networkType); const isIfn = assertIfn(networkType);
const isMn = assertMn(networkType); const isMn = assertMn(networkType);
@ -242,11 +234,6 @@ const AnNetworkConfigInputGroup = <
children: ( children: (
<AnNetworkInputGroup <AnNetworkInputGroup
formUtils={formUtils} formUtils={formUtils}
idPrefix={idPrefix}
inputGatewayId={inputGatewayId}
inputMinIpId={inputMinIpId}
inputNetworkTypeId={inputNetworkTypeId}
inputSubnetMaskId={inputSubnetMaskId}
networkId={networkId} networkId={networkId}
networkNumber={networkNumber} networkNumber={networkNumber}
networkType={networkType} networkType={networkType}

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

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

Loading…
Cancel
Save