Commit 5defad2d authored by Luke Bennett's avatar Luke Bennett Committed by Annabel Dunstone Gray

Finished up margin JS logic

parent eb55ac7d
...@@ -126,6 +126,9 @@ ...@@ -126,6 +126,9 @@
new TreeView(); new TreeView();
} }
break; break;
case 'projects:pipelines:show':
new window.gl.Pipelines();
break;
case 'groups:activity': case 'groups:activity':
new Activities(); new Activities();
break; break;
......
(function() { ((global) => {
function addMarginToBuild () { class Pipelines {
const $secondChildBuildNode = $('.build:nth-child(2)'); constructor() {
const $firstChildBuildNode = $secondChildBuildNode.prev('.build'); $(document).off('click', '.toggle-pipeline-btn').on('click', '.toggle-pipeline-btn', this.toggleGraph);
// const $previousBuildColumn = $secondChildBuildNode.closest('.stage-column').prev('.stage-column'); $(document).off('ready.addMarginToBuildColumns').on('ready.addMarginToBuildColumns', this.addMarginToBuildColumns);
if ($secondChildBuildNode.length) {
$secondChildBuildNode.closest('.stage-column').addClass('left-margin');
$firstChildBuildNode.addClass('left-connector');
} }
}
function toggleGraph() { toggleGraph() {
const $pipelineBtn = $(this).closest('.toggle-pipeline-btn'); const $pipelineBtn = $(this).closest('.toggle-pipeline-btn');
const $pipelineGraph = $(this).closest('.row-content-block').next('.pipeline-graph'); const $pipelineGraph = $(this).closest('.row-content-block').next('.pipeline-graph');
const $btnText = $(this).find('.toggle-btn-text'); const $btnText = $(this).find('.toggle-btn-text');
const $icon = $(this).find('.fa');
$($pipelineBtn).add($pipelineGraph).toggleClass('graph-collapsed'); $($pipelineBtn).add($pipelineGraph).toggleClass('graph-collapsed');
const graphCollapsed = $pipelineGraph.hasClass('graph-collapsed'); const graphCollapsed = $pipelineGraph.hasClass('graph-collapsed');
const expandIcon = 'fa-caret-down';
const hideIcon = 'fa-caret-up';
if(graphCollapsed) { graphCollapsed ? $btnText.text('Expand') : $btnText.text('Hide')
$btnText.text('Expand'); }
$icon.removeClass(hideIcon).addClass(expandIcon);
} else { addMarginToBuildColumns() {
$btnText.text('Hide'); const $secondChildBuildNode = $('.build:nth-child(2)');
$icon.removeClass(expandIcon).addClass(hideIcon); 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-container').removeClass('hidden');
} }
} }
$(document).on('click', '.toggle-pipeline-btn', toggleGraph); global.Pipelines = Pipelines;
$(document).on('ready', addMarginToBuild);
})(); })(window.gl || (window.gl = {}));
...@@ -326,6 +326,10 @@ ...@@ -326,6 +326,10 @@
} }
} }
&.no-margin {
margin: 0;
}
li { li {
list-style: none; list-style: none;
} }
......
.row-content-block.build-content.middle-block.pipeline-actions .pipeline-graph-container.hidden
.pull-right .row-content-block.build-content.middle-block.pipeline-actions
.btn.btn-grouped.btn-white.toggle-pipeline-btn .pull-right
%span.toggle-btn-text Hide .btn.btn-grouped.btn-white.toggle-pipeline-btn
%span pipeline graph %span.toggle-btn-text Hide
= icon('caret-up') %span pipeline graph
- if can?(current_user, :update_pipeline, pipeline.project) %span.caret
- if pipeline.builds.latest.failed.any?(&:retryable?) - if can?(current_user, :update_pipeline, pipeline.project)
= link_to "Retry failed", retry_namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), class: 'btn btn-grouped btn-primary', method: :post - if pipeline.builds.latest.failed.any?(&:retryable?)
= link_to "Retry failed", retry_namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), class: 'btn btn-grouped btn-primary', method: :post
- if pipeline.builds.running_or_pending.any? - if pipeline.builds.running_or_pending.any?
= link_to "Cancel running", cancel_namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), data: { confirm: 'Are you sure?' }, class: 'btn btn-grouped btn-danger', method: :post = link_to "Cancel running", cancel_namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), data: { confirm: 'Are you sure?' }, class: 'btn btn-grouped btn-danger', method: :post
.oneline.clearfix .oneline.clearfix
- if defined?(pipeline_details) && pipeline_details - if defined?(pipeline_details) && pipeline_details
Pipeline Pipeline
= link_to "##{pipeline.id}", namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), class: "monospace" = link_to "##{pipeline.id}", namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline.id), class: "monospace"
with with
= pluralize pipeline.statuses.count(:id), "build" = pluralize pipeline.statuses.count(:id), "build"
- if pipeline.ref - if pipeline.ref
for for
= link_to pipeline.ref, namespace_project_commits_path(pipeline.project.namespace, pipeline.project, pipeline.ref), class: "monospace" = link_to pipeline.ref, namespace_project_commits_path(pipeline.project.namespace, pipeline.project, pipeline.ref), class: "monospace"
- if defined?(link_to_commit) && link_to_commit - if defined?(link_to_commit) && link_to_commit
for commit for commit
= link_to pipeline.short_sha, namespace_project_commit_path(pipeline.project.namespace, pipeline.project, pipeline.sha), class: "monospace" = link_to pipeline.short_sha, namespace_project_commit_path(pipeline.project.namespace, pipeline.project, pipeline.sha), class: "monospace"
- if pipeline.duration - if pipeline.duration
in in
= time_interval_in_words pipeline.duration = time_interval_in_words pipeline.duration
.row-content-block.build-content.middle-block.pipeline-graph .row-content-block.build-content.middle-block.pipeline-graph
.pipeline-visualization .pipeline-visualization
%ul.stage-column-list %ul.stage-column-list
- stages = pipeline.stages_with_latest_statuses - stages = pipeline.stages_with_latest_statuses
- stages.each do |stage, statuses| - stages.each do |stage, statuses|
%li.stage-column %li.stage-column
.stage-name .stage-name
%a{name: stage} %a{name: stage}
- if stage - if stage
= stage.titleize = stage.titleize
.builds-container .builds-container
%ul %ul
= render "projects/commit/pipeline_stage", statuses: statuses = render "projects/commit/pipeline_stage", statuses: statuses
- if pipeline.yaml_errors.present? - if pipeline.yaml_errors.present?
......
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