diff --git a/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx b/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx index 15fce11d..a365fb3c 100644 --- a/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx +++ b/striker-ui/components/StrikerConfig/ConfigPeersForm.tsx @@ -57,7 +57,7 @@ const ConfigPeersForm: FC = ({ refreshInterval, onError: (error) => { setAPIMessage({ - children: `Failed to get connection data; CAUSE: ${error}`, + children: `Failed to get connection data. Error: ${error}`, type: 'error', }); }, @@ -194,13 +194,7 @@ const ConfigPeersForm: FC = ({ .catch((error) => { const emsg = handleAPIError(error); - emsg.children = ( - <> - Failed to delete peer connection(s); - CAUSE: - {emsg.children} - - ); + emsg.children = `Failed to delete peer connection(s). ${emsg.children}`; setAPIMessage(emsg); }); diff --git a/striker-ui/components/StrikerConfig/SimpleOperationsPanel.tsx b/striker-ui/components/StrikerConfig/SimpleOperationsPanel.tsx index 2d6920ec..8f6f5b14 100644 --- a/striker-ui/components/StrikerConfig/SimpleOperationsPanel.tsx +++ b/striker-ui/components/StrikerConfig/SimpleOperationsPanel.tsx @@ -30,6 +30,20 @@ const SimpleOperationsPanel: FC = ({ ), [title], ); + const messageElement = useMemo( + () => + message && ( + + { + setMessage(undefined); + }} + /> + + ), + [message], + ); return ( @@ -69,13 +83,7 @@ const SimpleOperationsPanel: FC = ({ .catch((error) => { const emsg = handleAPIError(error); - emsg.children = ( - <> - Failed to {actionText} "Install - target"; CAUSE: - {emsg.children} - - ); + emsg.children = `Failed to ${actionText} "Install target". ${emsg.children}`; setMessage(emsg); }); @@ -102,12 +110,7 @@ const SimpleOperationsPanel: FC = ({ api.put('/command/update-system').catch((error) => { const emsg = handleAPIError(error); - emsg.children = ( - <> - Failed to initiate system update; CAUSE: - {emsg.children} - - ); + emsg.children = `Failed to initiate system update. ${emsg.children}`; setMessage(emsg); }); @@ -119,7 +122,6 @@ const SimpleOperationsPanel: FC = ({ Update system - Reconfigure striker @@ -135,12 +137,7 @@ const SimpleOperationsPanel: FC = ({ api.put('/command/reboot-host').catch((error) => { const emsg = handleAPIError(error); - emsg.children = ( - <> - Failed to initiate system reboot; CAUSE: - {emsg.children} - - ); + emsg.children = `Failed to initiate system reboot. ${emsg.children}`; setMessage(emsg); }); @@ -164,12 +161,7 @@ const SimpleOperationsPanel: FC = ({ api.put('/command/poweroff-host').catch((error) => { const emsg = handleAPIError(error); - emsg.children = ( - <> - Failed to initiate system shutdown; CAUSE: - {emsg.children} - - ); + emsg.children = `Failed to initiate system shutdown. ${emsg.children}`; setMessage(emsg); }); @@ -181,16 +173,7 @@ const SimpleOperationsPanel: FC = ({ Shutdown - - {message && ( - { - setMessage(undefined); - }} - /> - )} - + {messageElement} );