Skip to content
Snippets Groups Projects
Commit 3f72af99 authored by Riyad Preukschas's avatar Riyad Preukschas
Browse files

Make notes for merge requests include commit notes and add helpers

parent dda852a0
No related branches found
No related tags found
1 merge request!1630Mix commit notes with merge request notes on MR show page
Loading
Loading
@@ -13,7 +13,7 @@ module Notes
when "issue"
project.issues.find(target_id).notes.inc_author.fresh.limit(20)
when "merge_request"
project.merge_requests.find(target_id).notes.inc_author.fresh.limit(20)
project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh.limit(20)
when "snippet"
project.snippets.find(target_id).notes.fresh
when "wall"
Loading
Loading
Loading
Loading
@@ -7,6 +7,11 @@ class NotesController < ProjectResourceController
 
def index
notes
if params[:target_type] == "merge_request"
@mixed_targets = true
@main_target_type = params[:target_type].camelize
end
respond_with(@notes)
end
 
Loading
Loading
Loading
Loading
@@ -7,6 +7,11 @@ module NotesHelper
params[:loading_new].present?
end
 
# Helps to distinguish e.g. commit notes in mr notes list
def note_for_main_target?(note)
!@mixed_targets || @main_target_type == note.noteable_type
end
def note_vote_class(note)
if note.upvote?
"vote upvote"
Loading
Loading
Loading
Loading
@@ -49,7 +49,7 @@ class Note < ActiveRecord::Base
end
 
def target
if noteable_type == "Commit"
if commit?
project.commit(noteable_id)
else
noteable
Loading
Loading
@@ -82,6 +82,10 @@ class Note < ActiveRecord::Base
noteable_type == "Commit"
end
 
def line_note?
line_code.present?
end
def commit_author
@commit_author ||=
project.users.find_by_email(target.author_email) ||
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment