2022-06-13 08:08:38 -04:00
|
|
|
import { useCallback } from 'react'
|
2022-06-07 07:55:48 -04:00
|
|
|
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'
|
2022-06-13 08:08:38 -04:00
|
|
|
import { useStopOnFirstError } from '../../../shared/hooks/use-stop-on-first-error'
|
2022-06-07 07:55:48 -04:00
|
|
|
|
|
|
|
export default function StopOnFirstErrorPrompt() {
|
|
|
|
const { t } = useTranslation()
|
2022-06-13 08:29:35 -04:00
|
|
|
const { startCompile, setAnimateCompileDropdownArrow } = useCompileContext()
|
2022-06-13 08:08:38 -04:00
|
|
|
const { disableStopOnFirstError } = useStopOnFirstError({
|
|
|
|
eventSource: 'logs-pane',
|
|
|
|
})
|
|
|
|
|
|
|
|
const handleDisableButtonClick = useCallback(() => {
|
|
|
|
disableStopOnFirstError()
|
|
|
|
startCompile({ stopOnFirstError: false })
|
2022-06-13 08:29:35 -04:00
|
|
|
setAnimateCompileDropdownArrow(true)
|
|
|
|
}, [disableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
|
2022-06-13 08:08:38 -04:00
|
|
|
|
2022-06-07 07:55:48 -04:00
|
|
|
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 />]}
|
|
|
|
/>{' '}
|
2022-06-13 08:08:38 -04:00
|
|
|
<Button bsSize="xs" bsStyle="info" onClick={handleDisableButtonClick}>
|
2022-06-07 07:55:48 -04:00
|
|
|
{t('disable_stop_on_first_error')}
|
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
level="info"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|