summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/environments/components/deployment_status_badge.vue
blob: 5a026911766499f5ec0cc095f3b496824f0c3368 (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
<script>
import { GlBadge } from '@gitlab/ui';
import { s__ } from '~/locale';

const STATUS_TEXT = {
  created: s__('Deployment|Created'),
  running: s__('Deployment|Running'),
  success: s__('Deployment|Success'),
  failed: s__('Deployment|Failed'),
  canceled: s__('Deployment|Cancelled'),
  skipped: s__('Deployment|Skipped'),
  blocked: s__('Deployment|Waiting'),
};

const STATUS_VARIANT = {
  success: 'success',
  running: 'info',
  failed: 'danger',
  created: 'neutral',
  canceled: 'neutral',
  skipped: 'neutral',
  blocked: 'neutral',
};

const STATUS_ICON = {
  success: 'status_success',
  running: 'status_running',
  failed: 'status_failed',
  created: 'status_created',
  canceled: 'status_canceled',
  skipped: 'status_skipped',
  blocked: 'status_manual',
};

export default {
  components: {
    GlBadge,
  },
  props: {
    status: {
      type: String,
      required: true,
    },
  },
  computed: {
    icon() {
      return STATUS_ICON[this.status];
    },
    text() {
      return STATUS_TEXT[this.status];
    },
    variant() {
      return STATUS_VARIANT[this.status];
    },
  },
};
</script>
<template>
  <gl-badge v-if="status" :icon="icon" :variant="variant">{{ text }}</gl-badge>
</template>