From b7bccc7d227b22e83c99b8c911e540e439510919 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 9 Aug 2016 14:00:36 +0800 Subject: [PATCH] =?UTF-8?q?PR=E6=B7=BB=E5=8A=A0=E8=AF=84=E8=AE=BA=20?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 5 +++- .../_pull_request_comments.html.erb | 19 +++++++++++++ app/views/pull_requests/_show.html.erb | 27 +++++-------------- .../pull_requests/pull_request_changes.js.erb | 2 +- .../pull_request_comments.js.erb | 1 + .../pull_requests/pull_request_commits.js.erb | 2 +- 6 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 app/views/pull_requests/_pull_request_comments.html.erb create mode 100644 app/views/pull_requests/pull_request_comments.js.erb diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 8d11e7279..f63f1dc17 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -1,7 +1,7 @@ class PullRequestsController < ApplicationController before_filter :find_project_and_repository - before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request] + before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request, :pull_request_comments] layout "base_projects" include PullRequestsHelper include ApplicationHelper @@ -87,6 +87,8 @@ class PullRequestsController < ApplicationController @commits_count = @commits.count @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) @changes_count = @changes.count + @comments = @g.merge_request_comments(@project.gpid, params[:id]) + @comments_count = @comments.count end # Accept a merge request. @@ -170,6 +172,7 @@ class PullRequestsController < ApplicationController def pull_request_commits begin @commits = @g.merge_request_commits(@project.gpid, params[:id]) + @commits_count = @commits.count rescue Exception => e @message = e.message end diff --git a/app/views/pull_requests/_pull_request_comments.html.erb b/app/views/pull_requests/_pull_request_comments.html.erb new file mode 100644 index 000000000..e5fa3a052 --- /dev/null +++ b/app/views/pull_requests/_pull_request_comments.html.erb @@ -0,0 +1,19 @@ + + + + + +<% @comments.each do |comment| %> +
+ <%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "link-blue mr15 fl" %> + <%#= time_tag(comment.author.try(:created_at)) %>前 +
+
<%= comment.note %>
+
+<% end %> + +
+ + + 提 交 +
\ No newline at end of file diff --git a/app/views/pull_requests/_show.html.erb b/app/views/pull_requests/_show.html.erb index ce0c633c6..31d337faf 100644 --- a/app/views/pull_requests/_show.html.erb +++ b/app/views/pull_requests/_show.html.erb @@ -7,13 +7,13 @@ <%= get_state(@request.state) %>合并请求 由 <%= 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) %> 前 <% unless @request.state == "merged" %> <%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %> - <% end %> + <% end %>
<%= @request.title %>

<%= @request.description %>

+
请求将 <%= @request.source_branch %> 合并至 <%= @request.target_branch %> - <% if @commits_count == 0 && @changes_count == 0 %>
<%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %>
@@ -33,28 +33,15 @@
<% end %> <% end %> -
+
-
- Hjqreturn20小时前 -
-
回复内容
-
-
- Hjqreturn20小时前 -
-
已关闭请求/重新审核请求
-
-
- - 提 交 -
+ <%= render :partial => "pull_requests/pull_request_comments" %>
<%= render :partial => "pull_requests/pull_request_commits" %> diff --git a/app/views/pull_requests/pull_request_changes.js.erb b/app/views/pull_requests/pull_request_changes.js.erb index 2b3d77537..d1cf90c2f 100644 --- a/app/views/pull_requests/pull_request_changes.js.erb +++ b/app/views/pull_requests/pull_request_changes.js.erb @@ -1 +1 @@ -$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>'); \ No newline at end of file +$("#merge_record_2").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>'); \ No newline at end of file diff --git a/app/views/pull_requests/pull_request_comments.js.erb b/app/views/pull_requests/pull_request_comments.js.erb new file mode 100644 index 000000000..5a7e6683c --- /dev/null +++ b/app/views/pull_requests/pull_request_comments.js.erb @@ -0,0 +1 @@ +$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_comments") %>'); \ No newline at end of file diff --git a/app/views/pull_requests/pull_request_commits.js.erb b/app/views/pull_requests/pull_request_commits.js.erb index 0833b1e8a..217198291 100644 --- a/app/views/pull_requests/pull_request_commits.js.erb +++ b/app/views/pull_requests/pull_request_commits.js.erb @@ -1 +1 @@ -$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>'); \ No newline at end of file +$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>'); \ No newline at end of file