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

65 lines
1.4 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-10-15 14:42:47 +05:30
import CiIcon from './ci_icon.vue';
2019-01-03 12:48:30 +05:30
import tooltip from '../directives/tooltip';
2018-10-15 14:42:47 +05:30
/**
* 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-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
export default {
components: {
CiIcon,
},
directives: {
2019-01-03 12:48:30 +05:30
tooltip,
2018-10-15 14:42:47 +05:30
},
props: {
status: {
type: Object,
required: true,
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
showText: {
type: Boolean,
required: false,
default: true,
2017-08-17 22:00:37 +05:30
},
2018-10-15 14:42:47 +05:30
},
computed: {
cssClass() {
const className = this.status.group;
2018-12-13 13:39:08 +05:30
return className ? `ci-status ci-${className} qa-status-badge` : 'ci-status qa-status-badge';
2018-03-17 18:26:18 +05:30
},
2018-10-15 14:42:47 +05:30
},
};
2017-08-17 22:00:37 +05:30
</script>
<template>
<a
2019-01-03 12:48:30 +05:30
v-tooltip
2017-08-17 22:00:37 +05:30
:href="status.details_path"
2018-03-17 18:26:18 +05:30
:class="cssClass"
:title="!showText ? status.text : ''"
>
2017-08-17 22:00:37 +05:30
<ci-icon :status="status" />
2018-03-17 18:26:18 +05:30
<template v-if="showText">
{{ status.text }}
</template>
2017-08-17 22:00:37 +05:30
</a>
</template>