gitlab-org--gitlab-foss/app/assets/javascripts/vue_shared/components/ci_badge_link.vue

64 lines
1.4 KiB
Vue
Raw Normal View History

2017-05-12 11:28:26 +00:00
<script>
2017-10-18 16:30:31 +00:00
import ciIcon from './ci_icon.vue';
import tooltip from '../directives/tooltip';
/**
* Renders CI Badge link with CI icon and status text 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 - first column
* - Jobs table - first column
* - Pipeline show view - header
* - Job show view - header
* - MR widget
*/
2017-05-12 11:28:26 +00:00
2017-10-18 16:30:31 +00:00
export default {
props: {
status: {
type: Object,
required: true,
},
showText: {
type: Boolean,
required: false,
default: true,
},
2017-05-12 11:28:26 +00:00
},
2017-10-18 16:30:31 +00:00
components: {
ciIcon,
},
directives: {
tooltip,
},
computed: {
cssClass() {
const className = this.status.group;
return className ? `ci-status ci-${className}` : 'ci-status';
},
2017-05-12 11:28:26 +00:00
},
2017-10-18 16:30:31 +00:00
};
2017-05-12 11:28:26 +00:00
</script>
<template>
<a
:href="status.details_path"
2017-10-18 16:30:31 +00:00
:class="cssClass"
v-tooltip
2017-10-23 13:36:02 +00:00
:title="!showText ? status.text : ''">
2017-05-12 11:28:26 +00:00
<ci-icon :status="status" />
2017-10-18 16:30:31 +00:00
<template v-if="showText">
{{status.text}}
</template>
2017-05-12 11:28:26 +00:00
</a>
</template>