summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/store/utils.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 14:14:39 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 14:14:39 +0000
commit1eb82b65c554f21d83447f895a6208905fabe112 (patch)
treeab12f01b3dc46f11c02afea1e470a78f06ca70c2 /app/assets/javascripts/jobs/store/utils.js
parent4ab54c2233e91f60a80e5b6fa2181e6899fdcc3e (diff)
downloadgitlab-ce-stable-branch-foss-test.tar.gz
Add latest changes from gitlab-org/gitlab@12-3-auto-deploy-20190916stable-branch-foss-test
Diffstat (limited to 'app/assets/javascripts/jobs/store/utils.js')
-rw-r--r--app/assets/javascripts/jobs/store/utils.js35
1 files changed, 15 insertions, 20 deletions
diff --git a/app/assets/javascripts/jobs/store/utils.js b/app/assets/javascripts/jobs/store/utils.js
index 261ec90cd12..f6a87b9a212 100644
--- a/app/assets/javascripts/jobs/store/utils.js
+++ b/app/assets/javascripts/jobs/store/utils.js
@@ -1,21 +1,10 @@
/**
- * 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
*
@@ -25,21 +14,27 @@ export const parseLine = (line = {}, lineNumber) => ({
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: parseLine(line, lineNumber),
+ line: {
+ ...line,
+ lineNumber,
+ },
+
lines: [],
});
- } 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));
+ } else if (acc.length && acc[acc.length - 1].isHeader) {
+ acc[acc.length - 1].lines.push({
+ ...line,
+ lineNumber,
+ });
+ } else {
+ acc.push({
+ ...line,
+ lineNumber,
+ });
}
return acc;