diff --git a/services/web/frontend/js/features/preview/components/preview-logs-toggle-button.js b/services/web/frontend/js/features/preview/components/preview-logs-toggle-button.js index f815dbbc02..df0292c540 100644 --- a/services/web/frontend/js/features/preview/components/preview-logs-toggle-button.js +++ b/services/web/frontend/js/features/preview/components/preview-logs-toggle-button.js @@ -36,34 +36,27 @@ function PreviewLogsToggleButton({ } function CompilationResultIndicator({ nErrors, nWarnings }) { - if (nErrors) { - return - } else if (nWarnings) { - return + if (nErrors || nWarnings) { + return ( + + ) } else { return } } -function ErrorsCompilationResultIndicator({ nErrors }) { +function LogsCompilationResultIndicator({ logType, nLogs }) { const { t } = useTranslation() + const label = + logType === 'errors' ? t('your_project_has_errors') : t('view_warnings') return ( <> - - {`${t('your_project_has_errors')} (${nErrors > 9 ? '9+' : nErrors})`} - - - ) -} - -function WarningsCompilationResultIndicator({ nWarnings }) { - const { t } = useTranslation() - return ( - <> - - - {`${t('view_warnings')} (${nWarnings > 9 ? '9+' : nWarnings})`} + + {`${label} (${nLogs > 9 ? '9+' : nLogs})`} ) @@ -99,12 +92,9 @@ PreviewLogsToggleButton.propTypes = { showLogs: PropTypes.bool.isRequired } -ErrorsCompilationResultIndicator.propTypes = { - nErrors: PropTypes.number.isRequired -} - -WarningsCompilationResultIndicator.propTypes = { - nWarnings: PropTypes.number.isRequired +LogsCompilationResultIndicator.propTypes = { + logType: PropTypes.string.isRequired, + nLogs: PropTypes.number.isRequired } export default PreviewLogsToggleButton