summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/reports/components/issue_status_icon.vue
blob: 386653b94448646bcb77e97cf1cd3c89a0e4151e (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
<script>
import Icon from '~/vue_shared/components/icon.vue';
import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '../constants';

export default {
  name: 'IssueStatusIcon',
  components: {
    Icon,
  },
  props: {
    // failed || success
    status: {
      type: String,
      required: true,
    },
    statusIconSize: {
      type: Number,
      required: false,
      default: 24,
    },
  },
  computed: {
    iconName() {
      if (this.isStatusFailed) {
        return 'status_failed_borderless';
      } else if (this.isStatusSuccess) {
        return 'status_success_borderless';
      }

      return 'status_created_borderless';
    },
    isStatusFailed() {
      return this.status === STATUS_FAILED;
    },
    isStatusSuccess() {
      return this.status === STATUS_SUCCESS;
    },
    isStatusNeutral() {
      return this.status === STATUS_NEUTRAL;
    },
  },
};
</script>
<template>
  <div
    :class="{
      failed: isStatusFailed,
      success: isStatusSuccess,
      neutral: isStatusNeutral,
    }"
    class="report-block-list-icon"
  >
    <icon :name="iconName" :size="statusIconSize" />
  </div>
</template>