list.vue 3.3 KB
Newer Older
P
Phil Hughes 已提交
1
<script>
P
Phil Hughes 已提交
2
import { mapActions, mapGetters, mapState } from 'vuex';
3
import _ from 'underscore';
C
Clement Ho 已提交
4
import { GlLoadingIcon } from '@gitlab/ui';
5
import { sprintf, __ } from '../../../locale';
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

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

<template>
P
Phil Hughes 已提交
58
  <div class="ide-pipeline">
M
Mike Greiling 已提交
59
    <gl-loading-icon v-if="showLoadingIcon" :size="2" class="prepend-top-default" />
60
    <template v-else-if="hasLoadedPipeline">
M
Mike Greiling 已提交
61 62
      <header v-if="latestPipeline" class="ide-tree-header ide-pipeline-header">
        <ci-icon :status="latestPipeline.details.status" :size="24" />
P
Phil Hughes 已提交
63
        <span class="prepend-left-8">
M
Mike Greiling 已提交
64 65 66
          <strong> {{ __('Pipeline') }} </strong>
          <a :href="latestPipeline.path" target="_blank" class="ide-external-link">
            #{{ latestPipeline.id }} <icon :size="12" name="external-link" />
P
Phil Hughes 已提交
67 68 69
          </a>
        </span>
      </header>
70
      <empty-state
71
        v-if="!latestPipeline"
72
        :help-page-path="links.ciHelpPagePath"
73 74 75
        :empty-state-svg-path="pipelinesEmptyStateSvgPath"
        :can-set-ci="true"
      />
M
Mike Greiling 已提交
76 77 78 79
      <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>
80
      </div>
M
Mike Greiling 已提交
81 82
      <tabs v-else class="ide-pipeline-list">
        <tab :active="!pipelineFailed">
P
Phil Hughes 已提交
83
          <template slot="title">
84
            {{ __('Jobs') }}
M
Mike Greiling 已提交
85
            <span v-if="jobsCount" class="badge badge-pill"> {{ jobsCount }} </span>
P
Phil Hughes 已提交
86
          </template>
M
Mike Greiling 已提交
87
          <jobs-list :loading="isLoadingJobs" :stages="stages" />
P
Phil Hughes 已提交
88
        </tab>
M
Mike Greiling 已提交
89
        <tab :active="pipelineFailed">
P
Phil Hughes 已提交
90
          <template slot="title">
91
            {{ __('Failed Jobs') }}
M
Mike Greiling 已提交
92
            <span v-if="failedJobsCount" class="badge badge-pill"> {{ failedJobsCount }} </span>
P
Phil Hughes 已提交
93
          </template>
M
Mike Greiling 已提交
94
          <jobs-list :loading="isLoadingJobs" :stages="failedStages" />
P
Phil Hughes 已提交
95 96
        </tab>
      </tabs>
P
Phil Hughes 已提交
97 98 99
    </template>
  </div>
</template>