mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 03:23:10 +00:00
Consolidate errors and warnings compilation result indicator.
GitOrigin-RevId: c17b782884c9860022cef93e038136c6853bdc6b
This commit is contained in:
parent
e1c2291fef
commit
6e99c7b722
1 changed files with 15 additions and 25 deletions
|
@ -36,34 +36,27 @@ function PreviewLogsToggleButton({
|
|||
}
|
||||
|
||||
function CompilationResultIndicator({ nErrors, nWarnings }) {
|
||||
if (nErrors) {
|
||||
return <ErrorsCompilationResultIndicator nErrors={nErrors} />
|
||||
} else if (nWarnings) {
|
||||
return <WarningsCompilationResultIndicator nWarnings={nWarnings} />
|
||||
if (nErrors || nWarnings) {
|
||||
return (
|
||||
<LogsCompilationResultIndicator
|
||||
logType={nErrors ? 'errors' : 'warnings'}
|
||||
nLogs={nErrors || nWarnings}
|
||||
/>
|
||||
)
|
||||
} else {
|
||||
return <ViewLogsButton />
|
||||
}
|
||||
}
|
||||
|
||||
function ErrorsCompilationResultIndicator({ nErrors }) {
|
||||
function LogsCompilationResultIndicator({ logType, nLogs }) {
|
||||
const { t } = useTranslation()
|
||||
const label =
|
||||
logType === 'errors' ? t('your_project_has_errors') : t('view_warnings')
|
||||
return (
|
||||
<>
|
||||
<Icon type="file-text-o" />
|
||||
<span className="btn-toggle-logs-label">
|
||||
{`${t('your_project_has_errors')} (${nErrors > 9 ? '9+' : nErrors})`}
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function WarningsCompilationResultIndicator({ nWarnings }) {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<>
|
||||
<Icon type="file-text-o" />
|
||||
<span className="btn-toggle-logs-label">
|
||||
{`${t('view_warnings')} (${nWarnings > 9 ? '9+' : nWarnings})`}
|
||||
<span className="btn-toggle-logs-label" aria-label={label}>
|
||||
{`${label} (${nLogs > 9 ? '9+' : nLogs})`}
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue