From 045b7d2a6da5f3af842444bad122129c9503d9a5 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Wed, 27 Dec 2023 16:43:23 +1100 Subject: [PATCH] Updates beginning section default based on log target --- src/components/LogViewer/index.js | 13 ++++++------- src/components/Task/index.tsx | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/LogViewer/index.js b/src/components/LogViewer/index.js index 42613b6b..97107f2e 100644 --- a/src/components/LogViewer/index.js +++ b/src/components/LogViewer/index.js @@ -4,12 +4,12 @@ import LogAccordion from 'components/LogViewer/LogAccordion'; import { StyledLogs } from './StyledLogViewer'; -const LogViewer = ({ logs, status = 'NA', checkedParseState, changeState, forceLastSectionOpen = true }) => ( +const LogViewer = ({ logs, status = 'NA', checkedParseState, changeState, forceLastSectionOpen = true, logsTarget = "Deployments" }) => ( {logs !== null ? ( checkedParseState ? ( -
{logPreprocessor(logs, status, forceLastSectionOpen)}
+
{logPreprocessor(logs, status, forceLastSectionOpen, logsTarget)}
) : (
{logs}
) @@ -37,13 +37,13 @@ const isLogStateBad = status => { * @param {*} status a status for the build - if not complete, we open the very last item * @returns */ -const logPreprocessor = (logs, status, forceLastSectionOpen = true) => { +const logPreprocessor = (logs, status, forceLastSectionOpen = true, logsTarget) => { let ret = null; let statusBad = isLogStateBad(status); let openLastSection = forceLastSectionOpen || shouldLastSectionBeOpen(status); try { - let tokens = logPreprocessorTokenize(logs); + let tokens = logPreprocessorTokenize(logs, logsTarget); let sectionMetadata = logPreprocessorExtractSectionEndDetails(logs); let AST = logPreprocessorProcessParse(tokens, sectionMetadata); return logPreprocessorProcessASTToReact(AST, openLastSection, statusBad); @@ -183,12 +183,11 @@ const logPreprocessorExtractSectionEndDetails = logs => { return ret; }; -const logPreprocessorTokenize = logs => { +const logPreprocessorTokenize = (logs, logsTarget) => { // tokenize const regexp = /##############################################\n(BEGIN) (.+)\n##############################################/; - const beginningSectionDefaultDetails = 'Build Setup'; - + const beginningSectionDefaultDetails = logsTarget === "Deployments" ? 'Build Setup' : 'Task Setup'; // The regex above will split the logs into three separate token types // 1. standard blocks of text // 2. markers for section starts containing "SECTION" only diff --git a/src/components/Task/index.tsx b/src/components/Task/index.tsx index 10892a95..b5f9de87 100644 --- a/src/components/Task/index.tsx +++ b/src/components/Task/index.tsx @@ -79,7 +79,7 @@ const Task: FC = ({ task, projectId, environmentId }) => { )} - + ); };