fix(striker-ui): align request method, body in striker init form with API

main
Tsu-ba-me 2 years ago
parent c417de89e7
commit f7918d7d6c
  1. 16
      striker-ui/components/NetworkInitForm.tsx
  2. 4
      striker-ui/components/StrikerInitForm.tsx

@ -78,7 +78,7 @@ type NetworkInterfaceInputMap = Record<
>; >;
type NetworkInitFormValues = { type NetworkInitFormValues = {
domainNameServerCSV?: string; dns?: string;
gateway?: string; gateway?: string;
gatewayInterface?: string; gatewayInterface?: string;
networks: Omit<NetworkInput, 'ipAddressInputRef' | 'subnetMaskInputRef'>[]; networks: Omit<NetworkInput, 'ipAddressInputRef' | 'subnetMaskInputRef'>[];
@ -148,7 +148,7 @@ const NODE_REQUIRED_NETWORKS: NetworkInput[] = [
const MAX_INTERFACES_PER_NETWORK = 2; const MAX_INTERFACES_PER_NETWORK = 2;
const IT_IDS = { const IT_IDS = {
dnsCSV: 'domainNameServerCSV', dnsCSV: 'dns',
gateway: 'gateway', gateway: 'gateway',
networkInterfaces: (prefix: string) => `${prefix}Interface`, networkInterfaces: (prefix: string) => `${prefix}Interface`,
networkIPAddress: (prefix: string) => `${prefix}IPAddress`, networkIPAddress: (prefix: string) => `${prefix}IPAddress`,
@ -645,7 +645,7 @@ const NetworkInitForm = forwardRef<
messageGroupRef.current.setMessageRe?.call(null, re, message), messageGroupRef.current.setMessageRe?.call(null, re, message),
[], [],
); );
const setDomainNameServerCSVInputMessage = useCallback( const setDnsInputMessage = useCallback(
(message?: Message) => setMessage(IT_IDS.dnsCSV, message), (message?: Message) => setMessage(IT_IDS.dnsCSV, message),
[setMessage], [setMessage],
); );
@ -743,13 +743,13 @@ const NetworkInitForm = forwardRef<
defaults: { defaults: {
getValue: () => dnsCSVInputRef.current.getValue?.call(null), getValue: () => dnsCSVInputRef.current.getValue?.call(null),
onSuccess: () => { onSuccess: () => {
setDomainNameServerCSVInputMessage(); setDnsInputMessage();
}, },
}, },
tests: [ tests: [
{ {
onFailure: () => { onFailure: () => {
setDomainNameServerCSVInputMessage({ setDnsInputMessage({
children: children:
'Domain name servers should be a comma-separated list of IPv4 addresses without trailing comma(s).', 'Domain name servers should be a comma-separated list of IPv4 addresses without trailing comma(s).',
}); });
@ -958,7 +958,7 @@ const NetworkInitForm = forwardRef<
return tests; return tests;
}, [ }, [
networkInputs, networkInputs,
setDomainNameServerCSVInputMessage, setDnsInputMessage,
setGatewayInputMessage, setGatewayInputMessage,
setMessage, setMessage,
subnetContains, subnetContains,
@ -1166,7 +1166,7 @@ const NetworkInitForm = forwardRef<
ref, ref,
() => ({ () => ({
get: () => ({ get: () => ({
domainNameServerCSV: dnsCSVInputRef.current.getValue?.call(null), dns: dnsCSVInputRef.current.getValue?.call(null),
gateway: gatewayInputRef.current.getValue?.call(null), gateway: gatewayInputRef.current.getValue?.call(null),
gatewayInterface, gatewayInterface,
networks: networkInputs.map( networks: networkInputs.map(
@ -1400,7 +1400,7 @@ const NetworkInitForm = forwardRef<
testInputToToggleSubmitDisabled({ testInputToToggleSubmitDisabled({
inputs: { [IT_IDS.dnsCSV]: { value } }, inputs: { [IT_IDS.dnsCSV]: { value } },
}); });
setDomainNameServerCSVInputMessage(); setDnsInputMessage();
}} }}
label="Domain name server(s)" label="Domain name server(s)"
value={xDns} value={xDns}

@ -206,7 +206,7 @@ const StrikerInitForm: FC = () => {
<BodyText>Domain name server(s)</BodyText> <BodyText>Domain name server(s)</BodyText>
</Grid> </Grid>
<Grid item xs={1}> <Grid item xs={1}>
<MonoText>{requestBody?.domainNameServerCSV}</MonoText> <MonoText>{requestBody?.dns}</MonoText>
</Grid> </Grid>
</Grid> </Grid>
} }
@ -220,7 +220,7 @@ const StrikerInitForm: FC = () => {
setIsOpenConfirm(false); setIsOpenConfirm(false);
api api
.post('/init', requestBody) .put('/init', requestBody)
.then(() => { .then(() => {
setIsSubmittingForm(false); setIsSubmittingForm(false);
}) })

Loading…
Cancel
Save