Commit 43dcc957 authored by Valery Sizov's avatar Valery Sizov

Task #735 Automerge should not be checked on every load of MR show page

parent 28cb4313
...@@ -5,12 +5,13 @@ var MergeRequest = { ...@@ -5,12 +5,13 @@ var MergeRequest = {
init: init:
function(opts) { function(opts) {
this.opts = opts; var self = this;
self.opts = opts;
if($(".automerge_widget").length){ self.showState(self.opts.current_state);
if($(".automerge_widget").length && self.opts.check_enable){
$.get(opts.url_to_automerge_check, function(data){ $.get(opts.url_to_automerge_check, function(data){
$(".automerge_widget").hide(); self.showState(data.state);
$(".automerge_widget." + data.state).show();
}, "json"); }, "json");
} }
...@@ -35,6 +36,13 @@ var MergeRequest = { ...@@ -35,6 +36,13 @@ var MergeRequest = {
}); });
}, },
showState:
function(state){
$(".automerge_widget").hide();
$(".automerge_widget." + state).show();
},
loadDiff: loadDiff:
function() { function() {
$(".dashboard-loader").show(); $(".dashboard-loader").show();
......
...@@ -101,6 +101,8 @@ ...@@ -101,6 +101,8 @@
$(function(){ $(function(){
MergeRequest.init({ MergeRequest.init({
url_to_automerge_check: "#{automerge_check_project_merge_request_path(@project, @merge_request)}", url_to_automerge_check: "#{automerge_check_project_merge_request_path(@project, @merge_request)}",
check_enable: #{@merge_request.state == MergeRequest::UNCHECKED ? "true" : "false"},
current_state: "#{@merge_request.human_state}"
}); });
$(".accept_merge_request").live("ajax:beforeSend", function() { $(".accept_merge_request").live("ajax:beforeSend", function() {
......
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