2022-06-14 10:28:03 -04:00
|
|
|
import { useCallback, useMemo } from 'react'
|
2022-06-07 07:55:48 -04:00
|
|
|
import { useTranslation, Trans } from 'react-i18next'
|
|
|
|
import { Button } from 'react-bootstrap'
|
|
|
|
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-14 10:28:03 -04:00
|
|
|
import BetaBadge from '../../../shared/components/beta-badge'
|
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-14 10:28:03 -04:00
|
|
|
const betaBadgeTooltip = useMemo(
|
|
|
|
() => ({
|
|
|
|
id: 'stop-on-first-error-tooltip',
|
|
|
|
placement: 'right',
|
|
|
|
className: 'tooltip-wide',
|
|
|
|
text: (
|
|
|
|
<>
|
|
|
|
We are beta testing the “Stop on first error” compilation mode.
|
|
|
|
<br />
|
|
|
|
Click to give feedback
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
}),
|
|
|
|
[]
|
|
|
|
)
|
|
|
|
|
2022-06-07 07:55:48 -04:00
|
|
|
return (
|
|
|
|
<PdfLogEntry
|
|
|
|
headerTitle={t('stop_on_first_error_enabled_title')}
|
2022-06-14 10:28:03 -04:00
|
|
|
headerIcon={
|
|
|
|
<BetaBadge
|
|
|
|
tooltip={betaBadgeTooltip}
|
|
|
|
url="https://forms.gle/7M8821o5RDZrFKoF6"
|
|
|
|
/>
|
|
|
|
}
|
2022-06-07 07:55:48 -04:00
|
|
|
formattedContent={
|
|
|
|
<>
|
|
|
|
<Trans
|
|
|
|
i18nKey="stop_on_first_error_enabled_description"
|
|
|
|
// eslint-disable-next-line react/jsx-key
|
|
|
|
components={[<strong />]}
|
|
|
|
/>{' '}
|
2022-06-13 08:08:38 -04:00
|
|
|
<Button bsSize="xs" bsStyle="info" onClick={handleDisableButtonClick}>
|
2022-06-07 07:55:48 -04:00
|
|
|
{t('disable_stop_on_first_error')}
|
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
level="info"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|