gitlab-org--gitlab-foss/app/assets/javascripts/pipelines.js.es6

41 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-09-29 17:24:37 -04:00
((global) => {
class Pipelines {
constructor() {
$(document).off('click', '.toggle-pipeline-btn').on('click', '.toggle-pipeline-btn', this.toggleGraph);
this.addMarginToBuildColumns();
}
2016-09-29 17:24:37 -04:00
toggleGraph() {
const $pipelineBtn = $(this).closest('.toggle-pipeline-btn');
const $pipelineGraph = $(this).closest('.row-content-block').next('.pipeline-graph');
const $btnText = $(this).find('.toggle-btn-text');
2016-10-07 07:23:00 -04:00
const graphCollapsed = $pipelineGraph.hasClass('graph-collapsed');
2016-09-29 17:24:37 -04:00
$($pipelineBtn).add($pipelineGraph).toggleClass('graph-collapsed');
graphCollapsed ? $btnText.text('Hide') : $btnText.text('Expand')
2016-09-29 17:24:37 -04:00
}
addMarginToBuildColumns() {
const $secondChildBuildNode = $('.build:nth-child(2)');
if ($secondChildBuildNode.length) {
const $firstChildBuildNode = $secondChildBuildNode.prev('.build');
const $multiBuildColumn = $secondChildBuildNode.closest('.stage-column');
const $previousColumn = $multiBuildColumn.prev('.stage-column');
$multiBuildColumn.addClass('left-margin');
$firstChildBuildNode.addClass('left-connector');
$previousColumn.each(function() {
$this = $(this);
if ($('.build', $this).length === 1) $this.addClass('no-margin');
});
}
$('.pipeline-graph').removeClass('hidden');
}
2016-08-17 17:41:24 -04:00
}
2016-09-29 17:24:37 -04:00
global.Pipelines = Pipelines;
})(window.gl || (window.gl = {}));