stop-on-first-error-prompt.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { useCallback } from 'react'
  2. import { useTranslation, Trans } from 'react-i18next'
  3. import { Button } from 'react-bootstrap'
  4. import PdfLogEntry from './pdf-log-entry'
  5. import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
  6. import { useStopOnFirstError } from '../../../shared/hooks/use-stop-on-first-error'
  7. export default function StopOnFirstErrorPrompt() {
  8. const { t } = useTranslation()
  9. const { startCompile, setAnimateCompileDropdownArrow } = useCompileContext()
  10. const { disableStopOnFirstError } = useStopOnFirstError({
  11. eventSource: 'logs-pane',
  12. })
  13. const handleDisableButtonClick = useCallback(() => {
  14. disableStopOnFirstError()
  15. startCompile({ stopOnFirstError: false })
  16. setAnimateCompileDropdownArrow(true)
  17. }, [disableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
  18. return (
  19. <PdfLogEntry
  20. headerTitle={t('stop_on_first_error_enabled_title')}
  21. formattedContent={
  22. <>
  23. <Trans
  24. i18nKey="stop_on_first_error_enabled_description"
  25. // eslint-disable-next-line react/jsx-key
  26. components={[<strong />]}
  27. />{' '}
  28. <Button bsSize="xs" bsStyle="info" onClick={handleDisableButtonClick}>
  29. {t('disable_stop_on_first_error')}
  30. </Button>
  31. </>
  32. }
  33. level="info"
  34. />
  35. )
  36. }