Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
commit43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch)
treedceebdc68925362117480a5d672bcff122fb625b /app/assets/javascripts/jobs/store/utils.js
parent20c84b99005abd1c82101dfeff264ac50d2df211 (diff)
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'app/assets/javascripts/jobs/store/utils.js')
-rw-r--r--app/assets/javascripts/jobs/store/utils.js30
1 files changed, 22 insertions, 8 deletions
diff --git a/app/assets/javascripts/jobs/store/utils.js b/app/assets/javascripts/jobs/store/utils.js
index a7b95154c1b..bc76901026d 100644
--- a/app/assets/javascripts/jobs/store/utils.js
+++ b/app/assets/javascripts/jobs/store/utils.js
@@ -18,12 +18,26 @@ export const parseLine = (line = {}, lineNumber) => ({
* @param Object line
* @param Number lineNumber
*/
-export const parseHeaderLine = (line = {}, lineNumber) => ({
- isClosed: parseBoolean(line.section_options?.collapsed),
- isHeader: true,
- line: parseLine(line, lineNumber),
- lines: [],
-});
+export const parseHeaderLine = (line = {}, lineNumber, hash) => {
+ // if a hash is present in the URL then we ensure
+ // all sections are visible so we can scroll to the hash
+ // in the DOM
+ if (hash) {
+ return {
+ isClosed: false,
+ isHeader: true,
+ line: parseLine(line, lineNumber),
+ lines: [],
+ };
+ }
+
+ return {
+ isClosed: parseBoolean(line.section_options?.collapsed),
+ isHeader: true,
+ line: parseLine(line, lineNumber),
+ lines: [],
+ };
+};
/**
* Finds the matching header section
@@ -104,7 +118,7 @@ export const getIncrementalLineNumber = (acc) => {
* @param Array accumulator
* @returns Array parsed log lines
*/
-export const logLinesParser = (lines = [], accumulator = []) =>
+export const logLinesParser = (lines = [], accumulator = [], hash = '') =>
lines.reduce(
(acc, line, index) => {
const lineNumber = accumulator.length > 0 ? getIncrementalLineNumber(acc) : index;
@@ -113,7 +127,7 @@ export const logLinesParser = (lines = [], accumulator = []) =>
// If the object is an header, we parse it into another structure
if (line.section_header) {
- acc.push(parseHeaderLine(line, lineNumber));
+ acc.push(parseHeaderLine(line, lineNumber, hash));
} else if (isCollapsibleSection(acc, last, line)) {
// if the object belongs to a nested section, we append it to the new `lines` array of the
// previously formatted header