jobs_container.vue 1.55 KB
Newer Older
1
<script>
2
  import _ from 'underscore';
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  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,
      },
20 21 22 23 24 25 26 27 28 29 30 31
      jobId: {
        type: Number,
        required: true,
      },
    },
    methods: {
      isJobActive(currentJobId) {
        return this.jobId === currentJobId;
      },
      tooltipText(job) {
        return `${_.escape(job.name)} - ${job.status.tooltip}`;
      },
32 33 34 35
    },
  };
</script>
<template>
36
  <div class="js-jobs-container builds-container">
37
    <div
38 39
      v-for="job in jobs"
      :key="job.id"
40
      class="build-job"
41
      :class="{ retried: job.retried, active: isJobActive(job.id) }"
42 43
    >
      <a
44
        v-tooltip
45 46 47
        :href="job.status.details_path"
        :title="tooltipText(job)"
        data-container="body"
48 49
      >
        <icon
50
          v-if="isJobActive(job.id)"
51
          name="arrow-right"
52
          class="js-arrow-right icon-arrow-right"
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
        />

        <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>