接受PR局部刷新及跳转

dev_blankdatabase
huang 9 years ago
parent 54a9fadbd1
commit 515649beb6

@ -75,10 +75,13 @@ class PullRequestsController < ApplicationController
# @param [Integer] id The ID of a merge request. # @param [Integer] id The ID of a merge request.
# @return [Gitlab::ObjectifiedHash] # @return [Gitlab::ObjectifiedHash]
def accept_pull_request def accept_pull_request
commit_id = parmas[:commit_id] begin
status = @g.accept_merge_rquest(@project.gpid, commit_id) status = @g.accept_merge_rquest(@project.gpid, params[:id])
if status == '200' respond_to do |format|
# 需跳入的地方 format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)}
end
rescue Exception => e
@message = e.message
end end
end end

@ -1,45 +1,52 @@
<div id="mergeShow" class="f14 fontGrey2 merge-show"> <div id="create_pull_request_error">
<span class="mr10 open-status"><%= @request.state == "merged" ? "已合并" : "待处理" %></span><span class="mr10">合并请求</span> 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %> <%= render :partial => "pull_requests/error_message" %>
<!--<a href="javascript:void(0);" class="BlueCirBtnMini fr mt5">编辑</a>-->
<div class="cl"></div>
</div> </div>
<div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div>
<% if @commits_count == 0 && @changes_count == 0 %> <div id="pull_request_show">
<div class="mt10 mb15"> <div id="mergeShow" class="f14 fontGrey2 merge-show">
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span> <span class="mr10 open-status"><%= @request.state == "merged" ? "已合并" : "待处理" %></span><span class="mr10">合并请求</span> 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %>
<div class="merge-commit-option mt15"> <!--<a href="javascript:void(0);" class="BlueCirBtnMini fr mt5">编辑</a>-->
<span class="fontGrey3 fb" style="font-size:13px;"><img src="/images/warning.png" width="16" class="mr5 mt2 fl"><%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %></span><br /> <div class="cl"></div>
<p class="fontGrey2 mt5">请将新改动提交至源分支或者切换到其它目标分支</p> </div>
<div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div>
<% if @commits_count == 0 && @changes_count == 0 %>
<div class="mt10 mb15">
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span>
<div class="merge-commit-option mt15">
<span class="fontGrey3 fb" style="font-size:13px;"><img src="/images/warning.png" width="16" class="mr5 mt2 fl"><%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %></span><br />
<p class="fontGrey2 mt5">请将新改动提交至源分支或者切换到其它目标分支</p>
</div>
</div> </div>
</div> <% else %>
<% else %> <% if @request.state == "merged" %>
<% if @request.state == "merged" %>
6666 6666
<% else %> <% else %>
<div class="mt10 mb15"> <div class="mt10 mb15">
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span> 请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span>
<div class="merge-commit-option mt15"> <div class="merge-commit-option mt15">
<%= link_to "接受请求", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :class => "BlueCirBtn" %> <%= link_to "接受请求", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true, :class => "BlueCirBtn" %>
</div>
</div> </div>
</div> <% end %>
<% end %> <ul class="merge-record" style="border-top:1px solid #ddd;">
<ul class="merge-record" style="border-top:1px solid #ddd;"> <li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li>
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li> <li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li> </ul>
</ul> <div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div> <div id="merge_record_0">
<div id="merge_record_0"> <%= render :partial => "pull_requests/pull_request_commits" %>
<%= render :partial => "pull_requests/pull_request_commits" %> </div>
</div> <div id="merge_record_1" class="undis">
<div id="merge_record_1" class="undis"> <%= render :partial => "pull_requests/pull_request_changes" %>
<%= render :partial => "pull_requests/pull_request_changes" %> </div>
</div> <% end %>
<% end %> </div>
<script> <script>
$("#mergeShow").parent().css("width","730px"); $("#pull_request_show").parent().css("width","730px");
$("#changed-files").toggle(function(){ $("#changed-files").toggle(function(){
$("#changed-files-detail").show(); $("#changed-files-detail").show();

@ -0,0 +1,2 @@
$("#create_pull_request_error").html('<%= escape_javascript(render :partial => "pull_requests/error_message") %>');

@ -1 +1,3 @@
$("#pull_request_new_form").html('<%= escape_javascript(render :partial => "pull_requests/show") %>'); <%# 详情页面和新建页面都会跳入,所以用两种局部刷新 %>
$("#pull_request_new_form").html('<%= escape_javascript(render :partial => "pull_requests/show") %>');
$("#pull_request_show").html('<%= escape_javascript(render :partial => "pull_requests/show") %>');

@ -809,7 +809,7 @@ RedmineApp::Application.routes.draw do
collection do collection do
end end
member do member do
post 'accept_pull_request' get 'accept_pull_request'
get 'pull_request_commits' get 'pull_request_commits'
get 'pull_request_changes' get 'pull_request_changes'
end end

Loading…
Cancel
Save