refactor(striker-ui): rename id variables in manifest network input group

main
Tsu-ba-me 2 years ago
parent 47e822421d
commit 4db9d8b321
  1. 56
      striker-ui/components/ManageManifest/AnNetworkInputGroup.tsx

@ -106,15 +106,15 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
[networkNumber, networkType], [networkNumber, networkType],
); );
const inputCellGatewayId = useMemo( const inputCellIdGateway = useMemo(
() => `${INPUT_CELL_ID_PREFIX_AN}-${networkId}-gateway`, () => `${INPUT_CELL_ID_PREFIX_AN}-${networkId}-gateway`,
[networkId], [networkId],
); );
const inputCellIpId = useMemo( const inputCellIdIp = useMemo(
() => `${INPUT_CELL_ID_PREFIX_AN}-${networkId}-ip`, () => `${INPUT_CELL_ID_PREFIX_AN}-${networkId}-ip`,
[networkId], [networkId],
); );
const inputCellSubnetMaskId = useMemo( const inputCellIdSubnetMask = useMemo(
() => `${INPUT_CELL_ID_PREFIX_AN}-${networkId}-subnet-mask`, () => `${INPUT_CELL_ID_PREFIX_AN}-${networkId}-subnet-mask`,
[networkId], [networkId],
); );
@ -124,19 +124,19 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
[networkId], [networkId],
); );
const inputGatewayId = useMemo( const inputIdGateway = useMemo(
() => buildInputIdANGateway(networkId), () => buildInputIdANGateway(networkId),
[networkId], [networkId],
); );
const inputMinIpId = useMemo( const inputIdMinIp = useMemo(
() => buildInputIdANMinIp(networkId), () => buildInputIdANMinIp(networkId),
[networkId], [networkId],
); );
const inputNetworkTypeId = useMemo( const inputIdNetworkType = useMemo(
() => buildInputIdANNetworkType(networkId), () => buildInputIdANNetworkType(networkId),
[networkId], [networkId],
); );
const inputSubnetMaskId = useMemo( const inputIdSubnetMask = useMemo(
() => buildInputIdANSubnetMask(networkId), () => buildInputIdANSubnetMask(networkId),
[networkId], [networkId],
); );
@ -169,8 +169,8 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
const inputGatewayElement = useMemo<ReactNode>(() => { const inputGatewayElement = useMemo<ReactNode>(() => {
let result: ReactNode; let result: ReactNode;
if (isShowGateway && inputGatewayId) { if (isShowGateway && inputIdGateway) {
setMsgSetter(inputGatewayId); setMsgSetter(inputIdGateway);
result = ( result = (
<InputWithRef <InputWithRef
@ -180,7 +180,7 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
'data-handler': 'gateway', 'data-handler': 'gateway',
'data-network-id': networkId, 'data-network-id': networkId,
}} }}
id={inputGatewayId} id={inputIdGateway}
label={inputGatewayLabel} label={inputGatewayLabel}
value={previousGateway} value={previousGateway}
/> />
@ -188,18 +188,18 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
inputTestBatch={buildIPAddressTestBatch( inputTestBatch={buildIPAddressTestBatch(
`${networkName} ${inputGatewayLabel}`, `${networkName} ${inputGatewayLabel}`,
() => { () => {
msgSetters[inputGatewayId](); msgSetters[inputIdGateway]();
}, },
{ {
onFinishBatch: buildFinishInputTestBatchFunction(inputGatewayId), onFinishBatch: buildFinishInputTestBatchFunction(inputIdGateway),
}, },
(message) => { (message) => {
msgSetters[inputGatewayId]({ msgSetters[inputIdGateway]({
children: message, children: message,
}); });
}, },
)} )}
onFirstRender={buildInputFirstRenderFunction(inputGatewayId)} onFirstRender={buildInputFirstRenderFunction(inputIdGateway)}
required={isShowGateway} required={isShowGateway}
/> />
); );
@ -208,7 +208,7 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
return result; return result;
}, [ }, [
isShowGateway, isShowGateway,
inputGatewayId, inputIdGateway,
setMsgSetter, setMsgSetter,
networkId, networkId,
inputGatewayLabel, inputGatewayLabel,
@ -220,9 +220,9 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
]); ]);
useEffect(() => { useEffect(() => {
setMsgSetter(inputMinIpId); setMsgSetter(inputIdMinIp);
setMsgSetter(inputSubnetMaskId); setMsgSetter(inputIdSubnetMask);
}, [inputMinIpId, inputSubnetMaskId, setMsgSetter]); }, [inputIdMinIp, inputIdSubnetMask, setMsgSetter]);
return ( return (
<InnerPanel mv={0}> <InnerPanel mv={0}>
@ -230,7 +230,7 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
<InputWithRef <InputWithRef
input={ input={
<SelectWithLabel <SelectWithLabel
id={inputNetworkTypeId} id={inputIdNetworkType}
isReadOnly={isReadonlyNetworkName} isReadOnly={isReadonlyNetworkName}
onChange={(...args) => { onChange={(...args) => {
onNetworkTypeChange?.call( onNetworkTypeChange?.call(
@ -261,7 +261,7 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
/> />
<Grid <Grid
layout={{ layout={{
[inputCellIpId]: { [inputCellIdIp]: {
children: ( children: (
<InputWithRef <InputWithRef
input={ input={
@ -270,7 +270,7 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
'data-handler': 'minip', 'data-handler': 'minip',
'data-network-id': networkId, 'data-network-id': networkId,
}} }}
id={inputMinIpId} id={inputIdMinIp}
label={inputMinIpLabel} label={inputMinIpLabel}
value={previousIpAddress} value={previousIpAddress}
/> />
@ -278,24 +278,24 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
inputTestBatch={buildIPAddressTestBatch( inputTestBatch={buildIPAddressTestBatch(
`${networkName} ${inputMinIpLabel}`, `${networkName} ${inputMinIpLabel}`,
() => { () => {
msgSetters[inputMinIpId](); msgSetters[inputIdMinIp]();
}, },
{ {
onFinishBatch: onFinishBatch:
buildFinishInputTestBatchFunction(inputMinIpId), buildFinishInputTestBatchFunction(inputIdMinIp),
}, },
(message) => { (message) => {
msgSetters[inputMinIpId]({ msgSetters[inputIdMinIp]({
children: message, children: message,
}); });
}, },
)} )}
onFirstRender={buildInputFirstRenderFunction(inputMinIpId)} onFirstRender={buildInputFirstRenderFunction(inputIdMinIp)}
required required
/> />
), ),
}, },
[inputCellSubnetMaskId]: { [inputCellIdSubnetMask]: {
children: ( children: (
<InputWithRef <InputWithRef
input={ input={
@ -304,7 +304,7 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
'data-handler': 'subnetmask', 'data-handler': 'subnetmask',
'data-network-id': networkId, 'data-network-id': networkId,
}} }}
id={inputSubnetMaskId} id={inputIdSubnetMask}
label={inputSubnetMaskLabel} label={inputSubnetMaskLabel}
value={previousSubnetMask} value={previousSubnetMask}
/> />
@ -313,7 +313,7 @@ const AnNetworkInputGroup = <M extends MapToInputTestID>({
/> />
), ),
}, },
[inputCellGatewayId]: { [inputCellIdGateway]: {
children: inputGatewayElement, children: inputGatewayElement,
display: inputCellGatewayDisplay, display: inputCellGatewayDisplay,
}, },

Loading…
Cancel
Save