mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
b902bd9265
GitOrigin-RevId: 96b8bb527fa3d60a5fb84eee2b8f4fabc1726875
67 lines
1.5 KiB
JavaScript
67 lines
1.5 KiB
JavaScript
import { useTranslation } from 'react-i18next'
|
|
import Icon from '../../../shared/components/icon'
|
|
import PropTypes from 'prop-types'
|
|
import { memo } from 'react'
|
|
|
|
export function PdfLogsButtonContent({
|
|
showLogs,
|
|
logEntries,
|
|
codeCheckFailed,
|
|
}) {
|
|
const { t } = useTranslation()
|
|
|
|
if (showLogs) {
|
|
return (
|
|
<>
|
|
<Icon type="file-pdf-o" />
|
|
<span className="toolbar-text toolbar-hide-small">{t('view_pdf')}</span>
|
|
</>
|
|
)
|
|
}
|
|
|
|
if (codeCheckFailed) {
|
|
return (
|
|
<>
|
|
<Icon type="exclamation-triangle" />
|
|
<span className="toolbar-text toolbar-hide-small">
|
|
{t('code_check_failed')}
|
|
</span>
|
|
</>
|
|
)
|
|
}
|
|
|
|
const count = logEntries?.errors?.length || logEntries?.warnings?.length
|
|
|
|
if (!count) {
|
|
return (
|
|
<>
|
|
<Icon type="file-text-o" />
|
|
<span className="toolbar-text toolbar-hide-small">
|
|
{t('view_logs')}
|
|
</span>
|
|
</>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Icon type="file-text-o" />
|
|
<span className="btn-toggle-logs-label toolbar-text toolbar-hide-small">
|
|
{logEntries.errors?.length
|
|
? t('your_project_has_an_error', { count })
|
|
: t('view_warning', { count })}
|
|
<span className="sr-hidden">
|
|
{count > 1 && ` (${count > 99 ? '99+' : count})`}
|
|
</span>
|
|
</span>
|
|
</>
|
|
)
|
|
}
|
|
|
|
PdfLogsButtonContent.propTypes = {
|
|
codeCheckFailed: PropTypes.bool,
|
|
showLogs: PropTypes.bool,
|
|
logEntries: PropTypes.object,
|
|
}
|
|
|
|
export default memo(PdfLogsButtonContent)
|