Explorar o código

Move the compile assistant into individual log entries (#18168)

GitOrigin-RevId: 391fd9f31e637bf27f81ebee0dd33fcdfba5f22b
Alf Eaton %!s(int64=2) %!d(string=hai) anos
pai
achega
de353bd8aa

+ 1 - 1
services/web/config/settings.defaults.js

@@ -903,7 +903,7 @@ module.exports = {
     editorToolbarButtons: [],
     sourceEditorExtensions: [],
     sourceEditorComponents: [],
-    pdfLogsComponents: [],
+    pdfLogEntryComponents: [],
     sourceEditorCompletionSources: [],
     sourceEditorSymbolPalette: [],
     sourceEditorToolbarComponents: [],

+ 14 - 0
services/web/frontend/js/features/pdf-preview/components/pdf-log-entry-content.jsx

@@ -1,11 +1,16 @@
 import { useTranslation } from 'react-i18next'
 import PdfLogEntryRawContent from './pdf-log-entry-raw-content'
 import PropTypes from 'prop-types'
+import importOverleafModules from '../../../../macros/import-overleaf-module.macro'
+
+const pdfLogEntryComponents = importOverleafModules('pdfLogEntryComponents')
 
 export default function PdfLogEntryContent({
   rawContent,
   formattedContent,
   extraInfoURL,
+  index,
+  logEntry,
 }) {
   const { t } = useTranslation()
 
@@ -23,6 +28,13 @@ export default function PdfLogEntryContent({
         </div>
       )}
 
+      {logEntry &&
+        pdfLogEntryComponents.map(
+          ({ import: { default: Component }, path }) => (
+            <Component key={path} index={index} logEntry={logEntry} />
+          )
+        )}
+
       {rawContent && (
         <PdfLogEntryRawContent rawContent={rawContent} collapsedSize={150} />
       )}
@@ -34,4 +46,6 @@ PdfLogEntryContent.propTypes = {
   rawContent: PropTypes.string,
   formattedContent: PropTypes.node,
   extraInfoURL: PropTypes.string,
+  index: PropTypes.number,
+  logEntry: PropTypes.any,
 }

+ 7 - 0
services/web/frontend/js/features/pdf-preview/components/pdf-log-entry.jsx

@@ -23,6 +23,8 @@ function PdfLogEntry({
   contentDetails,
   onSourceLocationClick,
   onClose,
+  index,
+  logEntry,
 }) {
   if (ruleId && HumanReadableLogsHints[ruleId]) {
     const hint = HumanReadableLogsHints[ruleId]
@@ -59,11 +61,14 @@ function PdfLogEntry({
         showCloseButton={showCloseButton}
         onClose={onClose}
       />
+
       {(rawContent || formattedContent) && (
         <PdfLogEntryContent
           rawContent={rawContent}
           formattedContent={formattedContent}
           extraInfoURL={extraInfoURL}
+          index={index}
+          logEntry={logEntry}
         />
       )}
     </div>
@@ -94,6 +99,8 @@ PdfLogEntry.propTypes = {
   contentDetails: PropTypes.arrayOf(PropTypes.string),
   onSourceLocationClick: PropTypes.func,
   onClose: PropTypes.func,
+  index: PropTypes.number,
+  logEntry: PropTypes.any,
 }
 
 export default memo(PdfLogEntry)

+ 3 - 8
services/web/frontend/js/features/pdf-preview/components/pdf-logs-entries.jsx

@@ -4,12 +4,9 @@ import { useTranslation } from 'react-i18next'
 import PreviewLogsPaneMaxEntries from '../../preview/components/preview-logs-pane-max-entries'
 import PdfLogEntry from './pdf-log-entry'
 import { useDetachCompileContext } from '../../../shared/context/detach-compile-context'
-import importOverleafModules from '../../../../macros/import-overleaf-module.macro'
 
 const LOG_PREVIEW_LIMIT = 100
 
-const pdfLogsComponents = importOverleafModules('pdfLogsComponents')
-
 function PdfLogsEntries({ entries, hasErrors }) {
   const { t } = useTranslation()
   const { syncToEntry } = useDetachCompileContext()
@@ -25,13 +22,11 @@ function PdfLogsEntries({ entries, hasErrors }) {
         />
       )}
 
-      {pdfLogsComponents.map(({ import: { default: Component }, path }) => (
-        <Component key={path} entries={entries} />
-      ))}
-
-      {logEntries.map(logEntry => (
+      {logEntries.map((logEntry, index) => (
         <PdfLogEntry
           key={logEntry.key}
+          index={index}
+          logEntry={logEntry}
           ruleId={logEntry.ruleId}
           headerTitle={logEntry.messageComponent ?? logEntry.message}
           rawContent={logEntry.content}