summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs/components/jobs_container.vue
blob: 03f36ec5c8bd115b0f6d7a4704b5f7ffecfb2a6e (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 _ from 'underscore';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
import Icon from '~/vue_shared/components/icon.vue';
import tooltip from '~/vue_shared/directives/tooltip';

export default {
  components: {
    CiIcon,
    Icon,
  },
  directives: {
    tooltip,
  },
  props: {
    jobs: {
      type: Array,
      required: true,
    },
    jobId: {
      type: Number,
      required: true,
    },
  },
  methods: {
    isJobActive(currentJobId) {
      return this.jobId === currentJobId;
    },
    tooltipText(job) {
      return `${_.escape(job.name)} - ${job.status.tooltip}`;
    },
  },
};
</script>
<template>
  <div class="js-jobs-container builds-container">
    <div
      v-for="job in jobs"
      :key="job.id"
      class="build-job"
      :class="{ retried: job.retried, active: isJobActive(job.id) }"
    >
      <a
        v-tooltip
        :href="job.status.details_path"
        :title="tooltipText(job)"
        data-container="body"
      >
        <icon
          v-if="isJobActive(job.id)"
          name="arrow-right"
          class="js-arrow-right icon-arrow-right"
        />

        <ci-icon :status="job.status" />

        <span>
          <template v-if="job.name">
            {{ job.name }}
          </template>
          <template v-else>
            {{ job.id }}
          </template>
        </span>

        <icon
          v-if="job.retried"
          name="retry"
          class="js-retry-icon"
        />
      </a>
    </div>
  </div>
</template>