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

121 lines
3.3 KiB
Vue
Raw Normal View History

2019-12-21 20:55:43 +05:30
<script>
2020-04-22 19:07:51 +05:30
import { GlLoadingIcon, GlTooltipDirective, GlDeprecatedButton } from '@gitlab/ui';
2019-12-21 20:55:43 +05:30
import CiStatus from '~/vue_shared/components/ci_icon.vue';
2020-07-28 23:09:34 +05:30
import { __, sprintf } from '~/locale';
2019-12-21 20:55:43 +05:30
export default {
directives: {
GlTooltip: GlTooltipDirective,
},
components: {
CiStatus,
GlLoadingIcon,
2020-04-22 19:07:51 +05:30
GlDeprecatedButton,
2019-12-21 20:55:43 +05:30
},
props: {
pipeline: {
type: Object,
required: true,
},
2020-03-13 15:44:24 +05:30
projectId: {
type: Number,
required: true,
},
columnTitle: {
type: String,
required: true,
},
2019-12-21 20:55:43 +05:30
},
computed: {
tooltipText() {
2020-07-28 23:09:34 +05:30
return `${this.downstreamTitle} #${this.pipeline.id} - ${this.pipelineStatus.label}
${this.sourceJobInfo}`;
2019-12-21 20:55:43 +05:30
},
buttonId() {
return `js-linked-pipeline-${this.pipeline.id}`;
},
pipelineStatus() {
return this.pipeline.details.status;
},
projectName() {
return this.pipeline.project.name;
},
2020-07-28 23:09:34 +05:30
downstreamTitle() {
return this.childPipeline ? __('child-pipeline') : this.pipeline.project.name;
},
2020-03-13 15:44:24 +05:30
parentPipeline() {
// Refactor string match when BE returns Upstream/Downstream indicators
return this.projectId === this.pipeline.project.id && this.columnTitle === __('Upstream');
},
childPipeline() {
// Refactor string match when BE returns Upstream/Downstream indicators
2020-07-28 23:09:34 +05:30
return this.projectId === this.pipeline.project.id && this.isDownstream;
2020-03-13 15:44:24 +05:30
},
label() {
2020-07-28 23:09:34 +05:30
if (this.parentPipeline) {
return __('Parent');
} else if (this.childPipeline) {
return __('Child');
}
return __('Multi-project');
2020-03-13 15:44:24 +05:30
},
2020-07-28 23:09:34 +05:30
isDownstream() {
return this.columnTitle === __('Downstream');
2020-03-13 15:44:24 +05:30
},
2020-07-28 23:09:34 +05:30
sourceJobInfo() {
return this.isDownstream
? sprintf(__('Created by %{job}'), { job: this.pipeline.source_job.name })
: '';
2020-03-13 15:44:24 +05:30
},
2019-12-21 20:55:43 +05:30
},
methods: {
onClickLinkedPipeline() {
this.$root.$emit('bv::hide::tooltip', this.buttonId);
2020-03-13 15:44:24 +05:30
this.$emit('pipelineClicked', this.$refs.linkedPipeline);
},
hideTooltips() {
this.$root.$emit('bv::hide::tooltip');
2019-12-21 20:55:43 +05:30
},
2020-07-28 23:09:34 +05:30
onDownstreamHovered() {
this.$emit('downstreamHovered', this.pipeline.source_job.name);
},
onDownstreamHoverLeave() {
this.$emit('downstreamHovered', '');
},
2019-12-21 20:55:43 +05:30
},
};
</script>
<template>
2020-03-13 15:44:24 +05:30
<li
ref="linkedPipeline"
class="linked-pipeline build"
2020-07-28 23:09:34 +05:30
:class="{ 'downstream-pipeline': isDownstream }"
data-qa-selector="child_pipeline"
@mouseover="onDownstreamHovered"
@mouseleave="onDownstreamHoverLeave"
2020-03-13 15:44:24 +05:30
>
2020-04-22 19:07:51 +05:30
<gl-deprecated-button
2019-12-21 20:55:43 +05:30
:id="buttonId"
v-gl-tooltip
:title="tooltipText"
class="js-linked-pipeline-content linked-pipeline-content"
data-qa-selector="linked_pipeline_button"
:class="`js-pipeline-expand-${pipeline.id}`"
@click="onClickLinkedPipeline"
>
<gl-loading-icon v-if="pipeline.isLoading" class="js-linked-pipeline-loading d-inline" />
<ci-status
v-else
:status="pipelineStatus"
css-classes="position-top-0"
class="js-linked-pipeline-status"
/>
2020-07-28 23:09:34 +05:30
<span class="str-truncated"> {{ downstreamTitle }} &#8226; #{{ pipeline.id }} </span>
<div class="gl-pt-2">
<span class="badge badge-primary" data-testid="downstream-pipeline-label">{{ label }}</span>
2020-03-13 15:44:24 +05:30
</div>
2020-04-22 19:07:51 +05:30
</gl-deprecated-button>
2019-12-21 20:55:43 +05:30
</li>
</template>