summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/pipelines/list.vue
blob: 5757dfdc925ee7a66fd2ecba4d31c90bf760115f (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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<script>
import { mapActions, mapGetters, mapState } from 'vuex';
import _ from 'underscore';
import { sprintf, __ } from '../../../locale';
import LoadingIcon from '../../../vue_shared/components/loading_icon.vue';
import Icon from '../../../vue_shared/components/icon.vue';
import CiIcon from '../../../vue_shared/components/ci_icon.vue';
import Tabs from '../../../vue_shared/components/tabs/tabs';
import Tab from '../../../vue_shared/components/tabs/tab.vue';
import EmptyState from '../../../pipelines/components/empty_state.vue';
import JobsList from '../jobs/list.vue';

export default {
  components: {
    LoadingIcon,
    Icon,
    CiIcon,
    Tabs,
    Tab,
    JobsList,
    EmptyState,
  },
  computed: {
    ...mapState(['pipelinesEmptyStateSvgPath', 'links']),
    ...mapGetters(['currentProject']),
    ...mapGetters('pipelines', ['jobsCount', 'failedJobsCount', 'failedStages', 'pipelineFailed']),
    ...mapState('pipelines', ['isLoadingPipeline', 'latestPipeline', 'stages', 'isLoadingJobs']),
    ciLintText() {
      return sprintf(
        __('You can also test your .gitlab-ci.yml in the %{linkStart}Lint%{linkEnd}'),
        {
          linkStart: `<a href="${_.escape(this.currentProject.web_url)}/-/ci/lint">`,
          linkEnd: '</a>',
        },
        false,
      );
    },
    showLoadingIcon() {
      return this.isLoadingPipeline && this.latestPipeline === null;
    },
  },
  created() {
    this.fetchLatestPipeline();
  },
  methods: {
    ...mapActions('pipelines', ['fetchLatestPipeline']),
  },
};
</script>

<template>
  <div class="ide-pipeline">
    <loading-icon
      v-if="showLoadingIcon"
      class="prepend-top-default"
      size="2"
    />
    <template v-else-if="latestPipeline !== null">
      <header
        v-if="latestPipeline"
        class="ide-tree-header ide-pipeline-header"
      >
        <ci-icon
          :status="latestPipeline.details.status"
          :size="24"
        />
        <span class="prepend-left-8">
          <strong>
            {{ __('Pipeline') }}
          </strong>
          <a
            :href="latestPipeline.path"
            target="_blank"
            class="ide-external-link"
          >
            #{{ latestPipeline.id }}
            <icon
              :size="12"
              name="external-link"
            />
          </a>
        </span>
      </header>
      <empty-state
        v-if="latestPipeline === false"
        :help-page-path="links.ciHelpPagePath"
        :empty-state-svg-path="pipelinesEmptyStateSvgPath"
        :can-set-ci="true"
      />
      <div
        v-else-if="latestPipeline.yamlError"
        class="bs-callout bs-callout-danger"
      >
        <p class="append-bottom-0">
          {{ __('Found errors in your .gitlab-ci.yml:') }}
        </p>
        <p class="append-bottom-0 break-word">
          {{ latestPipeline.yamlError }}
        </p>
        <p
          class="append-bottom-0"
          v-html="ciLintText"
        ></p>
      </div>
      <tabs
        v-else
        class="ide-pipeline-list"
      >
        <tab
          :active="!pipelineFailed"
        >
          <template slot="title">
            {{ __('Jobs') }}
            <span
              v-if="jobsCount"
              class="badge badge-pill"
            >
              {{ jobsCount }}
            </span>
          </template>
          <jobs-list
            :loading="isLoadingJobs"
            :stages="stages"
          />
        </tab>
        <tab
          :active="pipelineFailed"
        >
          <template slot="title">
            {{ __('Failed Jobs') }}
            <span
              v-if="failedJobsCount"
              class="badge badge-pill"
            >
              {{ failedJobsCount }}
            </span>
          </template>
          <jobs-list
            :loading="isLoadingJobs"
            :stages="failedStages"
          />
        </tab>
      </tabs>
    </template>
  </div>
</template>