overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-logs-viewer.jsx

85 lines
2.6 KiB
React
Raw Normal View History

import { useTranslation } from 'react-i18next'
import { memo } 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'
function PdfLogsViewer() {
const {
codeCheckFailed,
error,
logEntries,
rawLog,
validationIssues,
showLogs,
stoppedOnFirstError,
} = useCompileContext()
const { loadingError } = usePdfPreviewContext()
const { t } = useTranslation()
return (
<div
className={classnames('logs-pane', {
hidden: !showLogs && !loadingError,
})}
>
<div className="logs-pane-content">
{codeCheckFailed && <PdfCodeCheckFailedNotice />}
{stoppedOnFirstError && <StopOnFirstErrorPrompt />}
{loadingError && <PdfPreviewError error="pdf-viewer-loading-error" />}
[web] Remove split-tests `compile-backend-class*` and `compile-timeout-20s*` (#17700) * Remove split-tests of `compile-timeout-20s` and `compile-timeout-20s-existing-users` * Remove `NEW_COMPILE_TIMEOUT_ENFORCED_CUTOFF` variables * Revert timeout override `60` -> `20` * Update settings.overrides.saas.js: `compileTimeout: 20` * Remove `compile-backend-class-n2d` * Remove `force_new_compile_timeout` * Remove `showNewCompileTimeoutUI` * Remove `compileTimeChanging` * Simplify code by removing segmentation object * Remove `CompileTimeoutChangingSoon` * Remove `user.features.compileTimeout = '20 (with 10s prompt)'` * Remove `CompileTimeWarning` * Remove `TimeoutUpgradePrompt` (old) * Remove `compile-backend-class` * Remove unused translations * Update tests * Fix: Show `CompileTimeout` even if `!window.ExposedSettings.enableSubscriptions` * Create script to migrate users to 20s compileTimeout * migration script: exclude `compileTimeout: 20` from the match * migration script: use `batchedUpdate` * Remove `showFasterCompilesFeedbackUI` and `FasterCompilesFeedback` Helped-by: Jakob Ackermann <jakob.ackermann@overleaf.com> * Remove `_getCompileBackendClassDetails`, simplify definition of `limits` object * Remove `Settings.apis.clsi.defaultBackendClass` * Remove unnecessary second scan of the whole user collection in dry mode * Override `timeout` to 20 for users having `compileGroup === 'standard' && compileTimeout <= 60` * Remove second `logCount`: re-run the script in dry-mode if you want to see that count * Use secondary readPreference when counting users * Fix script setup and exit 0 * Fix: Remove `user.` from query path! * Add acceptance test on script migration_compile_timeout_60s_to_20s.js GitOrigin-RevId: 3cb65130e6d7fbd9c54005f4c213066d0473e9d8
2024-04-12 04:40:09 -04:00
{error === 'timedout' ? (
<TimeoutUpgradePromptNew />
) : (
[web] Remove split-tests `compile-backend-class*` and `compile-timeout-20s*` (#17700) * Remove split-tests of `compile-timeout-20s` and `compile-timeout-20s-existing-users` * Remove `NEW_COMPILE_TIMEOUT_ENFORCED_CUTOFF` variables * Revert timeout override `60` -> `20` * Update settings.overrides.saas.js: `compileTimeout: 20` * Remove `compile-backend-class-n2d` * Remove `force_new_compile_timeout` * Remove `showNewCompileTimeoutUI` * Remove `compileTimeChanging` * Simplify code by removing segmentation object * Remove `CompileTimeoutChangingSoon` * Remove `user.features.compileTimeout = '20 (with 10s prompt)'` * Remove `CompileTimeWarning` * Remove `TimeoutUpgradePrompt` (old) * Remove `compile-backend-class` * Remove unused translations * Update tests * Fix: Show `CompileTimeout` even if `!window.ExposedSettings.enableSubscriptions` * Create script to migrate users to 20s compileTimeout * migration script: exclude `compileTimeout: 20` from the match * migration script: use `batchedUpdate` * Remove `showFasterCompilesFeedbackUI` and `FasterCompilesFeedback` Helped-by: Jakob Ackermann <jakob.ackermann@overleaf.com> * Remove `_getCompileBackendClassDetails`, simplify definition of `limits` object * Remove `Settings.apis.clsi.defaultBackendClass` * Remove unnecessary second scan of the whole user collection in dry mode * Override `timeout` to 20 for users having `compileGroup === 'standard' && compileTimeout <= 60` * Remove second `logCount`: re-run the script in dry-mode if you want to see that count * Use secondary readPreference when counting users * Fix script setup and exit 0 * Fix: Remove `user.` from query path! * Add acceptance test on script migration_compile_timeout_60s_to_20s.js GitOrigin-RevId: 3cb65130e6d7fbd9c54005f4c213066d0473e9d8
2024-04-12 04:40:09 -04:00
<>{error && <PdfPreviewError error={error} />}</>
)}
{validationIssues &&
Object.entries(validationIssues).map(([name, issue]) => (
<PdfValidationIssue key={name} name={name} issue={issue} />
))}
{logEntries?.all && (
<PdfLogsEntries
entries={logEntries.all}
hasErrors={logEntries.errors.length > 0}
/>
)}
{rawLog && (
<PdfLogEntry
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), () => (
<PdfPreviewErrorBoundaryFallback type="logs" />
))