2022-06-21 08:15:45 -04:00
|
|
|
import { useCallback } from 'react'
|
2021-10-06 04:33:18 -04:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { Trans, useTranslation } from 'react-i18next'
|
2022-06-09 10:47:53 -04:00
|
|
|
import { Button } from 'react-bootstrap'
|
2021-10-06 04:33:18 -04:00
|
|
|
import PreviewLogEntryHeader from './preview-log-entry-header'
|
|
|
|
import Icon from '../../../shared/components/icon'
|
2022-06-09 10:47:53 -04:00
|
|
|
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
|
2022-06-13 08:08:38 -04:00
|
|
|
import { useStopOnFirstError } from '../../../shared/hooks/use-stop-on-first-error'
|
2021-10-06 04:33:18 -04:00
|
|
|
|
2021-11-25 05:24:25 -05:00
|
|
|
function PreviewLogsPaneMaxEntries({ totalEntries, entriesShown, hasErrors }) {
|
2021-10-06 04:33:18 -04:00
|
|
|
const { t } = useTranslation()
|
2022-06-13 08:29:35 -04:00
|
|
|
const { startCompile, stoppedOnFirstError, setAnimateCompileDropdownArrow } =
|
|
|
|
useCompileContext()
|
2022-06-13 08:08:38 -04:00
|
|
|
const { enableStopOnFirstError } = useStopOnFirstError({
|
|
|
|
eventSource: 'too-many-logs',
|
|
|
|
})
|
2021-10-06 04:33:18 -04:00
|
|
|
|
|
|
|
const title = t('log_entry_maximum_entries_title', {
|
|
|
|
total: totalEntries,
|
|
|
|
displayed: entriesShown,
|
|
|
|
})
|
|
|
|
|
2022-06-13 08:08:38 -04:00
|
|
|
const handleEnableStopOnFirstErrorClick = useCallback(() => {
|
|
|
|
enableStopOnFirstError()
|
|
|
|
startCompile({ stopOnFirstError: true })
|
2022-06-13 08:29:35 -04:00
|
|
|
setAnimateCompileDropdownArrow(true)
|
|
|
|
}, [enableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
|
2022-06-13 08:08:38 -04:00
|
|
|
|
2021-10-06 04:33:18 -04:00
|
|
|
return (
|
|
|
|
<div className="log-entry" aria-label={t('log_entry_maximum_entries')}>
|
|
|
|
<PreviewLogEntryHeader level="raw" headerTitle={title} />
|
|
|
|
<div className="log-entry-content">
|
2022-06-14 10:28:03 -04:00
|
|
|
<div className="log-entry-formatted-content">
|
2022-10-03 11:22:13 -04:00
|
|
|
{hasErrors && !stoppedOnFirstError ? (
|
|
|
|
<>
|
2022-06-09 10:47:53 -04:00
|
|
|
<p>
|
|
|
|
<Icon type="lightbulb-o" />
|
|
|
|
|
|
|
|
<strong>{t('tip')}: </strong>
|
2022-10-03 11:22:13 -04:00
|
|
|
<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" />
|
|
|
|
),
|
|
|
|
}}
|
|
|
|
/>{' '}
|
2022-06-09 10:47:53 -04:00
|
|
|
</p>
|
2022-10-03 11:22:13 -04:00
|
|
|
<p>{t('log_entry_maximum_entries_see_full_logs')}</p>
|
|
|
|
</>
|
2022-06-09 10:47:53 -04:00
|
|
|
) : (
|
2022-10-03 11:22:13 -04:00
|
|
|
<p>
|
2022-06-09 10:47:53 -04:00
|
|
|
<Icon type="lightbulb-o" />
|
|
|
|
|
2022-10-03 11:22:13 -04:00
|
|
|
<strong>{t('tip')}: </strong>
|
|
|
|
{t('log_entry_maximum_entries_see_full_logs')}
|
|
|
|
</p>
|
2022-06-14 10:28:03 -04:00
|
|
|
)}
|
|
|
|
</div>
|
2021-10-06 04:33:18 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
PreviewLogsPaneMaxEntries.propTypes = {
|
|
|
|
totalEntries: PropTypes.number,
|
|
|
|
entriesShown: PropTypes.number,
|
2021-11-25 05:24:25 -05:00
|
|
|
hasErrors: PropTypes.bool,
|
2021-10-06 04:33:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default PreviewLogsPaneMaxEntries
|