fix(striker-ui): revise error messages in StrikerConfig

main
Tsu-ba-me 2 years ago
parent e038b809d9
commit 91212adf98
  1. 10
      striker-ui/components/StrikerConfig/ConfigPeersForm.tsx
  2. 55
      striker-ui/components/StrikerConfig/SimpleOperationsPanel.tsx

@ -57,7 +57,7 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
refreshInterval, refreshInterval,
onError: (error) => { onError: (error) => {
setAPIMessage({ setAPIMessage({
children: `Failed to get connection data; CAUSE: ${error}`, children: `Failed to get connection data. Error: ${error}`,
type: 'error', type: 'error',
}); });
}, },
@ -194,13 +194,7 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
.catch((error) => { .catch((error) => {
const emsg = handleAPIError(error); const emsg = handleAPIError(error);
emsg.children = ( emsg.children = `Failed to delete peer connection(s). ${emsg.children}`;
<>
Failed to delete peer connection(s)&semi;
CAUSE&colon;
{emsg.children}
</>
);
setAPIMessage(emsg); setAPIMessage(emsg);
}); });

@ -30,6 +30,20 @@ const SimpleOperationsPanel: FC<SimpleOperationsPanelProps> = ({
), ),
[title], [title],
); );
const messageElement = useMemo(
() =>
message && (
<Grid item sm={2} xs={1}>
<MessageBox
{...message}
onClose={() => {
setMessage(undefined);
}}
/>
</Grid>
),
[message],
);
return ( return (
<Panel> <Panel>
@ -69,13 +83,7 @@ const SimpleOperationsPanel: FC<SimpleOperationsPanelProps> = ({
.catch((error) => { .catch((error) => {
const emsg = handleAPIError(error); const emsg = handleAPIError(error);
emsg.children = ( emsg.children = `Failed to ${actionText} "Install target". ${emsg.children}`;
<>
Failed to {actionText} &quot;Install
target&quot;&semi; CAUSE&colon;
{emsg.children}
</>
);
setMessage(emsg); setMessage(emsg);
}); });
@ -102,12 +110,7 @@ const SimpleOperationsPanel: FC<SimpleOperationsPanelProps> = ({
api.put('/command/update-system').catch((error) => { api.put('/command/update-system').catch((error) => {
const emsg = handleAPIError(error); const emsg = handleAPIError(error);
emsg.children = ( emsg.children = `Failed to initiate system update. ${emsg.children}`;
<>
Failed to initiate system update&semi; CAUSE&colon;
{emsg.children}
</>
);
setMessage(emsg); setMessage(emsg);
}); });
@ -119,7 +122,6 @@ const SimpleOperationsPanel: FC<SimpleOperationsPanelProps> = ({
Update system Update system
</StretchedButton> </StretchedButton>
</Grid> </Grid>
<Grid item sm={2} xs={1}> <Grid item sm={2} xs={1}>
<StretchedButton>Reconfigure striker</StretchedButton> <StretchedButton>Reconfigure striker</StretchedButton>
</Grid> </Grid>
@ -135,12 +137,7 @@ const SimpleOperationsPanel: FC<SimpleOperationsPanelProps> = ({
api.put('/command/reboot-host').catch((error) => { api.put('/command/reboot-host').catch((error) => {
const emsg = handleAPIError(error); const emsg = handleAPIError(error);
emsg.children = ( emsg.children = `Failed to initiate system reboot. ${emsg.children}`;
<>
Failed to initiate system reboot&semi; CAUSE&colon;
{emsg.children}
</>
);
setMessage(emsg); setMessage(emsg);
}); });
@ -164,12 +161,7 @@ const SimpleOperationsPanel: FC<SimpleOperationsPanelProps> = ({
api.put('/command/poweroff-host').catch((error) => { api.put('/command/poweroff-host').catch((error) => {
const emsg = handleAPIError(error); const emsg = handleAPIError(error);
emsg.children = ( emsg.children = `Failed to initiate system shutdown. ${emsg.children}`;
<>
Failed to initiate system shutdown&semi; CAUSE&colon;
{emsg.children}
</>
);
setMessage(emsg); setMessage(emsg);
}); });
@ -181,16 +173,7 @@ const SimpleOperationsPanel: FC<SimpleOperationsPanelProps> = ({
Shutdown Shutdown
</StretchedButton> </StretchedButton>
</Grid> </Grid>
<Grid item sm={2} xs={1}> {messageElement}
{message && (
<MessageBox
{...message}
onClose={() => {
setMessage(undefined);
}}
/>
)}
</Grid>
</Grid> </Grid>
</Panel> </Panel>
); );

Loading…
Cancel
Save