debian-mirror-gitlab/app/assets/javascripts/pipelines/components/graph/job_component.vue

144 lines
3.1 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
import actionComponent from './action_component.vue';
import dropdownActionComponent from './dropdown_action_component.vue';
import jobNameComponent from './job_name_component.vue';
2017-09-10 17:25:29 +05:30
import tooltip from '../../../vue_shared/directives/tooltip';
2017-08-17 22:00:37 +05:30
/**
* 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",
* "details_path": "/root/ci-mock/builds/4256",
* "action": {
2018-03-17 18:26:18 +05:30
* "icon": "retry",
2017-08-17 22:00:37 +05:30
* "title": "Retry",
* "path": "/root/ci-mock/builds/4256/retry",
* "method": "post"
* }
* }
* }
*/
export default {
2018-03-17 18:26:18 +05:30
components: {
actionComponent,
dropdownActionComponent,
jobNameComponent,
},
directives: {
tooltip,
},
2017-08-17 22:00:37 +05:30
props: {
job: {
type: Object,
required: true,
},
cssClassJobName: {
type: String,
required: false,
default: '',
},
isDropdown: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
2018-03-17 18:26:18 +05:30
status() {
return this.job && this.job.status ? this.job.status : {};
},
2017-08-17 22:00:37 +05:30
tooltipText() {
2018-03-17 18:26:18 +05:30
const textBuilder = [];
if (this.job.name) {
textBuilder.push(this.job.name);
}
if (this.job.name && this.status.label) {
textBuilder.push('-');
}
if (this.status.label) {
textBuilder.push(`${this.job.status.label}`);
}
return textBuilder.join(' ');
2017-08-17 22:00:37 +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;
},
},
};
</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"
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-03-17 18:26:18 +05:30
class="js-job-component-tooltip"
2017-08-17 22:00:37 +05:30
:title="tooltipText"
:class="cssClassJobName"
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
v-if="hasAction && !isDropdown"
2018-03-17 18:26:18 +05:30
:tooltip-text="status.action.title"
:link="status.action.path"
:action-icon="status.action.icon"
:action-method="status.action.method"
/>
2017-08-17 22:00:37 +05:30
<dropdown-action-component
v-if="hasAction && isDropdown"
2018-03-17 18:26:18 +05:30
:tooltip-text="status.action.title"
:link="status.action.path"
:action-icon="status.action.icon"
:action-method="status.action.method"
/>
2017-08-17 22:00:37 +05:30
</div>
</template>