list.vue 3.9 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 LoadingIcon from '../../../vue_shared/components/loading_icon.vue';
P
Phil Hughes 已提交
6
import Icon from '../../../vue_shared/components/icon.vue';
P
Phil Hughes 已提交
7
import CiIcon from '../../../vue_shared/components/ci_icon.vue';
P
Phil Hughes 已提交
8 9
import Tabs from '../../../vue_shared/components/tabs/tabs';
import Tab from '../../../vue_shared/components/tabs/tab.vue';
10
import EmptyState from '../../../pipelines/components/empty_state.vue';
P
Phil Hughes 已提交
11
import JobsList from '../jobs/list.vue';
P
Phil Hughes 已提交
12 13 14 15

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

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