Refactor discussion reply
This commit is contained in:
parent
1319373d58
commit
494ae87840
27 changed files with 229 additions and 197 deletions
|
@ -13,10 +13,14 @@ class CommitController < ProjectResourceController
|
|||
@commit = result[:commit]
|
||||
git_not_found! unless @commit
|
||||
|
||||
@suppress_diff = result[:suppress_diff]
|
||||
@note = result[:note]
|
||||
@line_notes = result[:line_notes]
|
||||
@notes_count = result[:notes_count]
|
||||
@suppress_diff = result[:suppress_diff]
|
||||
|
||||
@note = result[:note]
|
||||
@line_notes = result[:line_notes]
|
||||
@notes_count = result[:notes_count]
|
||||
@target_type = :commit
|
||||
@target_id = @commit.id
|
||||
|
||||
@comments_allowed = @reply_allowed = true
|
||||
@comments_target = { noteable_type: 'Commit',
|
||||
noteable_id: @commit.id }
|
||||
|
|
|
@ -38,6 +38,8 @@ class IssuesController < ProjectResourceController
|
|||
|
||||
def show
|
||||
@note = @project.notes.new(noteable: @issue)
|
||||
@target_type = :issue
|
||||
@target_id = @issue.id
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
|
|
@ -21,6 +21,9 @@ class MergeRequestsController < ProjectResourceController
|
|||
end
|
||||
|
||||
def show
|
||||
@target_type = :merge_request
|
||||
@target_id = @merge_request.id
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
|
|
|
@ -6,13 +6,11 @@ class NotesController < ProjectResourceController
|
|||
respond_to :js
|
||||
|
||||
def index
|
||||
@target_note = Note.new(noteable_type: params[:target_type].camelize,
|
||||
noteable_id: params[:target_id])
|
||||
@target = @target_note.noteable
|
||||
@notes = Notes::LoadContext.new(project, current_user, params).execute
|
||||
@target_type = params[:target_type].camelize
|
||||
@target_id = params[:target_id]
|
||||
|
||||
if params[:target_type] == "merge_request"
|
||||
@mixed_targets = true
|
||||
@discussions = discussions_from_notes
|
||||
end
|
||||
|
||||
|
@ -21,6 +19,8 @@ class NotesController < ProjectResourceController
|
|||
|
||||
def create
|
||||
@note = Notes::CreateContext.new(project, current_user, params).execute
|
||||
@target_type = params[:target_type].camelize
|
||||
@target_id = params[:target_id]
|
||||
|
||||
respond_to do |format|
|
||||
format.html {redirect_to :back}
|
||||
|
@ -58,7 +58,7 @@ class NotesController < ProjectResourceController
|
|||
next if discussion_ids.include?(note.discussion_id)
|
||||
|
||||
# don't group notes for the main target
|
||||
if for_main_target?(note)
|
||||
if note_for_main_target?(note)
|
||||
discussions << [note]
|
||||
else
|
||||
discussions << discussion_notes_for(note)
|
||||
|
@ -70,7 +70,7 @@ class NotesController < ProjectResourceController
|
|||
end
|
||||
|
||||
# Helps to distinguish e.g. commit notes in mr notes list
|
||||
def for_main_target?(note)
|
||||
!@mixed_targets || (@target.class.name == note.noteable_type && !note.for_diff_line?)
|
||||
def note_for_main_target?(note)
|
||||
@target_type.camelize == note.noteable_type && !note.for_diff_line?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,7 +75,10 @@ class ProjectsController < ProjectResourceController
|
|||
|
||||
def wall
|
||||
return render_404 unless @project.wall_enabled
|
||||
@note = Note.new
|
||||
|
||||
@target_type = :wall
|
||||
@target_id = nil
|
||||
@note = @project.notes.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
|
|
@ -50,6 +50,8 @@ class SnippetsController < ProjectResourceController
|
|||
|
||||
def show
|
||||
@note = @project.notes.new(noteable: @snippet)
|
||||
@target_type = :snippet
|
||||
@target_id = @snippet.id
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue