Commit 17039d83 authored by Sarah Groff Hennigh-Palermo's avatar Sarah Groff Hennigh-Palermo

Merge branch '239446-pipeline-graph-layout' into 'master'

Leverage CSS vs. JS for pipeline padding

See merge request gitlab-org/gitlab!46914
parents 8149d7b5 778e4c9a
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { escape, capitalize } from 'lodash'; import { escape, capitalize } from 'lodash';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import StageColumnComponentLegacy from './stage_column_component_legacy.vue'; import StageColumnComponentLegacy from './stage_column_component_legacy.vue';
import GraphWidthMixin from '../../mixins/graph_width_mixin';
import LinkedPipelinesColumnLegacy from './linked_pipelines_column_legacy.vue'; import LinkedPipelinesColumnLegacy from './linked_pipelines_column_legacy.vue';
import GraphBundleMixin from '../../mixins/graph_pipeline_bundle_mixin'; import GraphBundleMixin from '../../mixins/graph_pipeline_bundle_mixin';
import { UPSTREAM, DOWNSTREAM, MAIN } from './constants'; import { UPSTREAM, DOWNSTREAM, MAIN } from './constants';
...@@ -14,7 +13,7 @@ export default { ...@@ -14,7 +13,7 @@ export default {
LinkedPipelinesColumnLegacy, LinkedPipelinesColumnLegacy,
StageColumnComponentLegacy, StageColumnComponentLegacy,
}, },
mixins: [GraphWidthMixin, GraphBundleMixin], mixins: [GraphBundleMixin],
props: { props: {
isLoading: { isLoading: {
type: Boolean, type: Boolean,
...@@ -183,87 +182,83 @@ export default { ...@@ -183,87 +182,83 @@ export default {
class="pipeline-visualization pipeline-graph" class="pipeline-visualization pipeline-graph"
:class="{ 'pipeline-tab-content': !isLinkedPipeline }" :class="{ 'pipeline-tab-content': !isLinkedPipeline }"
> >
<div <div class="gl-w-full">
:style="{ <div class="container-fluid container-limited">
paddingLeft: `${graphLeftPadding}px`, <gl-loading-icon v-if="isLoading" class="m-auto" size="lg" />
paddingRight: `${graphRightPadding}px`, <pipeline-graph-legacy
}" v-if="pipelineTypeUpstream"
> :type="$options.upstream"
<gl-loading-icon v-if="isLoading" class="m-auto" size="lg" /> class="d-inline-block upstream-pipeline"
:class="`js-upstream-pipeline-${expandedUpstream.id}`"
<pipeline-graph-legacy :is-loading="false"
v-if="pipelineTypeUpstream" :pipeline="expandedUpstream"
:type="$options.upstream" :is-linked-pipeline="true"
class="d-inline-block upstream-pipeline" :mediator="mediator"
:class="`js-upstream-pipeline-${expandedUpstream.id}`" @onClickUpstreamPipeline="clickUpstreamPipeline"
:is-loading="false" @refreshPipelineGraph="requestRefreshPipelineGraph"
:pipeline="expandedUpstream" />
:is-linked-pipeline="true"
:mediator="mediator"
@onClickUpstreamPipeline="clickUpstreamPipeline"
@refreshPipelineGraph="requestRefreshPipelineGraph"
/>
<linked-pipelines-column-legacy <linked-pipelines-column-legacy
v-if="hasUpstream" v-if="hasUpstream"
:type="$options.upstream" :type="$options.upstream"
:linked-pipelines="upstreamPipelines" :linked-pipelines="upstreamPipelines"
:column-title="__('Upstream')" :column-title="__('Upstream')"
:project-id="pipelineProjectId" :project-id="pipelineProjectId"
@linkedPipelineClick="$emit('onClickUpstreamPipeline', $event)" @linkedPipelineClick="$emit('onClickUpstreamPipeline', $event)"
/> />
<ul <ul
v-if="!isLoading" v-if="!isLoading"
:class="{
'inline js-has-linked-pipelines': hasDownstream || hasUpstream,
}"
class="stage-column-list align-top"
>
<stage-column-component-legacy
v-for="(stage, index) in graph"
:key="stage.name"
:class="{ :class="{
'has-upstream gl-ml-11': hasUpstreamColumn(index), 'inline js-has-linked-pipelines': hasDownstream || hasUpstream,
'has-only-one-job': hasOnlyOneJob(stage),
'gl-mr-26': shouldAddRightMargin(index),
}" }"
:title="capitalizeStageName(stage.name)" class="stage-column-list align-top"
:groups="stage.groups" >
:stage-connector-class="stageConnectorClass(index, stage)" <stage-column-component-legacy
:is-first-column="isFirstColumn(index)" v-for="(stage, index) in graph"
:has-upstream="hasUpstream" :key="stage.name"
:action="stage.status.action" :class="{
:job-hovered="jobName" 'has-upstream gl-ml-11': hasUpstreamColumn(index),
:pipeline-expanded="pipelineExpanded" 'has-only-one-job': hasOnlyOneJob(stage),
@refreshPipelineGraph="refreshPipelineGraph" 'gl-mr-26': shouldAddRightMargin(index),
/> }"
</ul> :title="capitalizeStageName(stage.name)"
:groups="stage.groups"
:stage-connector-class="stageConnectorClass(index, stage)"
:is-first-column="isFirstColumn(index)"
:has-upstream="hasUpstream"
:action="stage.status.action"
:job-hovered="jobName"
:pipeline-expanded="pipelineExpanded"
@refreshPipelineGraph="refreshPipelineGraph"
/>
</ul>
<linked-pipelines-column-legacy <linked-pipelines-column-legacy
v-if="hasDownstream" v-if="hasDownstream"
:type="$options.downstream" :type="$options.downstream"
:linked-pipelines="downstreamPipelines" :linked-pipelines="downstreamPipelines"
:column-title="__('Downstream')" :column-title="__('Downstream')"
:project-id="pipelineProjectId" :project-id="pipelineProjectId"
@linkedPipelineClick="handleClickedDownstream" @linkedPipelineClick="handleClickedDownstream"
@downstreamHovered="setJob" @downstreamHovered="setJob"
@pipelineExpandToggle="setPipelineExpanded" @pipelineExpandToggle="setPipelineExpanded"
/> />
<pipeline-graph-legacy <pipeline-graph-legacy
v-if="pipelineTypeDownstream" v-if="pipelineTypeDownstream"
:type="$options.downstream" :type="$options.downstream"
class="d-inline-block" class="d-inline-block"
:class="`js-downstream-pipeline-${expandedDownstream.id}`" :class="`js-downstream-pipeline-${expandedDownstream.id}`"
:is-loading="false" :is-loading="false"
:pipeline="expandedDownstream" :pipeline="expandedDownstream"
:is-linked-pipeline="true" :is-linked-pipeline="true"
:style="{ 'margin-top': downstreamMarginTop }" :style="{ 'margin-top': downstreamMarginTop }"
:mediator="mediator" :mediator="mediator"
@onClickDownstreamPipeline="clickDownstreamPipeline" @onClickDownstreamPipeline="clickDownstreamPipeline"
@refreshPipelineGraph="requestRefreshPipelineGraph" @refreshPipelineGraph="requestRefreshPipelineGraph"
/> />
</div>
</div> </div>
</div> </div>
</div> </div>
......
import { debounceByAnimationFrame } from '~/lib/utils/common_utils';
import { LAYOUT_CHANGE_DELAY } from '~/pipelines/constants';
export default {
debouncedResize: null,
sidebarMutationObserver: null,
data() {
return {
graphLeftPadding: 0,
graphRightPadding: 0,
};
},
beforeDestroy() {
window.removeEventListener('resize', this.$options.debouncedResize);
if (this.$options.sidebarMutationObserver) {
this.$options.sidebarMutationObserver.disconnect();
}
},
created() {
this.$options.debouncedResize = debounceByAnimationFrame(this.setGraphPadding);
window.addEventListener('resize', this.$options.debouncedResize);
},
mounted() {
this.setGraphPadding();
this.$options.sidebarMutationObserver = new MutationObserver(this.handleLayoutChange);
this.$options.sidebarMutationObserver.observe(document.querySelector('.layout-page'), {
attributes: true,
childList: false,
subtree: false,
});
},
methods: {
setGraphPadding() {
// only add padding to main graph (not inline upstream/downstream graphs)
if (this.type && this.type !== 'main') return;
const container = document.querySelector('.js-pipeline-container');
if (!container) return;
this.graphLeftPadding = container.offsetLeft;
this.graphRightPadding = window.innerWidth - container.offsetLeft - container.offsetWidth;
},
handleLayoutChange() {
// wait until animations finish, then recalculate padding
window.setTimeout(this.setGraphPadding, LAYOUT_CHANGE_DELAY);
},
},
};
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
= render_if_exists "projects/pipelines/tabs_holder", pipeline: @pipeline, project: @project = render_if_exists "projects/pipelines/tabs_holder", pipeline: @pipeline, project: @project
.tab-content .tab-content
#js-tab-pipeline.tab-pane.gl-absolute.gl-left-0.gl-w-full #js-tab-pipeline.tab-pane.gl-w-full
#js-pipeline-graph-vue #js-pipeline-graph-vue
#js-tab-builds.tab-pane #js-tab-builds.tab-pane
......
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