Просмотр исходного кода

Merge pull request #28269 from overleaf/dp-expand-compile-timeout-messages

Update compile timeout log behaviour in new logs

GitOrigin-RevId: e3bc555dff859fc16dad4749b84b9fc2a3f7d151
David 1 год назад
Родитель
Сommit
408a55460a

+ 7 - 6
services/web/frontend/js/features/ide-redesign/components/error-logs/error-logs.tsx

@@ -12,6 +12,8 @@ import { Nav, NavLink, TabContainer, TabContent } from 'react-bootstrap'
 import { LogEntry as LogEntryData } from '@/features/pdf-preview/util/types'
 import LogEntry from './log-entry'
 import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
+import TimeoutUpgradePromptNew from '@/features/pdf-preview/components/timeout-upgrade-prompt-new'
+import getMeta from '@/utils/meta'
 
 const logsComponents: Array<{
   import: { default: ElementType }
@@ -27,6 +29,7 @@ type ErrorLogTab = {
 function ErrorLogs() {
   const { error, logEntries, rawLog, validationIssues, stoppedOnFirstError } =
     useCompileContext()
+  const { compileTimeout } = getMeta('ol-compileSettings')
 
   const tabs = useMemo(() => {
     return [
@@ -72,12 +75,10 @@ function ErrorLogs() {
             />
           )}
 
-          {error && (
-            <PdfPreviewError
-              error={error}
-              includeErrors={includeErrors}
-              includeWarnings={includeWarnings}
-            />
+          {compileTimeout < 60 && error === 'timedout' ? (
+            <TimeoutUpgradePromptNew />
+          ) : (
+            <>{error && <PdfPreviewError error={error} />}</>
           )}
 
           {includeErrors &&

+ 2 - 2
services/web/frontend/js/features/ide-redesign/components/error-logs/log-entry.tsx

@@ -39,8 +39,8 @@ type LogEntryProps = {
   openCollapseIconOverride?: string
 }
 
-function LogEntry(props: LogEntryProps) {
-  const [collapsed, setCollapsed] = useState(props.index !== 0)
+function LogEntry(props: LogEntryProps & { autoExpand?: boolean }) {
+  const [collapsed, setCollapsed] = useState(!props.autoExpand)
 
   return (
     <ControlledLogEntry

+ 3 - 0
services/web/frontend/js/features/pdf-preview/components/pdf-log-entry.tsx

@@ -10,6 +10,7 @@ import NewLogEntry from '@/features/ide-redesign/components/error-logs/log-entry
 import { useFeatureFlag } from '@/shared/context/split-test-context'
 
 function PdfLogEntry({
+  autoExpand,
   ruleId,
   headerTitle,
   headerIcon,
@@ -29,6 +30,7 @@ function PdfLogEntry({
 }: {
   headerTitle: string | React.ReactNode
   level: ErrorLevel
+  autoExpand?: boolean
   ruleId?: string
   headerIcon?: React.ReactElement
   rawContent?: string
@@ -75,6 +77,7 @@ function PdfLogEntry({
   if (newEditor && newErrorlogs) {
     return (
       <NewLogEntry
+        autoExpand={autoExpand}
         index={index}
         id={id}
         logEntry={logEntry}

+ 1 - 0
services/web/frontend/js/features/pdf-preview/components/pdf-logs-entries.tsx

@@ -45,6 +45,7 @@ function PdfLogsEntries({
       {logEntries.map((logEntry, index) => (
         <PdfLogEntry
           key={logEntry.key}
+          autoExpand={index === 0}
           index={index}
           id={logEntry.key}
           logEntry={logEntry}

+ 4 - 1
services/web/frontend/js/features/pdf-preview/components/pdf-preview-error.tsx

@@ -253,10 +253,12 @@ function PdfPreviewError({
 export default memo(PdfPreviewError)
 
 function ErrorLogEntry({
+  autoExpand,
   title,
   headerIcon,
   children,
 }: {
+  autoExpand?: boolean
   title: string
   headerIcon?: React.ReactElement
   children: React.ReactNode
@@ -265,6 +267,7 @@ function ErrorLogEntry({
 
   return (
     <PdfLogEntry
+      autoExpand={autoExpand}
       headerTitle={title}
       headerIcon={headerIcon}
       formattedContent={children}
@@ -289,7 +292,7 @@ function TimedOutLogEntry() {
   }, [enableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
 
   return (
-    <ErrorLogEntry title={t('timedout')}>
+    <ErrorLogEntry autoExpand title={t('timedout')}>
       <p>{t('project_timed_out_intro')}</p>
       <ul>
         <li>

+ 2 - 0
services/web/frontend/js/features/pdf-preview/components/timeout-upgrade-prompt-new.tsx

@@ -66,6 +66,7 @@ const CompileTimeout = memo(function CompileTimeout({
 
   return (
     <PdfLogEntry
+      autoExpand
       headerTitle={t('your_compile_timed_out')}
       formattedContent={
         getMeta('ol-ExposedSettings').enableSubscriptions && (
@@ -147,6 +148,7 @@ const PreventTimeoutHelpMessage = memo(function PreventTimeoutHelpMessage({
 
   return (
     <PdfLogEntry
+      autoExpand
       headerTitle={t('reasons_for_compile_timeouts')}
       formattedContent={
         <>