Commit a82bcc89 authored by Sarah Groff Hennigh-Palermo's avatar Sarah Groff Hennigh-Palermo Committed by Scott Hampton

Pipeline Graph: Scroll downstream pipeline into view on load

parent 933a0b75
...@@ -2,5 +2,11 @@ export const DOWNSTREAM = 'downstream'; ...@@ -2,5 +2,11 @@ export const DOWNSTREAM = 'downstream';
export const MAIN = 'main'; export const MAIN = 'main';
export const UPSTREAM = 'upstream'; export const UPSTREAM = 'upstream';
/*
this value is based on the gl-pipeline-job-width class
plus some extra for the margins
*/
export const ONE_COL_WIDTH = 180;
export const REST = 'rest'; export const REST = 'rest';
export const GRAPHQL = 'graphql'; export const GRAPHQL = 'graphql';
...@@ -3,7 +3,7 @@ import LinkedGraphWrapper from '../graph_shared/linked_graph_wrapper.vue'; ...@@ -3,7 +3,7 @@ import LinkedGraphWrapper from '../graph_shared/linked_graph_wrapper.vue';
import LinksLayer from '../graph_shared/links_layer.vue'; import LinksLayer from '../graph_shared/links_layer.vue';
import LinkedPipelinesColumn from './linked_pipelines_column.vue'; import LinkedPipelinesColumn from './linked_pipelines_column.vue';
import StageColumnComponent from './stage_column_component.vue'; import StageColumnComponent from './stage_column_component.vue';
import { DOWNSTREAM, MAIN, UPSTREAM } from './constants'; import { DOWNSTREAM, MAIN, UPSTREAM, ONE_COL_WIDTH } from './constants';
import { reportToSentry } from './utils'; import { reportToSentry } from './utils';
export default { export default {
...@@ -101,6 +101,13 @@ export default { ...@@ -101,6 +101,13 @@ export default {
setJob(jobName) { setJob(jobName) {
this.hoveredJobName = jobName; this.hoveredJobName = jobName;
}, },
slidePipelineContainer() {
this.$refs.mainPipelineContainer.scrollBy({
left: ONE_COL_WIDTH,
top: 0,
behavior: 'smooth',
});
},
togglePipelineExpanded(jobName, expanded) { togglePipelineExpanded(jobName, expanded) {
this.pipelineExpanded = { this.pipelineExpanded = {
expanded, expanded,
...@@ -116,6 +123,7 @@ export default { ...@@ -116,6 +123,7 @@ export default {
<template> <template>
<div class="js-pipeline-graph"> <div class="js-pipeline-graph">
<div <div
ref="mainPipelineContainer"
class="gl-display-flex gl-position-relative gl-bg-gray-10 gl-white-space-nowrap" class="gl-display-flex gl-position-relative gl-bg-gray-10 gl-white-space-nowrap"
:class="{ 'gl-pipeline-min-h gl-py-5 gl-overflow-auto': !isLinkedPipeline }" :class="{ 'gl-pipeline-min-h gl-py-5 gl-overflow-auto': !isLinkedPipeline }"
> >
...@@ -165,6 +173,7 @@ export default { ...@@ -165,6 +173,7 @@ export default {
:type="$options.pipelineTypeConstants.DOWNSTREAM" :type="$options.pipelineTypeConstants.DOWNSTREAM"
@downstreamHovered="setJob" @downstreamHovered="setJob"
@pipelineExpandToggle="togglePipelineExpanded" @pipelineExpandToggle="togglePipelineExpanded"
@scrollContainer="slidePipelineContainer"
@error="onError" @error="onError"
/> />
</template> </template>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import getPipelineDetails from 'shared_queries/pipelines/get_pipeline_details.query.graphql'; import getPipelineDetails from 'shared_queries/pipelines/get_pipeline_details.query.graphql';
import LinkedPipeline from './linked_pipeline.vue'; import LinkedPipeline from './linked_pipeline.vue';
import { LOAD_FAILURE } from '../../constants'; import { LOAD_FAILURE } from '../../constants';
import { UPSTREAM } from './constants'; import { ONE_COL_WIDTH, UPSTREAM } from './constants';
import { unwrapPipelineData, toggleQueryPollingByVisibility, reportToSentry } from './utils'; import { unwrapPipelineData, toggleQueryPollingByVisibility, reportToSentry } from './utils';
export default { export default {
...@@ -28,6 +28,7 @@ export default { ...@@ -28,6 +28,7 @@ export default {
return { return {
currentPipeline: null, currentPipeline: null,
loadingPipelineId: null, loadingPipelineId: null,
minWidth: 0,
pipelineExpanded: false, pipelineExpanded: false,
}; };
}, },
...@@ -79,6 +80,7 @@ export default { ...@@ -79,6 +80,7 @@ export default {
}, },
result() { result() {
this.loadingPipelineId = null; this.loadingPipelineId = null;
this.$emit('scrollContainer');
}, },
error(err, _vm, _key, type) { error(err, _vm, _key, type) {
this.$emit('error', LOAD_FAILURE); this.$emit('error', LOAD_FAILURE);
...@@ -103,6 +105,7 @@ export default { ...@@ -103,6 +105,7 @@ export default {
if (this.currentPipeline?.id === pipeline.id) { if (this.currentPipeline?.id === pipeline.id) {
this.pipelineExpanded = false; this.pipelineExpanded = false;
this.currentPipeline = null; this.currentPipeline = null;
this.minWidth = 0;
return; return;
} }
...@@ -117,6 +120,11 @@ export default { ...@@ -117,6 +120,11 @@ export default {
*/ */
this.pipelineExpanded = true; this.pipelineExpanded = true;
/*
Min-width is set manually for timing reasons.
*/
this.minWidth = `${ONE_COL_WIDTH}px`;
this.getPipelineData(pipeline); this.getPipelineData(pipeline);
}, },
onDownstreamHovered(jobName) { onDownstreamHovered(jobName) {
...@@ -158,7 +166,11 @@ export default { ...@@ -158,7 +166,11 @@ export default {
@pipelineClicked="onPipelineClick(pipeline)" @pipelineClicked="onPipelineClick(pipeline)"
@pipelineExpandToggle="onPipelineExpandToggle" @pipelineExpandToggle="onPipelineExpandToggle"
/> />
<div v-if="isExpanded(pipeline.id)" class="gl-display-inline-block"> <div
v-if="isExpanded(pipeline.id) && !isUpstream"
:style="{ minWidth }"
class="gl-display-inline-block"
>
<pipeline-graph <pipeline-graph
v-if="currentPipeline" v-if="currentPipeline"
:type="type" :type="type"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment