mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 02:24:30 -05:00
03e1daa038
Error boundaries for React PDF viewer GitOrigin-RevId: 90052fc183f7ece8125ecfb0410a529cf905c13b
74 lines
2.4 KiB
JavaScript
74 lines
2.4 KiB
JavaScript
import Icon from '../../../shared/components/icon'
|
|
import { useTranslation } from 'react-i18next'
|
|
import PreviewLogsPaneEntry from '../../preview/components/preview-logs-pane-entry'
|
|
import { usePdfPreviewContext } from '../contexts/pdf-preview-context'
|
|
import { memo } from 'react'
|
|
import PdfValidationIssue from './pdf-validation-issue'
|
|
import TimeoutUpgradePrompt from './timeout-upgrade-prompt'
|
|
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 ErrorBoundaryFallback from './error-boundary-fallback'
|
|
|
|
function PdfLogsViewer() {
|
|
const {
|
|
autoCompileLintingError,
|
|
stopOnValidationError,
|
|
error,
|
|
logEntries,
|
|
rawLog,
|
|
validationIssues,
|
|
} = usePdfPreviewContext()
|
|
|
|
const { t } = useTranslation()
|
|
|
|
return (
|
|
<div className="logs-pane">
|
|
<div className="logs-pane-content">
|
|
{autoCompileLintingError && stopOnValidationError && (
|
|
<div className="log-entry">
|
|
<div className="log-entry-header log-entry-header-error">
|
|
<div className="log-entry-header-icon-container">
|
|
<Icon type="exclamation-triangle" modifier="fw" />
|
|
</div>
|
|
<h3 className="log-entry-header-title">
|
|
{t('code_check_failed_explanation')}
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{error && <PdfPreviewError error={error} />}
|
|
|
|
{error === 'timedout' && <TimeoutUpgradePrompt />}
|
|
|
|
{validationIssues &&
|
|
Object.entries(validationIssues).map(([name, issue]) => (
|
|
<PdfValidationIssue key={name} name={name} issue={issue} />
|
|
))}
|
|
|
|
{logEntries?.all && <PdfLogsEntries entries={logEntries.all} />}
|
|
|
|
{rawLog && (
|
|
<PreviewLogsPaneEntry
|
|
headerTitle={t('raw_logs')}
|
|
rawContent={rawLog}
|
|
entryAriaLabel={t('raw_logs_description')}
|
|
level="raw"
|
|
/>
|
|
)}
|
|
|
|
<div className="logs-pane-actions">
|
|
<PdfClearCacheButton />
|
|
<PdfDownloadFilesButton />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default withErrorBoundary(memo(PdfLogsViewer), () => (
|
|
<ErrorBoundaryFallback type="logs" />
|
|
))
|