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'
|
2021-09-30 07:29:25 -04:00
|
|
|
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'
|
2021-10-06 04:33:24 -04:00
|
|
|
import withErrorBoundary from '../../../infrastructure/error-boundary'
|
|
|
|
import ErrorBoundaryFallback from './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'
|
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,
|
|
|
|
logEntries,
|
|
|
|
rawLog,
|
|
|
|
validationIssues,
|
2021-10-15 05:39:56 -04:00
|
|
|
showLogs,
|
2022-06-07 07:55:48 -04:00
|
|
|
stopOnFirstError,
|
|
|
|
stoppedOnFirstError,
|
2021-10-15 05:39:56 -04:00
|
|
|
} = useCompileContext()
|
2021-09-30 07:29:25 -04:00
|
|
|
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
return (
|
2021-10-15 05:39:56 -04:00
|
|
|
<div className={classnames('logs-pane', { hidden: !showLogs })}>
|
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-07 07:55:48 -04:00
|
|
|
{stopOnFirstError && stoppedOnFirstError && <StopOnFirstErrorPrompt />}
|
|
|
|
|
2021-09-30 07:29:25 -04:00
|
|
|
{error && <PdfPreviewError error={error} />}
|
|
|
|
|
|
|
|
{error === 'timedout' && <TimeoutUpgradePrompt />}
|
|
|
|
|
|
|
|
{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), () => (
|
|
|
|
<ErrorBoundaryFallback type="logs" />
|
|
|
|
))
|