debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/ci_icon.vue

70 lines
1.5 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlIcon } from '@gitlab/ui';
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
/**
* Renders CI icon based on API response shared between all places where it is used.
*
* Receives status object containing:
* status: {
* group:"running" // used for CSS class
* icon: "icon_status_running" // used to render the icon
* }
*
* 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
2019-07-07 11:18:12 +05:30
* - Linked pipelines
* - Extended MR Popover
2018-10-15 14:42:47 +05:30
*/
2018-11-08 19:23:39 +05:30
const validSizes = [8, 12, 16, 18, 24, 32, 48, 72];
2018-10-15 14:42:47 +05:30
export default {
components: {
2020-11-24 15:15:51 +05:30
GlIcon,
2018-10-15 14:42:47 +05:30
},
props: {
status: {
type: Object,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-11-08 19:23:39 +05:30
size: {
type: Number,
required: false,
default: 16,
validator(value) {
return validSizes.includes(value);
},
},
borderless: {
type: Boolean,
required: false,
default: false,
},
2019-07-07 11:18:12 +05:30
cssClasses: {
type: String,
required: false,
default: '',
},
2018-10-15 14:42:47 +05:30
},
computed: {
cssClass() {
const status = this.status.group;
return `ci-status-icon ci-status-icon-${status} js-ci-status-icon-${status}`;
2017-08-17 22:00:37 +05:30
},
2018-11-08 19:23:39 +05:30
icon() {
return this.borderless ? `${this.status.icon}_borderless` : this.status.icon;
},
2018-10-15 14:42:47 +05:30
},
};
2017-08-17 22:00:37 +05:30
</script>
<template>
2021-02-22 17:27:13 +05:30
<span :class="cssClass">
<gl-icon :name="icon" :size="size" :class="cssClasses" :aria-label="status.icon" />
</span>
2017-08-17 22:00:37 +05:30
</template>