list.vue 3.8 KB
Newer Older
P
Phil Hughes 已提交
1
<script>
P
Phil Hughes 已提交
2
import { mapActions, mapGetters, mapState } from 'vuex';
3
import _ from 'underscore';
4
import { sprintf, __ } from '../../../locale';
P
Phil Hughes 已提交
5
import Icon from '../../../vue_shared/components/icon.vue';
P
Phil Hughes 已提交
6
import CiIcon from '../../../vue_shared/components/ci_icon.vue';
P
Phil Hughes 已提交
7 8
import Tabs from '../../../vue_shared/components/tabs/tabs';
import Tab from '../../../vue_shared/components/tabs/tab.vue';
9
import EmptyState from '../../../pipelines/components/empty_state.vue';
P
Phil Hughes 已提交
10
import JobsList from '../jobs/list.vue';
P
Phil Hughes 已提交
11 12 13

export default {
  components: {
P
Phil Hughes 已提交
14
    Icon,
P
Phil Hughes 已提交
15
    CiIcon,
P
Phil Hughes 已提交
16 17
    Tabs,
    Tab,
P
Phil Hughes 已提交
18
    JobsList,
19
    EmptyState,
P
Phil Hughes 已提交
20 21
  },
  computed: {
22
    ...mapState(['pipelinesEmptyStateSvgPath', 'links']),
23
    ...mapGetters(['currentProject']),
P
Phil Hughes 已提交
24
    ...mapGetters('pipelines', ['jobsCount', 'failedJobsCount', 'failedStages', 'pipelineFailed']),
P
Phil Hughes 已提交
25
    ...mapState('pipelines', ['isLoadingPipeline', 'latestPipeline', 'stages', 'isLoadingJobs']),
26 27
    ciLintText() {
      return sprintf(
28
        __('You can test your .gitlab-ci.yml in %{linkStart}CI Lint%{linkEnd}.'),
29
        {
30
          linkStart: `<a href="${_.escape(this.currentProject.web_url)}/-/ci/lint">`,
31 32 33 34 35
          linkEnd: '</a>',
        },
        false,
      );
    },
36 37 38
    showLoadingIcon() {
      return this.isLoadingPipeline && this.latestPipeline === null;
    },
P
Phil Hughes 已提交
39
  },
P
Phil Hughes 已提交
40
  created() {
41
    this.fetchLatestPipeline();
P
Phil Hughes 已提交
42 43
  },
  methods: {
44
    ...mapActions('pipelines', ['fetchLatestPipeline']),
P
Phil Hughes 已提交
45 46 47 48 49
  },
};
</script>

<template>
P
Phil Hughes 已提交
50
  <div class="ide-pipeline">
C
Clement Ho 已提交
51
    <gl-loading-icon
52
      v-if="showLoadingIcon"
C
Clement Ho 已提交
53
      :size="2"
P
Phil Hughes 已提交
54 55
      class="prepend-top-default"
    />
56
    <template v-else-if="latestPipeline !== null">
P
Phil Hughes 已提交
57
      <header
58
        v-if="latestPipeline"
P
Phil Hughes 已提交
59 60 61
        class="ide-tree-header ide-pipeline-header"
      >
        <ci-icon
62
          :status="latestPipeline.details.status"
P
Phil Hughes 已提交
63
          :size="24"
P
Phil Hughes 已提交
64 65 66
        />
        <span class="prepend-left-8">
          <strong>
67
            {{ __('Pipeline') }}
P
Phil Hughes 已提交
68 69
          </strong>
          <a
P
Phil Hughes 已提交
70
            :href="latestPipeline.path"
P
Phil Hughes 已提交
71
            target="_blank"
P
Phil Hughes 已提交
72
            class="ide-external-link"
P
Phil Hughes 已提交
73 74
          >
            #{{ latestPipeline.id }}
P
Phil Hughes 已提交
75 76
            <icon
              :size="12"
77
              name="external-link"
P
Phil Hughes 已提交
78
            />
P
Phil Hughes 已提交
79 80 81
          </a>
        </span>
      </header>
82 83
      <empty-state
        v-if="latestPipeline === false"
84
        :help-page-path="links.ciHelpPagePath"
85 86 87 88 89 90 91 92
        :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">
93
          {{ __('Found errors in your .gitlab-ci.yml:') }}
94
        </p>
95
        <p class="append-bottom-0 break-word">
96 97 98 99 100 101 102 103 104 105 106
          {{ latestPipeline.yamlError }}
        </p>
        <p
          class="append-bottom-0"
          v-html="ciLintText"
        ></p>
      </div>
      <tabs
        v-else
        class="ide-pipeline-list"
      >
P
Phil Hughes 已提交
107 108 109
        <tab
          :active="!pipelineFailed"
        >
P
Phil Hughes 已提交
110
          <template slot="title">
111
            {{ __('Jobs') }}
P
Phil Hughes 已提交
112
            <span
113
              v-if="jobsCount"
P
Phil Hughes 已提交
114
              class="badge badge-pill"
P
Phil Hughes 已提交
115 116 117 118 119 120 121 122 123
            >
              {{ jobsCount }}
            </span>
          </template>
          <jobs-list
            :loading="isLoadingJobs"
            :stages="stages"
          />
        </tab>
P
Phil Hughes 已提交
124 125 126
        <tab
          :active="pipelineFailed"
        >
P
Phil Hughes 已提交
127
          <template slot="title">
128
            {{ __('Failed Jobs') }}
P
Phil Hughes 已提交
129
            <span
130
              v-if="failedJobsCount"
P
Phil Hughes 已提交
131
              class="badge badge-pill"
P
Phil Hughes 已提交
132 133 134 135 136 137 138 139 140 141
            >
              {{ failedJobsCount }}
            </span>
          </template>
          <jobs-list
            :loading="isLoadingJobs"
            :stages="failedStages"
          />
        </tab>
      </tabs>
P
Phil Hughes 已提交
142 143 144
    </template>
  </div>
</template>