overleaf/services/web/frontend/js/features/pdf-preview/components/stop-on-first-error-prompt.js
Eric Mc Sween a2532ef968 Merge pull request #8354 from overleaf/em-halt-on-error-animation
Animation when setting "Stop on first error"

GitOrigin-RevId: 9639e2c815d1eaf57f3392131f9a484a6a1a0a9e
2022-06-14 08:02:32 +00:00

39 lines
1.4 KiB
JavaScript

import { useCallback } from 'react'
import { useTranslation, Trans } from 'react-i18next'
import { Button } from 'react-bootstrap'
import PdfLogEntry from './pdf-log-entry'
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
import { useStopOnFirstError } from '../../../shared/hooks/use-stop-on-first-error'
export default function StopOnFirstErrorPrompt() {
const { t } = useTranslation()
const { startCompile, setAnimateCompileDropdownArrow } = useCompileContext()
const { disableStopOnFirstError } = useStopOnFirstError({
eventSource: 'logs-pane',
})
const handleDisableButtonClick = useCallback(() => {
disableStopOnFirstError()
startCompile({ stopOnFirstError: false })
setAnimateCompileDropdownArrow(true)
}, [disableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
return (
<PdfLogEntry
headerTitle={t('stop_on_first_error_enabled_title')}
formattedContent={
<>
<Trans
i18nKey="stop_on_first_error_enabled_description"
// eslint-disable-next-line react/jsx-key
components={[<strong />]}
/>{' '}
<Button bsSize="xs" bsStyle="info" onClick={handleDisableButtonClick}>
{t('disable_stop_on_first_error')}
</Button>
</>
}
level="info"
/>
)
}