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

69 lines
1.5 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-10-15 14:42:47 +05:30
import Icon from '../../vue_shared/components/icon.vue';
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: {
* 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
*/
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: {
Icon,
},
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,
},
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>
2018-03-17 18:26:18 +05:30
<span :class="cssClass">
2018-11-08 19:23:39 +05:30
<icon
:name="icon"
:size="size"
/>
2017-08-17 22:00:37 +05:30
</span>
</template>