fix(striker-ui): test after repop in general, network config forms

main
Tsu-ba-me 1 year ago
parent ffe7f1884e
commit 76ab36e1f9
  1. 25
      striker-ui/components/GeneralInitForm.tsx
  2. 43
      striker-ui/components/NetworkInitForm.tsx

@ -499,7 +499,18 @@ const GeneralInitForm = forwardRef<
);
useEffect(() => {
if (expectHostDetail && hostDetail && readHostDetailRef.current) {
if (
[
expectHostDetail,
hostDetail,
readHostDetailRef.current,
domainNameInputRef.current,
hostNameInputRef.current,
hostNumberInputRef.current,
organizationNameInputRef.current,
organizationPrefixInputRef.current,
].every((condition) => Boolean(condition))
) {
readHostDetailRef.current = false;
const {
@ -508,15 +519,17 @@ const GeneralInitForm = forwardRef<
organization: pOrganization,
prefix: pPrefix,
sequence: pSequence,
} = hostDetail;
} = hostDetail as APIHostDetail;
organizationNameInputRef.current.setValue?.call(null, pOrganization);
organizationPrefixInputRef.current.setValue?.call(null, pPrefix);
hostNumberInputRef.current.setValue?.call(null, pSequence);
domainNameInputRef.current.setValue?.call(null, pDomain);
hostNameInputRef.current.setValue?.call(null, pHostName);
hostNumberInputRef.current.setValue?.call(null, pSequence);
organizationNameInputRef.current.setValue?.call(null, pOrganization);
organizationPrefixInputRef.current.setValue?.call(null, pPrefix);
testInputToToggleSubmitDisabled();
}
}, [expectHostDetail, hostDetail]);
}, [expectHostDetail, hostDetail, testInputToToggleSubmitDisabled]);
useImperativeHandle(ref, () => ({
get: () => ({

@ -582,14 +582,8 @@ const NetworkInitForm = forwardRef<
toggleSubmitDisabled?: (testResult: boolean) => void;
}
>(({ expectHostDetail = false, hostDetail, toggleSubmitDisabled }, ref) => {
const {
dns: previousDns,
gateway: previousGateway,
gatewayInterface: previousGatewayInterface,
hostType,
hostUUID = 'local',
networks: previousNetworks,
}: APIHostDetail = hostDetail ?? ({} as APIHostDetail);
const { hostType, hostUUID = 'local' }: APIHostDetail =
hostDetail ?? ({} as APIHostDetail);
const uninitRequiredNetworks: NetworkInput[] = useMemo(
() =>
@ -1180,15 +1174,29 @@ const NetworkInitForm = forwardRef<
useEffect(() => {
if (
Object.keys(networkInterfaceInputMap).length > 0 &&
expectHostDetail &&
hostDetail &&
readHostDetailRef.current
[
Object.keys(networkInterfaceInputMap).length > 0,
expectHostDetail,
hostDetail,
readHostDetailRef.current,
dnsCSVInputRef.current,
gatewayInputRef.current,
].every((condition) => Boolean(condition))
) {
readHostDetailRef.current = false;
const {
dns: pDns,
gateway: pGateway,
gatewayInterface: pGatewayInterface,
networks: pNetworks,
} = hostDetail as APIHostDetail;
dnsCSVInputRef.current.setValue?.call(null, pDns);
gatewayInputRef.current.setValue?.call(null, pGateway);
const applied: string[] = [];
const inputs = Object.values(previousNetworks).reduce<NetworkInput[]>(
const inputs = Object.values(pNetworks).reduce<NetworkInput[]>(
(previous, { ip, link1Uuid, link2Uuid = '', subnetMask, type }) => {
const typeCount = getNetworkTypeCount(type, { inputs: previous }) + 1;
const isRequired = requiredNetworks[type] === typeCount;
@ -1216,7 +1224,7 @@ const NetworkInitForm = forwardRef<
[],
);
setGatewayInterface(previousGatewayInterface);
setGatewayInterface(pGatewayInterface);
setNetworkInterfaceInputMap((previous) => {
const result = { ...previous };
@ -1231,6 +1239,8 @@ const NetworkInitForm = forwardRef<
});
setNetworkInputs(inputs);
testInputToToggleSubmitDisabled();
}
}, [
createNetwork,
@ -1239,9 +1249,8 @@ const NetworkInitForm = forwardRef<
hostDetail,
networkInputs,
networkInterfaceInputMap,
previousGatewayInterface,
previousNetworks,
requiredNetworks,
testInputToToggleSubmitDisabled,
]);
useEffect(() => {
@ -1492,7 +1501,6 @@ const NetworkInitForm = forwardRef<
setGatewayInputMessage();
}}
label="Gateway"
value={previousGateway}
/>
}
ref={gatewayInputRef}
@ -1514,7 +1522,6 @@ const NetworkInitForm = forwardRef<
setDnsInputMessage();
}}
label="Domain name server(s)"
value={previousDns}
/>
}
ref={dnsCSVInputRef}

Loading…
Cancel
Save