diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-17 17:16:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-17 17:16:34 +0300 |
commit | 4ab54c2233e91f60a80e5b6fa2181e6899fdcc3e (patch) | |
tree | 2b256ff8dfe63dafe7f42b0d995f9e74fd1dc48b /app/assets/javascripts/jobs/store | |
parent | bd860c22f6a4b9473cbddd34a53eead8235a7ea1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/jobs/store')
-rw-r--r-- | app/assets/javascripts/jobs/store/utils.js | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/app/assets/javascripts/jobs/store/utils.js b/app/assets/javascripts/jobs/store/utils.js index f6a87b9a212..261ec90cd12 100644 --- a/app/assets/javascripts/jobs/store/utils.js +++ b/app/assets/javascripts/jobs/store/utils.js @@ -1,10 +1,21 @@ /** + * Adds the line number property + * @param Object line + * @param Number lineNumber + */ +export const parseLine = (line = {}, lineNumber) => ({ + ...line, + lineNumber, +}); + +/** * Parses the job log content into a structure usable by the template * * For collaspible lines (section_header = true): * - creates a new array to hold the lines that are collpasible, * - adds a isClosed property to handle toggle * - adds a isHeader property to handle template logic + * - adds the section_duration * For each line: * - adds the index as lineNumber * @@ -14,27 +25,21 @@ export const logLinesParser = (lines = [], lineNumberStart) => lines.reduce((acc, line, index) => { const lineNumber = lineNumberStart ? lineNumberStart + index : index; + const last = acc[acc.length - 1]; + if (line.section_header) { acc.push({ isClosed: true, isHeader: true, - line: { - ...line, - lineNumber, - }, - + line: parseLine(line, lineNumber), lines: [], }); - } else if (acc.length && acc[acc.length - 1].isHeader) { - acc[acc.length - 1].lines.push({ - ...line, - lineNumber, - }); - } else { - acc.push({ - ...line, - lineNumber, - }); + } else if (acc.length && last.isHeader && !line.section_duration && line.content.length) { + last.lines.push(parseLine(line, lineNumber)); + } else if (acc.length && last.isHeader && line.section_duration) { + last.section_duration = line.section_duration; + } else if (line.content.length) { + acc.push(parseLine(line, lineNumber)); } return acc; |