import { useTranslation } from 'react-i18next' import { memo, useState } from 'react' import classnames from 'classnames' import PdfValidationIssue from './pdf-validation-issue' import StopOnFirstErrorPrompt from './stop-on-first-error-prompt' import TimeoutUpgradePromptNew from './timeout-upgrade-prompt-new' import PdfPreviewError from './pdf-preview-error' import PdfClearCacheButton from './pdf-clear-cache-button' import PdfDownloadFilesButton from './pdf-download-files-button' import PdfLogsEntries from './pdf-logs-entries' import withErrorBoundary from '../../../infrastructure/error-boundary' import PdfPreviewErrorBoundaryFallback from './pdf-preview-error-boundary-fallback' import PdfCodeCheckFailedNotice from './pdf-code-check-failed-notice' import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context' import PdfLogEntry from './pdf-log-entry' import { usePdfPreviewContext } from '@/features/pdf-preview/components/pdf-preview-provider' import TimeoutUpgradePaywallPrompt from './timeout-upgrade-paywall-prompt' import getMeta from '@/utils/meta' function PdfLogsViewer({ alwaysVisible = false }: { alwaysVisible?: boolean }) { const { codeCheckFailed, error, hasShortCompileTimeout, logEntries, rawLog, validationIssues, showLogs, stoppedOnFirstError, isProjectOwner, } = useCompileContext() const { loadingError } = usePdfPreviewContext() const { t } = useTranslation() const [ isShowingPrimaryCompileTimeoutPaywall, setIsShowingPrimaryCompileTimeoutPaywall, ] = useState(false) const isPaywallChangeCompileTimeoutEnabled = getMeta( 'ol-isPaywallChangeCompileTimeoutEnabled' ) const isCompileTimeoutPaywallDisplay = isProjectOwner && isPaywallChangeCompileTimeoutEnabled return (
{codeCheckFailed && } {stoppedOnFirstError && } {loadingError && } {hasShortCompileTimeout && error === 'timedout' ? ( isCompileTimeoutPaywallDisplay ? ( ) : ( ) ) : ( <>{error && } )} {validationIssues && Object.entries(validationIssues).map(([name, issue]) => ( ))} {logEntries?.all && ( 0} /> )} {rawLog && ( )} {!isShowingPrimaryCompileTimeoutPaywall && (
)}
) } export default withErrorBoundary(memo(PdfLogsViewer), () => ( ))