mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05: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 }) {
|
function CompilationResultIndicator({ nErrors, nWarnings }) {
|
||||||
if (nErrors) {
|
if (nErrors || nWarnings) {
|
||||||
return <ErrorsCompilationResultIndicator nErrors={nErrors} />
|
return (
|
||||||
} else if (nWarnings) {
|
<LogsCompilationResultIndicator
|
||||||
return <WarningsCompilationResultIndicator nWarnings={nWarnings} />
|
logType={nErrors ? 'errors' : 'warnings'}
|
||||||
|
nLogs={nErrors || nWarnings}
|
||||||
|
/>
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
return <ViewLogsButton />
|
return <ViewLogsButton />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ErrorsCompilationResultIndicator({ nErrors }) {
|
function LogsCompilationResultIndicator({ logType, nLogs }) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const label =
|
||||||
|
logType === 'errors' ? t('your_project_has_errors') : t('view_warnings')
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Icon type="file-text-o" />
|
<Icon type="file-text-o" />
|
||||||
<span className="btn-toggle-logs-label">
|
<span className="btn-toggle-logs-label" aria-label={label}>
|
||||||
{`${t('your_project_has_errors')} (${nErrors > 9 ? '9+' : nErrors})`}
|
{`${label} (${nLogs > 9 ? '9+' : nLogs})`}
|
||||||
</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>
|
</span>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -99,12 +92,9 @@ PreviewLogsToggleButton.propTypes = {
|
||||||
showLogs: PropTypes.bool.isRequired
|
showLogs: PropTypes.bool.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorsCompilationResultIndicator.propTypes = {
|
LogsCompilationResultIndicator.propTypes = {
|
||||||
nErrors: PropTypes.number.isRequired
|
logType: PropTypes.string.isRequired,
|
||||||
}
|
nLogs: PropTypes.number.isRequired
|
||||||
|
|
||||||
WarningsCompilationResultIndicator.propTypes = {
|
|
||||||
nWarnings: PropTypes.number.isRequired
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PreviewLogsToggleButton
|
export default PreviewLogsToggleButton
|
||||||
|
|
Loading…
Reference in a new issue