1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
<!-- eslint-disable vue/multi-word-component-names -->
<script>
// eslint-disable-next-line no-restricted-imports
import { mapState, mapActions } from 'vuex';
import { scrollToElement } from '~/lib/utils/common_utils';
import { getLocationHash } from '~/lib/utils/url_utility';
import LogLine from './line.vue';
import LogLineHeader from './line_header.vue';
export default {
components: {
LogLineHeader,
LogLine,
},
inject: ['pagePath'],
props: {
searchResults: {
type: Array,
required: false,
default: () => [],
},
},
computed: {
...mapState(['jobLog', 'jobLogSections', 'isJobLogComplete']),
highlightedLines() {
return this.searchResults.map((result) => result.lineNumber);
},
},
mounted() {
if (window.location.hash) {
const lineNumber = getLocationHash();
this.unwatchJobLog = this.$watch('jobLog', async () => {
if (this.jobLog.length) {
await this.$nextTick();
const el = document.getElementById(lineNumber);
scrollToElement(el);
this.unwatchJobLog();
}
});
}
},
methods: {
...mapActions(['toggleCollapsibleLine', 'scrollBottom']),
handleOnClickCollapsibleLine(section) {
this.toggleCollapsibleLine(section);
},
isLineVisible(line) {
const { lineNumber, section } = line;
if (!section) {
// lines outside of sections can't be collapsed
return true;
}
return !Object.values(this.jobLogSections).find(
({ isClosed, startLineNumber, endLineNumber }) => {
return isClosed && lineNumber > startLineNumber && lineNumber <= endLineNumber;
},
);
},
isHighlighted({ lineNumber }) {
return this.highlightedLines.includes(lineNumber);
},
},
};
</script>
<template>
<code class="job-log gl-display-block" data-testid="job-log-content">
<template v-for="line in jobLog">
<template v-if="isLineVisible(line)">
<log-line-header
v-if="line.isHeader"
:key="line.offset"
:line="line"
:path="pagePath"
:is-closed="jobLogSections[line.section].isClosed"
:duration="jobLogSections[line.section].duration"
:hide-duration="jobLogSections[line.section].hideDuration"
:is-highlighted="isHighlighted(line)"
@toggleLine="handleOnClickCollapsibleLine(line.section)"
/>
<log-line
v-else
:key="line.offset"
:line="line"
:path="pagePath"
:is-highlighted="isHighlighted(line)"
/>
</template>
</template>
<div v-if="!isJobLogComplete" class="js-log-animation loader-animation pt-3 pl-3">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
</code>
</template>
|