fix(striker-ui): correct message group behaviour in test access of init host

main
Tsu-ba-me 9 months ago
parent 231a1a0537
commit 9ed047d3a7
  1. 63
      striker-ui/components/ManageHost/TestAccessForm.tsx

@ -31,6 +31,7 @@ const TestAccessForm: FC<TestAccessFormProps> = (props) => {
password: '', password: '',
}, },
onSubmit: (values, { setSubmitting }) => { onSubmit: (values, { setSubmitting }) => {
setApiMessage();
setLoadingInquiry(true); setLoadingInquiry(true);
setResponse(undefined); setResponse(undefined);
@ -42,6 +43,22 @@ const TestAccessForm: FC<TestAccessFormProps> = (props) => {
password, password,
}) })
.then(({ data }) => { .then(({ data }) => {
const { isConnected } = data;
if (!isConnected) {
setApiMessage({
children: (
<>
Failed to connect. Please make sure the credentials are
correct, and the host is reachable from this striker.
</>
),
type: 'warning',
});
return;
}
setResponse({ setResponse({
...data, ...data,
hostIpAddress: ip, hostIpAddress: ip,
@ -115,33 +132,25 @@ const TestAccessForm: FC<TestAccessFormProps> = (props) => {
} }
/> />
</Grid> </Grid>
{loadingInquiry ? ( <Grid item width="100%">
<Grid item width="100%"> <MessageGroup count={1} messages={formikErrors} ref={messageGroupRef} />
<Spinner /> </Grid>
</Grid> <Grid item width="100%">
) : ( {loadingInquiry ? (
<> <Spinner mt={0} />
<Grid item width="100%"> ) : (
<MessageGroup <ActionGroup
count={1} actions={[
messages={formikErrors} {
ref={messageGroupRef} background: 'blue',
/> children: 'Test access',
</Grid> disabled: disabledSubmit,
<Grid item width="100%"> type: 'submit',
<ActionGroup },
actions={[ ]}
{ />
background: 'blue', )}
children: 'Test access', </Grid>
disabled: disabledSubmit,
type: 'submit',
},
]}
/>
</Grid>
</>
)}
</Grid> </Grid>
); );
}; };

Loading…
Cancel
Save