import { useCallback, useMemo } from 'react'
import PropTypes from 'prop-types'
import { Trans, useTranslation } from 'react-i18next'
import { Button } from 'react-bootstrap'
import PreviewLogEntryHeader from './preview-log-entry-header'
import Icon from '../../../shared/components/icon'
import getMeta from '../../../utils/meta'
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
import { useStopOnFirstError } from '../../../shared/hooks/use-stop-on-first-error'
import BetaBadge from '../../../shared/components/beta-badge'
function PreviewLogsPaneMaxEntries({ totalEntries, entriesShown, hasErrors }) {
const { t } = useTranslation()
const showStopOnFirstError = getMeta('ol-showStopOnFirstError')
const { startCompile, stoppedOnFirstError, setAnimateCompileDropdownArrow } =
useCompileContext()
const { enableStopOnFirstError } = useStopOnFirstError({
eventSource: 'too-many-logs',
})
const title = t('log_entry_maximum_entries_title', {
total: totalEntries,
displayed: entriesShown,
})
const handleEnableStopOnFirstErrorClick = useCallback(() => {
enableStopOnFirstError()
startCompile({ stopOnFirstError: true })
setAnimateCompileDropdownArrow(true)
}, [enableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
const betaBadgeTooltip = useMemo(
() => ({
id: 'stop-on-first-error-tooltip',
placement: 'bottom',
className: 'tooltip-wide',
text: (
<>
We are beta testing the “Stop on first error” compilation mode.
Click to give feedback
>
),
}),
[]
)
return (
{t('log_entry_maximum_entries_see_full_logs')}
> ) : (