[#19] fix showing discussion in pull requests && small refactoring
This commit is contained in:
parent
ce2ca6646e
commit
8f18d0a874
|
@ -1,7 +1,7 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
module PullRequestHelper
|
||||
def merge_activity comments, commits
|
||||
common_comments, pull_comments = comments.partition {|c| c.data.blank?}
|
||||
common_comments, pull_comments = comments.partition {|c| c.automatic || c.data.blank?}
|
||||
common_comments = common_comments.map{ |c| [c.created_at, c] }
|
||||
pull_comments = pull_comments.group_by(&:data).map{|data, c| [c.first.created_at, [data || {}, [c].flatten]]}
|
||||
commits = commits.map{ |c| [(c.committed_date || c.authored_date), c] }
|
||||
|
|
|
@ -86,7 +86,7 @@ class Comment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def pull_comment?
|
||||
return true if commentable.is_a?(Issue) && commentable.pull_request.present?
|
||||
commentable.is_a?(Issue) && commentable.pull_request.present?
|
||||
end
|
||||
|
||||
def set_additional_data params
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
%a{ :name => "comments" }
|
||||
.hr
|
||||
%h3#block-list= t("layout.comments.comments_header")
|
||||
- counter = 1
|
||||
- list.each do |comment|
|
||||
-if comment.automatic
|
||||
- GitPresenters::CommitAsMessagePresenter.present(nil, :comment => comment) do |presenter|
|
||||
= render 'shared/feed_message', :presenter => presenter, :item_no => counter
|
||||
- counter += 1
|
||||
-else
|
||||
-unless comment.automatic
|
||||
= render 'projects/comments/comment', :comment => comment, :data => {:project => project, :commentable => commentable}
|
||||
-else
|
||||
- GitPresenters::CommitAsMessagePresenter.present(nil, :comment => comment) do |presenter|
|
||||
= render 'shared/feed_message', :presenter => presenter, :item_no => "-#{comment.id}"
|
||||
= render "projects/comments/markdown_help"
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
-if item.is_a? Comment
|
||||
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
|
||||
-commits_queue.clear
|
||||
=render 'projects/comments/comment', :comment => item, :data => {:project => @project, :commentable => @commentable}
|
||||
-unless item.automatic
|
||||
= render 'projects/comments/comment', :comment => item, :data => {:project => @project, :commentable => @commentable}
|
||||
-else
|
||||
- GitPresenters::CommitAsMessagePresenter.present(nil, :comment => item) do |presenter|
|
||||
= render 'shared/feed_message', :presenter => presenter, :item_no => "-#{item.id}"
|
||||
-elsif item.is_a? Grit::Commit
|
||||
-commits_queue << item
|
||||
-elsif item.is_a? Array
|
||||
|
@ -20,4 +24,3 @@
|
|||
-else
|
||||
=render 'projects/pull_requests/discussion_comments', :item => item, :add_id => nil
|
||||
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
|
||||
|
||||
|
|
Loading…
Reference in New Issue