diff options
-rw-r--r-- | app/assets/javascripts/pipeline.js.es6 | 20 | ||||
-rw-r--r-- | app/views/projects/commit/_pipeline.html.haml | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/app/assets/javascripts/pipeline.js.es6 b/app/assets/javascripts/pipeline.js.es6 index ae7369004de..bf33eb10100 100644 --- a/app/assets/javascripts/pipeline.js.es6 +++ b/app/assets/javascripts/pipeline.js.es6 @@ -1,13 +1,15 @@ -function toggleGraph() { - const indexOfBtn = $('.toggle-pipeline-btn').index($(this)); +(function() { + function 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'); - $($('.pipeline-graph')[indexOfBtn]).toggleClass('graph-collapsed'); - $($('.toggle-pipeline-btn')[indexOfBtn]).toggleClass('graph-collapsed'); + $($pipelineBtn).add($pipelineGraph).toggleClass('graph-collapsed'); - const $btnText = $($('.toggle-pipeline-btn .btn-text')[indexOfBtn]); - const graphCollapsed = $($('.pipeline-graph')[indexOfBtn]).hasClass('graph-collapsed'); + const graphCollapsed = $pipelineGraph.hasClass('graph-collapsed'); - graphCollapsed ? $btnText.text('Expand') : $btnText.text('Hide') -} + graphCollapsed ? $btnText.text('Expand') : $btnText.text('Hide') + } -$(document).on('click', '.toggle-pipeline-btn', toggleGraph); + $(document).on('click', '.toggle-pipeline-btn', toggleGraph); +})(); diff --git a/app/views/projects/commit/_pipeline.html.haml b/app/views/projects/commit/_pipeline.html.haml index 9fa54057823..20a85148ab5 100644 --- a/app/views/projects/commit/_pipeline.html.haml +++ b/app/views/projects/commit/_pipeline.html.haml @@ -1,7 +1,7 @@ .row-content-block.build-content.middle-block.pipeline-actions .pull-right .btn.btn-grouped.btn-white.toggle-pipeline-btn - %span.btn-text Hide + %span.toggle-btn-text Hide %span pipeline graph %span.caret - if can?(current_user, :update_pipeline, pipeline.project) |