overleaf-cep/services/web/frontend/js/features/pdf-preview/components/stop-on-first-error-prompt.tsx
Tim Down 057f4b4bb5 Merge pull request #25113 from overleaf/td-remove-button-info-variant
Change labs/new editor buttons to be based on secondary buttons

GitOrigin-RevId: f02565e60be33ff75c217c1ea1d0f24b3b619ed4
2025-05-05 08:05:40 +00:00

43 lines
1.4 KiB
TypeScript

import { useCallback } from 'react'
import { useTranslation, Trans } from 'react-i18next'
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 />]}
/>{' '}
<OLButton
variant="primary"
size="sm"
onClick={handleDisableButtonClick}
>
{t('disable_stop_on_first_error')}
</OLButton>
</>
}
level="info"
/>
)
}