summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/ci_icon.vue
blob: 03f924ba99dc6beb17e198db0a1ab4e3d01ec12a (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
<script>
import Icon from '../../vue_shared/components/icon.vue';

/**
 * Renders CI icon based on API response shared between all places where it is used.
 *
 * Receives status object containing:
 * status: {
 *   details_path: "/gitlab-org/gitlab-ce/pipelines/8150156" // url
 *   group:"running" // used for CSS class
 *   icon: "icon_status_running" // used to render the icon
 *   label:"running" // used for potential tooltip
 *   text:"running" // text rendered
 * }
 *
 * Used in:
 * - Pipelines table Badge
 * - Pipelines table mini graph
 * - Pipeline graph
 * - Pipeline show view badge
 * - Jobs table
 * - Jobs show view header
 * - Jobs show view sidebar
 */
const validSizes = [8, 12, 16, 18, 24, 32, 48, 72];

export default {
  components: {
    Icon,
  },
  props: {
    status: {
      type: Object,
      required: true,
    },
    size: {
      type: Number,
      required: false,
      default: 16,
      validator(value) {
        return validSizes.includes(value);
      },
    },
    borderless: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  computed: {
    cssClass() {
      const status = this.status.group;
      return `ci-status-icon ci-status-icon-${status} js-ci-status-icon-${status}`;
    },
    icon() {
      return this.borderless ? `${this.status.icon}_borderless` : this.status.icon;
    },
  },
};
</script>
<template>
  <span :class="cssClass">
    <icon
      :name="icon"
      :size="size"
    />
  </span>
</template>