Skip to content

Commit

Permalink
fix: prevent showing 'null' status in ErrorBanner
Browse files Browse the repository at this point in the history
  • Loading branch information
csm-thu committed Jul 11, 2022
1 parent 3491d22 commit a316535
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/misc/ErrorBanner/ErrorBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ export const ErrorBanner = (props) => {
navigator.clipboard.writeText(message).then(() => setCopyButtonText(labels.toggledButtonText));
};
const errorMessageMaxLength = 200;
const errorStatusText = error.status ? error.status + ' ' : '';
return (
<Slide direction="down" in={error != null} unmountOnExit>
<Paper square elevation={0} className={classes.errorContainer} data-cy="error-banner">
<div>
<Typography className={classes.errorTitle}>{error.status + ' ' + error.title}</Typography>
<Typography className={classes.errorTitle}>{errorStatusText + error.title}</Typography>
<Typography className={classes.errorText}>
{error.detail.length < errorMessageMaxLength ? error.detail : labels.tooLongErrorMessage}
</Typography>
Expand Down Expand Up @@ -52,7 +53,12 @@ export const ErrorBanner = (props) => {
};

ErrorBanner.propTypes = {
error: PropTypes.object.isRequired,
error: PropTypes.shape({
comment: PropTypes.string,
detail: PropTypes.string,
status: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
title: PropTypes.string.isRequired,
}).isRequired,
clearErrors: PropTypes.func,
labels: PropTypes.shape({
tooLongErrorMessage: PropTypes.string,
Expand Down

0 comments on commit a316535

Please sign in to comment.