debian-mirror-gitlab/app/assets/javascripts/jobs/components/log/log.vue

71 lines
1.9 KiB
Vue
Raw Normal View History

2019-12-04 20:38:33 +05:30
<script>
import { mapState, mapActions } from 'vuex';
2020-07-28 23:09:34 +05:30
import CollapsibleLogSection from './collapsible_section.vue';
2019-12-04 20:38:33 +05:30
import LogLine from './line.vue';
export default {
components: {
2020-07-28 23:09:34 +05:30
CollapsibleLogSection,
2019-12-04 20:38:33 +05:30
LogLine,
},
computed: {
2019-12-26 22:10:19 +05:30
...mapState([
'traceEndpoint',
'trace',
'isTraceComplete',
'isScrolledToBottomBeforeReceivingTrace',
]),
},
updated() {
this.$nextTick(() => {
this.handleScrollDown();
});
},
mounted() {
this.$nextTick(() => {
this.handleScrollDown();
});
2019-12-04 20:38:33 +05:30
},
methods: {
2019-12-26 22:10:19 +05:30
...mapActions(['toggleCollapsibleLine', 'scrollBottom']),
2019-12-04 20:38:33 +05:30
handleOnClickCollapsibleLine(section) {
this.toggleCollapsibleLine(section);
},
2019-12-26 22:10:19 +05:30
/**
* The job log is sent in HTML, which means we need to use `v-html` to render it
* Using the updated hook with $nextTick is not enough to wait for the DOM to be updated
* in this case because it runs before `v-html` has finished running, since there's no
* Vue binding.
* In order to scroll the page down after `v-html` has finished, we need to use setTimeout
*/
handleScrollDown() {
if (this.isScrolledToBottomBeforeReceivingTrace) {
setTimeout(() => {
this.scrollBottom();
}, 0);
}
},
2019-12-04 20:38:33 +05:30
},
};
</script>
<template>
2020-03-09 13:42:32 +05:30
<code class="job-log d-block" data-qa-selector="job_log_content">
2019-12-04 20:38:33 +05:30
<template v-for="(section, index) in trace">
2020-07-28 23:09:34 +05:30
<collapsible-log-section
2019-12-21 20:55:43 +05:30
v-if="section.isHeader"
:key="`collapsible-${index}`"
:section="section"
:trace-endpoint="traceEndpoint"
@onClickCollapsibleLine="handleOnClickCollapsibleLine"
/>
2019-12-04 20:38:33 +05:30
<log-line v-else :key="section.offset" :line="section" :path="traceEndpoint" />
</template>
<div v-if="!isTraceComplete" 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>