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'
|
2024-10-23 03:32:40 -04:00
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
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'
|
2024-10-23 03:32:40 -04:00
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
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>
|
2024-10-23 03:32:40 -04:00
|
|
|
<BootstrapVersionSwitcher
|
|
|
|
bs3={<Icon type="lightbulb-o" />}
|
|
|
|
bs5={
|
|
|
|
<MaterialIcon type="lightbulb" className="align-middle" />
|
|
|
|
}
|
|
|
|
/>
|
2022-06-09 10:47:53 -04:00
|
|
|
|
|
|
|
<strong>{t('tip')}: </strong>
|
2022-10-03 11:22:13 -04:00
|
|
|
<Trans
|
|
|
|
i18nKey="log_entry_maximum_entries_enable_stop_on_first_error"
|
2023-07-20 06:11:33 -04:00
|
|
|
components={[
|
2024-10-23 03:32:40 -04:00
|
|
|
<OLButton
|
|
|
|
variant="info"
|
|
|
|
size="sm"
|
2023-07-20 06:11:33 -04:00
|
|
|
key="enable-stop-on-first-error"
|
2024-10-23 03:32:40 -04:00
|
|
|
bs3Props={{ bsSize: 'xsmall' }}
|
2023-07-20 06:11:33 -04:00
|
|
|
onClick={handleEnableStopOnFirstErrorClick}
|
|
|
|
/>,
|
|
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
|
|
<a
|
|
|
|
key="learn-more"
|
|
|
|
href="https://www.overleaf.com/learn/latex/Questions/Tips_and_Tricks_for_Troubleshooting_LaTeX"
|
|
|
|
/>,
|
|
|
|
]}
|
2022-10-03 11:22:13 -04:00
|
|
|
/>{' '}
|
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>
|
2024-10-23 03:32:40 -04:00
|
|
|
<BootstrapVersionSwitcher
|
|
|
|
bs3={<Icon type="lightbulb-o" />}
|
|
|
|
bs5={<MaterialIcon type="lightbulb" className="align-middle" />}
|
|
|
|
/>
|
2022-06-09 10:47:53 -04:00
|
|
|
|
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
|