Commit 30912c75 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve merge request comments

When add diff note on 'Changes' page - and then go to 'Discussions' tab
you will not see this discussion unless you reload a page. This commit
fixes it by rendering discussion on 'Discussion' page as soon as you
submit comment on 'Changes' page
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 8c67c339
...@@ -142,6 +142,13 @@ class Notes ...@@ -142,6 +142,13 @@ class Notes
# remove the note (will be added again below) # remove the note (will be added again below)
row.next().find(".note").remove() row.next().find(".note").remove()
# Add note to 'Changes' page discussions
$(".notes[rel='" + note.discussion_id + "']").append note.html
# Init discussion on 'Discussion' page
$('ul.main-notes-list').append(note.discussion_with_diff_html)
else
# append new note to all matching discussions # append new note to all matching discussions
$(".notes[rel='" + note.discussion_id + "']").append note.html $(".notes[rel='" + note.discussion_id + "']").append note.html
......
...@@ -85,12 +85,22 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -85,12 +85,22 @@ class Projects::NotesController < Projects::ApplicationController
) )
end end
def note_to_discussion_with_diff_html(note)
render_to_string(
"projects/notes/_discussion",
layout: false,
formats: [:html],
locals: { discussion_notes: [note] }
)
end
def render_note_json(note) def render_note_json(note)
render json: { render json: {
id: note.id, id: note.id,
discussion_id: note.discussion_id, discussion_id: note.discussion_id,
html: note_to_html(note), html: note_to_html(note),
discussion_html: note_to_discussion_html(note) discussion_html: note_to_discussion_html(note),
discussion_with_diff_html: note_to_discussion_with_diff_html(note)
} }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment