2021-09-30 07:29:25 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { memo } from 'react'
|
2021-10-15 05:39:56 -04:00
|
|
|
import classnames from 'classnames'
|
2021-09-30 07:29:25 -04:00
|
|
|
import PdfValidationIssue from './pdf-validation-issue'
|
2022-06-07 07:55:48 -04:00
|
|
|
import StopOnFirstErrorPrompt from './stop-on-first-error-prompt'
|
2023-09-18 07:35:43 -04:00
|
|
|
import TimeoutUpgradePromptNew from './timeout-upgrade-prompt-new'
|
2021-09-30 07:29:25 -04:00
|
|
|
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'
|
2021-10-06 04:33:24 -04:00
|
|
|
import withErrorBoundary from '../../../infrastructure/error-boundary'
|
2022-08-09 09:48:59 -04:00
|
|
|
import PdfPreviewErrorBoundaryFallback from './pdf-preview-error-boundary-fallback'
|
2021-10-15 06:42:47 -04:00
|
|
|
import PdfCodeCheckFailedNotice from './pdf-code-check-failed-notice'
|
2022-03-31 07:22:36 -04:00
|
|
|
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
|
2021-10-15 06:42:47 -04:00
|
|
|
import PdfLogEntry from './pdf-log-entry'
|
2023-09-28 05:56:45 -04:00
|
|
|
import { usePdfPreviewContext } from '@/features/pdf-preview/components/pdf-preview-provider'
|
2021-09-30 07:29:25 -04:00
|
|
|
|
|
|
|
function PdfLogsViewer() {
|
|
|
|
const {
|
2021-10-08 05:23:33 -04:00
|
|
|
codeCheckFailed,
|
2021-09-30 07:29:25 -04:00
|
|
|
error,
|
2024-04-15 05:33:46 -04:00
|
|
|
hasShortCompileTimeout,
|
2021-09-30 07:29:25 -04:00
|
|
|
logEntries,
|
|
|
|
rawLog,
|
|
|
|
validationIssues,
|
2021-10-15 05:39:56 -04:00
|
|
|
showLogs,
|
2022-06-07 07:55:48 -04:00
|
|
|
stoppedOnFirstError,
|
2021-10-15 05:39:56 -04:00
|
|
|
} = useCompileContext()
|
2021-09-30 07:29:25 -04:00
|
|
|
|
2023-09-28 05:56:45 -04:00
|
|
|
const { loadingError } = usePdfPreviewContext()
|
|
|
|
|
2021-09-30 07:29:25 -04:00
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
return (
|
2023-09-28 05:56:45 -04:00
|
|
|
<div
|
|
|
|
className={classnames('logs-pane', {
|
|
|
|
hidden: !showLogs && !loadingError,
|
|
|
|
})}
|
|
|
|
>
|
2021-09-30 07:29:25 -04:00
|
|
|
<div className="logs-pane-content">
|
2021-10-12 04:47:46 -04:00
|
|
|
{codeCheckFailed && <PdfCodeCheckFailedNotice />}
|
2021-09-30 07:29:25 -04:00
|
|
|
|
2022-06-09 10:47:53 -04:00
|
|
|
{stoppedOnFirstError && <StopOnFirstErrorPrompt />}
|
2022-06-07 07:55:48 -04:00
|
|
|
|
2023-09-28 05:56:45 -04:00
|
|
|
{loadingError && <PdfPreviewError error="pdf-viewer-loading-error" />}
|
|
|
|
|
2024-04-15 05:33:46 -04:00
|
|
|
{hasShortCompileTimeout && error === 'timedout' ? (
|
2023-09-18 07:35:43 -04:00
|
|
|
<TimeoutUpgradePromptNew />
|
|
|
|
) : (
|
2024-04-15 05:33:46 -04:00
|
|
|
<>{error && <PdfPreviewError error={error} />}</>
|
2023-09-18 07:35:43 -04:00
|
|
|
)}
|
2021-09-30 07:29:25 -04:00
|
|
|
|
|
|
|
{validationIssues &&
|
|
|
|
Object.entries(validationIssues).map(([name, issue]) => (
|
|
|
|
<PdfValidationIssue key={name} name={name} issue={issue} />
|
|
|
|
))}
|
|
|
|
|
2021-11-25 05:24:25 -05:00
|
|
|
{logEntries?.all && (
|
|
|
|
<PdfLogsEntries
|
|
|
|
entries={logEntries.all}
|
|
|
|
hasErrors={logEntries.errors.length > 0}
|
|
|
|
/>
|
|
|
|
)}
|
2021-09-30 07:29:25 -04:00
|
|
|
|
|
|
|
{rawLog && (
|
2021-10-15 06:42:47 -04:00
|
|
|
<PdfLogEntry
|
2021-09-30 07:29:25 -04:00
|
|
|
headerTitle={t('raw_logs')}
|
|
|
|
rawContent={rawLog}
|
|
|
|
entryAriaLabel={t('raw_logs_description')}
|
|
|
|
level="raw"
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<div className="logs-pane-actions">
|
|
|
|
<PdfClearCacheButton />
|
|
|
|
<PdfDownloadFilesButton />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-10-06 04:33:24 -04:00
|
|
|
export default withErrorBoundary(memo(PdfLogsViewer), () => (
|
2022-08-09 09:48:59 -04:00
|
|
|
<PdfPreviewErrorBoundaryFallback type="logs" />
|
2021-10-06 04:33:24 -04:00
|
|
|
))
|