mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 06:40:20 -05:00
7837af0afd
Replace stop-on-first-error beta badge with info badge GitOrigin-RevId: d0f8d1c6e960646bd257aeaf5efc21b23615242b
101 lines
3.7 KiB
JavaScript
101 lines
3.7 KiB
JavaScript
import { useCallback } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { Trans, useTranslation } from 'react-i18next'
|
|
import { Button } from 'react-bootstrap'
|
|
import PreviewLogEntryHeader from './preview-log-entry-header'
|
|
import Icon from '../../../shared/components/icon'
|
|
import getMeta from '../../../utils/meta'
|
|
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
|
|
import { useStopOnFirstError } from '../../../shared/hooks/use-stop-on-first-error'
|
|
import StopOnFirstErrorBadge from '../../../shared/components/stop-on-first-error-badge'
|
|
|
|
function PreviewLogsPaneMaxEntries({ totalEntries, entriesShown, hasErrors }) {
|
|
const { t } = useTranslation()
|
|
const showStopOnFirstError = getMeta('ol-showStopOnFirstError')
|
|
const { startCompile, stoppedOnFirstError, setAnimateCompileDropdownArrow } =
|
|
useCompileContext()
|
|
const { enableStopOnFirstError } = useStopOnFirstError({
|
|
eventSource: 'too-many-logs',
|
|
})
|
|
|
|
const title = t('log_entry_maximum_entries_title', {
|
|
total: totalEntries,
|
|
displayed: entriesShown,
|
|
})
|
|
|
|
const handleEnableStopOnFirstErrorClick = useCallback(() => {
|
|
enableStopOnFirstError()
|
|
startCompile({ stopOnFirstError: true })
|
|
setAnimateCompileDropdownArrow(true)
|
|
}, [enableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
|
|
|
|
return (
|
|
<div className="log-entry" aria-label={t('log_entry_maximum_entries')}>
|
|
<PreviewLogEntryHeader level="raw" headerTitle={title} />
|
|
<div className="log-entry-content">
|
|
<div className="log-entry-formatted-content">
|
|
{showStopOnFirstError ? (
|
|
hasErrors && !stoppedOnFirstError ? (
|
|
<>
|
|
<p>
|
|
<Icon type="lightbulb-o" />
|
|
|
|
<strong>{t('tip')}: </strong>
|
|
<Trans
|
|
i18nKey="log_entry_maximum_entries_enable_stop_on_first_error"
|
|
components={{
|
|
button: (
|
|
<Button
|
|
bsSize="xs"
|
|
bsStyle="info"
|
|
onClick={handleEnableStopOnFirstErrorClick}
|
|
/>
|
|
),
|
|
'learn-more-link': (
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
<a href="https://www.overleaf.com/learn/latex/Questions/Tips_and_Tricks_for_Troubleshooting_LaTeX" />
|
|
),
|
|
}}
|
|
/>{' '}
|
|
<StopOnFirstErrorBadge placement="bottom" />
|
|
</p>
|
|
<p>{t('log_entry_maximum_entries_see_full_logs')}</p>
|
|
</>
|
|
) : (
|
|
<p>
|
|
<Icon type="lightbulb-o" />
|
|
|
|
<strong>{t('tip')}: </strong>
|
|
{t('log_entry_maximum_entries_see_full_logs')}
|
|
</p>
|
|
)
|
|
) : (
|
|
<>
|
|
<Icon type="lightbulb-o" />
|
|
|
|
{hasErrors ? (
|
|
<Trans
|
|
i18nKey="log_entry_maximum_entries_message"
|
|
components={[<b />, <p />]} // eslint-disable-line react/jsx-key
|
|
/>
|
|
) : (
|
|
<Trans
|
|
i18nKey="log_entry_maximum_entries_message_no_errors"
|
|
components={[<b />]} // eslint-disable-line react/jsx-key
|
|
/>
|
|
)}
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
PreviewLogsPaneMaxEntries.propTypes = {
|
|
totalEntries: PropTypes.number,
|
|
entriesShown: PropTypes.number,
|
|
hasErrors: PropTypes.bool,
|
|
}
|
|
|
|
export default PreviewLogsPaneMaxEntries
|