summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ci/runner/components/runner_job_status_badge.vue
blob: bed592e3f304cff5d93c1654be852e65ebb24cf4 (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
<script>
import { GlBadge, GlTooltipDirective } from '@gitlab/ui';
import {
  I18N_JOB_STATUS_RUNNING,
  I18N_JOB_STATUS_IDLE,
  JOB_STATUS_RUNNING,
  JOB_STATUS_IDLE,
} from '../constants';

export default {
  components: {
    GlBadge,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    jobStatus: {
      required: false,
      default: null,
      type: String,
    },
  },
  computed: {
    badge() {
      switch (this.jobStatus) {
        case JOB_STATUS_RUNNING:
          return {
            classes: 'gl-text-blue-600! gl-border gl-border-blue-600!',
            label: I18N_JOB_STATUS_RUNNING,
          };
        case JOB_STATUS_IDLE:
          return {
            classes: 'gl-text-gray-700! gl-border gl-border-gray-500!',
            label: I18N_JOB_STATUS_IDLE,
          };
        default:
          return null;
      }
    },
  },
};
</script>
<template>
  <gl-badge
    v-if="badge"
    v-bind="$attrs"
    class="gl-display-inline-block gl-max-w-full gl-text-truncate gl-bg-transparent!"
    variant="muted"
    :class="badge.classes"
  >
    {{ badge.label }}
  </gl-badge>
</template>