From 8bf5790cdcbf762dbda707e64b488879b3a1fcbb Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Mon, 11 Sep 2023 10:56:43 +0100 Subject: [PATCH] Allow improvedTitle to return an additional JSX element (#14728) GitOrigin-RevId: ff2c5b9d12b7ef47f658e501ccb2c69b3d5c4cf3 --- .../pdf-preview/components/pdf-log-entry.js | 2 +- .../components/pdf-logs-entries.js | 2 +- .../components/preview-log-entry-header.js | 2 +- .../human-readable-logs/HumanReadableLogs.js | 8 ++++- ...ogsRules.js => HumanReadableLogsRules.tsx} | 35 ++++++++++++++----- 5 files changed, 36 insertions(+), 13 deletions(-) rename services/web/frontend/js/ide/human-readable-logs/{HumanReadableLogsRules.js => HumanReadableLogsRules.tsx} (88%) diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-log-entry.js b/services/web/frontend/js/features/pdf-preview/components/pdf-log-entry.js index 2f20aa9e96..100dd0f1f2 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-log-entry.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-log-entry.js @@ -67,7 +67,7 @@ function PdfLogEntry({ PdfLogEntry.propTypes = { ruleId: PropTypes.string, sourceLocation: PreviewLogEntryHeader.propTypes.sourceLocation, - headerTitle: PropTypes.string, + headerTitle: PreviewLogEntryHeader.propTypes.headerTitle, headerIcon: PropTypes.element, rawContent: PropTypes.string, logType: PropTypes.string, diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-logs-entries.js b/services/web/frontend/js/features/pdf-preview/components/pdf-logs-entries.js index 57ef298b30..86a3bccb8f 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-logs-entries.js +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-logs-entries.js @@ -25,7 +25,7 @@ function PdfLogsEntries({ entries, hasErrors }) { string | [string, JSX.Element] +} + +const rules: Rule[] = [ { ruleId: 'hint_misplaced_alignment_tab_character', regexToMatch: /Misplaced alignment tab character \&/, @@ -50,15 +63,17 @@ const rules = [ regexToMatch: /Undefined control sequence/, contentRegex: /^(?:l\.[0-9]+|<(?:recently read|inserted text|to be read again)>)\s*(\\\S+)/, - improvedTitle: (currentTitle, details) => { + improvedTitle: (currentTitle: string, details?: [string]) => { if (details?.length && packageSuggestionsForCommands.has(details[0])) { const command = details[0] const suggestion = packageSuggestionsForCommands.get(command) - return ( + return [ + `Is ${suggestion.command} missing?`, + // eslint-disable-next-line react/jsx-key Is {suggestion.command} missing? - - ) + , + ] } return currentTitle }, @@ -67,18 +82,20 @@ const rules = [ ruleId: 'hint_undefined_environment', regexToMatch: /LaTeX Error: Environment .+ undefined/, contentRegex: /\\begin\{(\S+)\}/, - improvedTitle: (currentTitle, details) => { + improvedTitle: (currentTitle: string, details?: [string]) => { if ( details?.length && packageSuggestionsForEnvironments.has(details[0]) ) { const environment = details[0] const suggestion = packageSuggestionsForEnvironments.get(environment) - return ( + return [ + `Is ${suggestion.command} missing?`, + // eslint-disable-next-line react/jsx-key Is {suggestion.command} missing? - - ) + , + ] } return currentTitle },