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(() => { 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; readHostDetailRef.current = false;
const { const {
@ -508,15 +519,17 @@ const GeneralInitForm = forwardRef<
organization: pOrganization, organization: pOrganization,
prefix: pPrefix, prefix: pPrefix,
sequence: pSequence, 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); domainNameInputRef.current.setValue?.call(null, pDomain);
hostNameInputRef.current.setValue?.call(null, pHostName); 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, () => ({ useImperativeHandle(ref, () => ({
get: () => ({ get: () => ({

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

Loading…
Cancel
Save