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

135 lines
3.1 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-05-09 12:01:36 +05:30
import ActionComponent from './action_component.vue';
import JobNameComponent from './job_name_component.vue';
2019-02-15 15:39:39 +05:30
import { GlTooltipDirective, GlLink } from '@gitlab/ui';
2018-12-13 13:39:08 +05:30
import { sprintf } from '~/locale';
import delayedJobMixin from '~/jobs/mixins/delayed_job_mixin';
2018-05-09 12:01:36 +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": {
2018-11-18 11:00:15 +05:30
* "icon": "status_success",
2018-05-09 12:01:36 +05:30
* "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,
2019-02-15 15:39:39 +05:30
GlLink,
2018-05-09 12:01:36 +05:30
},
directives: {
2019-02-15 15:39:39 +05:30
GlTooltip: GlTooltipDirective,
2018-05-09 12:01:36 +05:30
},
2018-12-13 13:39:08 +05:30
mixins: [delayedJobMixin],
2018-05-09 12:01:36 +05:30
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-11-08 19:23:39 +05:30
dropdownLength: {
type: Number,
required: false,
default: Infinity,
},
2018-05-09 12:01:36 +05:30
},
computed: {
status() {
return this.job && this.job.status ? this.job.status : {};
},
tooltipText() {
const textBuilder = [];
2018-12-13 13:39:08 +05:30
const { name: jobName } = this.job;
2018-05-09 12:01:36 +05:30
2018-12-13 13:39:08 +05:30
if (jobName) {
textBuilder.push(jobName);
2018-05-09 12:01:36 +05:30
}
2018-12-13 13:39:08 +05:30
const { tooltip: statusTooltip } = this.status;
if (jobName && statusTooltip) {
2018-05-09 12:01:36 +05:30
textBuilder.push('-');
}
2018-12-13 13:39:08 +05:30
if (statusTooltip) {
if (this.isDelayedJob) {
textBuilder.push(sprintf(statusTooltip, { remainingTime: this.remainingTime }));
} else {
textBuilder.push(statusTooltip);
}
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">
2019-02-15 15:39:39 +05:30
<gl-link
2018-03-17 18:26:18 +05:30
v-if="status.has_details"
2019-02-15 15:39:39 +05:30
v-gl-tooltip
2018-03-17 18:26:18 +05:30
:href="status.details_path"
2017-08-17 22:00:37 +05:30
:title="tooltipText"
:class="cssClassJobName"
2018-03-17 18:26:18 +05:30
class="js-pipeline-graph-job-link"
>
2019-02-15 15:39:39 +05:30
<job-name-component :name="job.name" :status="job.status" />
</gl-link>
2017-08-17 22:00:37 +05:30
<div
2018-11-08 19:23:39 +05:30
v-else
2019-02-15 15:39:39 +05:30
v-gl-tooltip
2017-08-17 22:00:37 +05:30
:title="tooltipText"
:class="cssClassJobName"
2018-11-08 19:23:39 +05:30
class="js-job-component-tooltip non-details-job-component"
2018-03-17 18:26:18 +05:30
>
2019-02-15 15:39:39 +05:30
<job-name-component :name="job.name" :status="job.status" />
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>