overleaf/services/web/frontend/js/features/pdf-preview/components/stop-on-first-error-prompt.jsx

45 lines
1.5 KiB
React
Raw Normal View History

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