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
|
<script>
import { GlLoadingIcon, GlLink } from '@gitlab/ui';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
import createFlash from '~/flash';
import {
getQueryHeaders,
toggleQueryPollingByVisibility,
} from '~/pipelines/components/graph/utils';
import getLatestPipelineStatusQuery from '../graphql/queries/get_latest_pipeline_status.query.graphql';
import { COMMIT_BOX_POLL_INTERVAL, PIPELINE_STATUS_FETCH_ERROR } from '../constants';
export default {
PIPELINE_STATUS_FETCH_ERROR,
components: {
CiIcon,
GlLoadingIcon,
GlLink,
},
inject: {
fullPath: {
default: '',
},
iid: {
default: '',
},
graphqlResourceEtag: {
default: '',
},
},
apollo: {
pipelineStatus: {
context() {
return getQueryHeaders(this.graphqlResourceEtag);
},
query: getLatestPipelineStatusQuery,
pollInterval: COMMIT_BOX_POLL_INTERVAL,
variables() {
return {
fullPath: this.fullPath,
iid: this.iid,
};
},
update({ project }) {
return project?.pipeline?.detailedStatus || {};
},
error() {
createFlash({ message: this.$options.PIPELINE_STATUS_FETCH_ERROR });
},
},
},
data() {
return {
pipelineStatus: {},
};
},
computed: {
loading() {
return this.$apollo.queries.pipelineStatus.loading;
},
},
mounted() {
toggleQueryPollingByVisibility(this.$apollo.queries.pipelineStatus);
},
};
</script>
<template>
<div class="gl-display-inline-block gl-vertical-align-middle gl-mr-2">
<gl-loading-icon v-if="loading" />
<gl-link v-else :href="pipelineStatus.detailsPath">
<ci-icon :status="pipelineStatus" :size="24" />
</gl-link>
</div>
</template>
|