summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnnabel Dunstone <annabel.dunstone@gmail.com>2016-08-17 16:41:24 -0500
committerAnnabel Dunstone <annabel.dunstone@gmail.com>2016-08-17 16:44:25 -0500
commit74f80465f6078b4a78ae2ebe4e367d4f1d7c890a (patch)
tree983acee75ef3c19150ffbfe92c5f998683d39690
parentab44aa7b34e85b498d5aba02e5ad902d6d16fe7f (diff)
downloadgitlab-ce-74f80465f6078b4a78ae2ebe4e367d4f1d7c890a.tar.gz
Remove index from pipeline toggles18141-pipeline-graph
-rw-r--r--app/assets/javascripts/pipeline.js.es620
-rw-r--r--app/views/projects/commit/_pipeline.html.haml2
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)