Commit 3824f9b3 authored by randx's avatar randx

Unverify MR on every push. Ajax for MR accept. better UI

parent 411d84f3
......@@ -90,6 +90,7 @@ class MergeRequestsController < ApplicationController
respond_to do |format|
if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id))
@merge_request.reload_code
@merge_request.mark_as_unchecked
format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' }
format.json { head :ok }
else
......@@ -101,8 +102,7 @@ class MergeRequestsController < ApplicationController
def automerge
render_404 unless @merge_request.open? && @merge_request.can_be_merged?
message = @merge_request.automerge! ? "Successfully merged" : "Can not be merged"
redirect_to [@merge_request.project, @merge_request], :alert => message
@merge_request.automerge!(current_user)
end
def destroy
......
......@@ -64,6 +64,10 @@ class MergeRequest < ActiveRecord::Base
state == UNCHECKED
end
def mark_as_unchecked
self.update_attributes(:state => UNCHECKED)
end
def can_be_merged?
state == CAN_BE_MERGED
end
......@@ -170,7 +174,7 @@ class MergeRequest < ActiveRecord::Base
)
end
def automerge!
def automerge!(current_user)
if GitlabMerge.new(self).merge
self.merge!(current_user.id)
true
......
......@@ -19,7 +19,7 @@ module Project::HooksTrait
# Update code for merge requests
mrs = self.merge_requests.opened.find_all_by_branch(branch_name).all
mrs.each { |merge_request| merge_request.reload_code }
mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked }
# Close merge requests
mrs = self.merge_requests.opened.where(:target_branch => branch_name).all
......
......@@ -54,11 +54,10 @@
- if @merge_request.open? && @commits.any?
- if @merge_request.can_be_merged?
.alert-message.info
.ui-box.padded
%p
You can accept this request automatically. If you still want to do it manually - #{link_to "click here", "#", :class => "how_to_merge_link cwhite", :title => "How To Merge"} for instructions
.alert-actions
= link_to "Accept Merge Request", automerge_project_merge_request_path(@project, @merge_request), :class => "btn small info"
You can accept this request automatically. If you still want to do it manually - #{link_to "click here", "#", :class => "how_to_merge_link vlink", :title => "How To Merge"} for instructions
= link_to "Accept Merge Request", automerge_project_merge_request_path(@project, @merge_request), :class => "btn small info accept_merge_request", :remote => true
&nbsp;
- else
......@@ -88,6 +87,10 @@
:javascript
$(function(){
MergeRequest.init();
$(".accept_merge_request").live("ajax:beforeSend", function() {
$(this).replaceWith('#{image_tag "ajax_loader.gif"}');
})
})
= render "notes/per_line_form"
......
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