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

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. import StopOnFirstErrorBadge from '../../../shared/components/stop-on-first-error-badge'
  8. export default function StopOnFirstErrorPrompt() {
  9. const { t } = useTranslation()
  10. const { startCompile, setAnimateCompileDropdownArrow } = useCompileContext()
  11. const { disableStopOnFirstError } = useStopOnFirstError({
  12. eventSource: 'logs-pane',
  13. })
  14. const handleDisableButtonClick = useCallback(() => {
  15. disableStopOnFirstError()
  16. startCompile({ stopOnFirstError: false })
  17. setAnimateCompileDropdownArrow(true)
  18. }, [disableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
  19. return (
  20. <PdfLogEntry
  21. headerTitle={t('stop_on_first_error_enabled_title')}
  22. headerIcon={<StopOnFirstErrorBadge placement="right" />}
  23. formattedContent={
  24. <>
  25. <Trans
  26. i18nKey="stop_on_first_error_enabled_description"
  27. // eslint-disable-next-line react/jsx-key
  28. components={[<strong />]}
  29. />{' '}
  30. <Button bsSize="xs" bsStyle="info" onClick={handleDisableButtonClick}>
  31. {t('disable_stop_on_first_error')}
  32. </Button>
  33. </>
  34. }
  35. level="info"
  36. />
  37. )
  38. }