2022-06-21 08:15:45 -04:00
|
|
|
import { useCallback } from 'react'
|
2022-06-07 07:55:48 -04:00
|
|
|
import { useTranslation, Trans } from 'react-i18next'
|
2024-10-23 03:32:40 -04:00
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
2022-06-07 07:55:48 -04:00
|
|
|
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 />]}
|
|
|
|
/>{' '}
|
2024-10-23 03:32:40 -04:00
|
|
|
<OLButton
|
|
|
|
variant="info"
|
|
|
|
size="sm"
|
|
|
|
onClick={handleDisableButtonClick}
|
|
|
|
bs3Props={{ bsSize: 'xsmall' }}
|
|
|
|
>
|
2022-06-07 07:55:48 -04:00
|
|
|
{t('disable_stop_on_first_error')}
|
2024-10-23 03:32:40 -04:00
|
|
|
</OLButton>
|
2022-06-07 07:55:48 -04:00
|
|
|
</>
|
|
|
|
}
|
|
|
|
level="info"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|