2011-12-13 09:07:52 +01:00
|
|
|
var MergeRequest = {
|
2011-12-13 19:40:45 +01:00
|
|
|
diffs_loaded: false,
|
2011-12-13 09:07:52 +01:00
|
|
|
commits_loaded: false,
|
2012-04-16 21:08:03 +02:00
|
|
|
opts: false,
|
2011-12-13 09:07:52 +01:00
|
|
|
|
|
|
|
init:
|
2012-04-16 21:08:03 +02:00
|
|
|
function(opts) {
|
2012-04-26 23:53:55 +02:00
|
|
|
var self = this;
|
|
|
|
self.opts = opts;
|
2012-04-16 21:08:03 +02:00
|
|
|
|
2012-06-29 20:55:22 +02:00
|
|
|
self.initTabs();
|
|
|
|
self.initMergeWidget();
|
|
|
|
|
|
|
|
$(".mr_show_all_commits").bind("click", function() {
|
|
|
|
self.showAllCommits();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
initMergeWidget:
|
|
|
|
function() {
|
|
|
|
var self = this;
|
2012-04-26 23:53:55 +02:00
|
|
|
self.showState(self.opts.current_state);
|
2012-06-29 20:55:22 +02:00
|
|
|
|
2012-04-26 23:53:55 +02:00
|
|
|
if($(".automerge_widget").length && self.opts.check_enable){
|
2012-06-29 21:02:22 +02:00
|
|
|
$.get(self.opts.url_to_automerge_check, function(data){
|
2012-04-26 23:53:55 +02:00
|
|
|
self.showState(data.state);
|
2012-04-16 21:08:03 +02:00
|
|
|
}, "json");
|
|
|
|
}
|
2012-06-29 20:55:22 +02:00
|
|
|
},
|
2012-04-16 21:08:03 +02:00
|
|
|
|
2012-06-29 20:55:22 +02:00
|
|
|
initTabs:
|
|
|
|
function() {
|
|
|
|
$(".mr_nav_tabs a").live("click", function() {
|
|
|
|
$(".mr_nav_tabs a").parent().removeClass("active");
|
2012-01-26 23:13:19 +01:00
|
|
|
$(this).parent().addClass("active");
|
2011-12-13 09:07:52 +01:00
|
|
|
});
|
|
|
|
|
2012-06-29 20:55:22 +02:00
|
|
|
var current_tab;
|
|
|
|
if(this.opts.action == "diffs") {
|
|
|
|
current_tab = $(".mr_nav_tabs .merge-diffs-tab");
|
|
|
|
} else {
|
|
|
|
current_tab = $(".mr_nav_tabs .merge-notes-tab");
|
|
|
|
}
|
|
|
|
current_tab.parent().addClass("active");
|
|
|
|
|
|
|
|
this.initNotesTab();
|
|
|
|
this.initDiffTab();
|
|
|
|
},
|
|
|
|
|
|
|
|
initNotesTab:
|
|
|
|
function() {
|
|
|
|
$(".mr_nav_tabs a.merge-notes-tab").live("click", function(e) {
|
2012-02-15 00:15:02 +01:00
|
|
|
$(".merge-request-diffs").hide();
|
2012-03-15 22:01:50 +01:00
|
|
|
$(".merge_request_notes").show();
|
2012-06-29 20:55:22 +02:00
|
|
|
var mr_path = $(".merge-notes-tab").attr("data-url");
|
|
|
|
history.pushState({ path: mr_path }, '', mr_path);
|
2012-02-21 21:04:01 +01:00
|
|
|
e.preventDefault();
|
2011-12-13 19:40:45 +01:00
|
|
|
});
|
2012-06-29 20:55:22 +02:00
|
|
|
},
|
2011-12-13 19:40:45 +01:00
|
|
|
|
2012-06-29 20:55:22 +02:00
|
|
|
initDiffTab:
|
|
|
|
function() {
|
|
|
|
$(".mr_nav_tabs a.merge-diffs-tab").live("click", function(e) {
|
2011-12-13 19:40:45 +01:00
|
|
|
if(!MergeRequest.diffs_loaded) {
|
|
|
|
MergeRequest.loadDiff();
|
|
|
|
}
|
2012-03-15 22:01:50 +01:00
|
|
|
$(".merge_request_notes").hide();
|
2011-12-13 19:40:45 +01:00
|
|
|
$(".merge-request-diffs").show();
|
2012-06-29 20:55:22 +02:00
|
|
|
var mr_diff_path = $(".merge-diffs-tab").attr("data-url");
|
|
|
|
history.pushState({ path: mr_diff_path }, '', mr_diff_path);
|
2012-02-21 21:04:01 +01:00
|
|
|
e.preventDefault();
|
2011-12-13 09:07:52 +01:00
|
|
|
});
|
2012-06-20 20:29:55 +02:00
|
|
|
|
2011-12-13 09:07:52 +01:00
|
|
|
},
|
|
|
|
|
2012-04-26 23:53:55 +02:00
|
|
|
showState:
|
|
|
|
function(state){
|
|
|
|
$(".automerge_widget").hide();
|
|
|
|
$(".automerge_widget." + state).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2011-12-13 09:07:52 +01:00
|
|
|
loadDiff:
|
|
|
|
function() {
|
2011-12-13 19:40:45 +01:00
|
|
|
$(".dashboard-loader").show();
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: $(".merge-diffs-tab").attr("data-url"),
|
2012-03-26 20:41:58 +02:00
|
|
|
beforeSend: function(){ $('.status').addClass("loading")},
|
2011-12-13 19:40:45 +01:00
|
|
|
complete: function(){
|
|
|
|
MergeRequest.diffs_loaded = true;
|
2012-03-15 22:01:50 +01:00
|
|
|
$(".merge_request_notes").hide();
|
2012-03-26 20:41:58 +02:00
|
|
|
$('.status').removeClass("loading");
|
|
|
|
},
|
2011-12-13 19:40:45 +01:00
|
|
|
dataType: "script"});
|
2012-04-17 21:08:07 +02:00
|
|
|
},
|
|
|
|
|
2012-06-20 20:01:00 +02:00
|
|
|
showAllCommits:
|
|
|
|
function() {
|
|
|
|
$(".first_mr_commits").remove();
|
|
|
|
$(".all_mr_commits").removeClass("hide");
|
|
|
|
},
|
|
|
|
|
2012-04-16 22:05:08 +02:00
|
|
|
already_cannot_be_merged:
|
|
|
|
function(){
|
|
|
|
$(".automerge_widget").hide();
|
2012-08-18 23:45:46 +02:00
|
|
|
$(".merge_in_progress").hide();
|
2012-04-16 22:05:08 +02:00
|
|
|
$(".automerge_widget.already_cannot_be_merged").show();
|
2011-12-13 09:07:52 +01:00
|
|
|
}
|
2012-10-26 14:52:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Filter merge requests
|
|
|
|
*/
|
|
|
|
function merge_requestsPage() {
|
|
|
|
$("#assignee_id").chosen();
|
|
|
|
$("#milestone_id").chosen();
|
|
|
|
$("#milestone_id, #assignee_id").on("change", function(){
|
|
|
|
$(this).closest("form").submit();
|
|
|
|
});
|
2011-12-13 09:07:52 +01:00
|
|
|
}
|