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

commit_box_pipeline_status.vue « components « info « commit_box « projects « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0feaf8db82bb0ffc81016aa4bf21e5d5cf407e13 (plain)
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 } from '@gitlab/ui';
import CiBadgeLink from '~/vue_shared/components/ci_badge_link.vue';
import { createAlert } from '~/alert';
import { getQueryHeaders, toggleQueryPollingByVisibility } from '~/ci/pipeline_details/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: {
    CiBadgeLink,
    GlLoadingIcon,
  },
  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() {
        createAlert({ 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" />
    <ci-badge-link
      v-else
      :status="pipelineStatus"
      :details-path="pipelineStatus.detailsPath"
      size="md"
      :show-text="false"
    />
  </div>
</template>