2017-08-17 22:00:37 +05:30
|
|
|
<script>
|
2018-10-15 14:42:47 +05:30
|
|
|
import _ from 'underscore';
|
2018-05-09 12:01:36 +05:30
|
|
|
import ActionComponent from './action_component.vue';
|
|
|
|
import JobNameComponent from './job_name_component.vue';
|
|
|
|
import tooltip from '../../../vue_shared/directives/tooltip';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the badge for the pipeline graph and the job's dropdown.
|
|
|
|
*
|
|
|
|
* The following object should be provided as `job`:
|
|
|
|
*
|
|
|
|
* {
|
|
|
|
* "id": 4256,
|
|
|
|
* "name": "test",
|
|
|
|
* "status": {
|
|
|
|
* "icon": "icon_status_success",
|
|
|
|
* "text": "passed",
|
|
|
|
* "label": "passed",
|
|
|
|
* "group": "success",
|
|
|
|
* "tooltip": "passed",
|
|
|
|
* "details_path": "/root/ci-mock/builds/4256",
|
|
|
|
* "action": {
|
|
|
|
* "icon": "retry",
|
|
|
|
* "title": "Retry",
|
|
|
|
* "path": "/root/ci-mock/builds/4256/retry",
|
|
|
|
* "method": "post"
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
ActionComponent,
|
|
|
|
JobNameComponent,
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
tooltip,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
job: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
cssClassJobName: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
status() {
|
|
|
|
return this.job && this.job.status ? this.job.status : {};
|
|
|
|
},
|
|
|
|
|
|
|
|
tooltipText() {
|
|
|
|
const textBuilder = [];
|
|
|
|
|
|
|
|
if (this.job.name) {
|
2018-10-15 14:42:47 +05:30
|
|
|
textBuilder.push(_.escape(this.job.name));
|
2018-05-09 12:01:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
if (this.job.name && this.status.tooltip) {
|
|
|
|
textBuilder.push('-');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.status.tooltip) {
|
2018-10-15 14:42:47 +05:30
|
|
|
textBuilder.push(this.job.status.tooltip);
|
2018-05-09 12:01:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return textBuilder.join(' ');
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
/**
|
|
|
|
* Verifies if the provided job has an action path
|
|
|
|
*
|
|
|
|
* @return {Boolean}
|
|
|
|
*/
|
|
|
|
hasAction() {
|
|
|
|
return this.job.status && this.job.status.action && this.job.status.action.path;
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
methods: {
|
|
|
|
pipelineActionRequestComplete() {
|
|
|
|
this.$emit('pipelineActionRequestComplete');
|
|
|
|
},
|
|
|
|
},
|
2018-05-09 12:01:36 +05:30
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
</script>
|
|
|
|
<template>
|
2018-03-17 18:26:18 +05:30
|
|
|
<div class="ci-job-component">
|
2017-08-17 22:00:37 +05:30
|
|
|
<a
|
2017-09-10 17:25:29 +05:30
|
|
|
v-tooltip
|
2018-03-17 18:26:18 +05:30
|
|
|
v-if="status.has_details"
|
|
|
|
:href="status.details_path"
|
2017-08-17 22:00:37 +05:30
|
|
|
:title="tooltipText"
|
|
|
|
:class="cssClassJobName"
|
2018-03-17 18:26:18 +05:30
|
|
|
data-container="body"
|
2018-05-09 12:01:36 +05:30
|
|
|
data-html="true"
|
2018-03-17 18:26:18 +05:30
|
|
|
class="js-pipeline-graph-job-link"
|
|
|
|
>
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
<job-name-component
|
|
|
|
:name="job.name"
|
|
|
|
:status="job.status"
|
2018-03-17 18:26:18 +05:30
|
|
|
/>
|
2017-08-17 22:00:37 +05:30
|
|
|
</a>
|
|
|
|
|
|
|
|
<div
|
|
|
|
v-else
|
2017-09-10 17:25:29 +05:30
|
|
|
v-tooltip
|
2018-10-15 14:42:47 +05:30
|
|
|
class="js-job-component-tooltip non-details-job-component"
|
2017-08-17 22:00:37 +05:30
|
|
|
:title="tooltipText"
|
|
|
|
:class="cssClassJobName"
|
2018-05-09 12:01:36 +05:30
|
|
|
data-html="true"
|
2018-03-17 18:26:18 +05:30
|
|
|
data-container="body"
|
|
|
|
>
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
<job-name-component
|
|
|
|
:name="job.name"
|
|
|
|
:status="job.status"
|
2018-03-17 18:26:18 +05:30
|
|
|
/>
|
2017-08-17 22:00:37 +05:30
|
|
|
</div>
|
|
|
|
|
|
|
|
<action-component
|
2018-10-15 14:42:47 +05:30
|
|
|
v-if="hasAction"
|
2018-03-17 18:26:18 +05:30
|
|
|
:tooltip-text="status.action.title"
|
|
|
|
:link="status.action.path"
|
|
|
|
:action-icon="status.action.icon"
|
2018-10-15 14:42:47 +05:30
|
|
|
@pipelineActionRequestComplete="pipelineActionRequestComplete"
|
2018-03-17 18:26:18 +05:30
|
|
|
/>
|
2017-08-17 22:00:37 +05:30
|
|
|
</div>
|
|
|
|
</template>
|