From 3491d22f1fd91e4273d022fe1d52198f37f737b2 Mon Sep 17 00:00:00 2001 From: Tristan Huet Date: Thu, 16 Jun 2022 14:27:32 +0200 Subject: [PATCH] feat: make dismiss errors button optional in ErrorBanner component If the function prop clearErrors is not provided, the button to clear errors is not displayed --- src/misc/ErrorBanner/ErrorBanner.js | 31 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/misc/ErrorBanner/ErrorBanner.js b/src/misc/ErrorBanner/ErrorBanner.js index f750a7e5..b3a33fb7 100644 --- a/src/misc/ErrorBanner/ErrorBanner.js +++ b/src/misc/ErrorBanner/ErrorBanner.js @@ -33,16 +33,18 @@ export const ErrorBanner = (props) => { {copyButtonText} )} - + {clearErrors && ( + + )} @@ -51,19 +53,20 @@ export const ErrorBanner = (props) => { ErrorBanner.propTypes = { error: PropTypes.object.isRequired, - clearErrors: PropTypes.func.isRequired, + clearErrors: PropTypes.func, labels: PropTypes.shape({ tooLongErrorMessage: PropTypes.string, - dismissButtonText: PropTypes.string.isRequired, + dismissButtonText: PropTypes.string, secondButtonText: PropTypes.string.isRequired, toggledButtonText: PropTypes.string, }), }; ErrorBanner.defaultProps = { labels: { + dismissButtonText: 'Dismiss', tooLongErrorMessage: - // eslint-disable-next-line max-len - 'Detailed error message is too long to be displayed. To read it, please use the COPY button and paste it in your favorite text editor.', + 'Detailed error message is too long to be displayed. To read it, please use the COPY button and paste it in ' + + 'your favorite text editor.', toggledButtonText: 'Copied', }, };