Commit d80f9036 authored by Douwe Maan's avatar Douwe Maan

Fix creating discussion when diff view is set to parallel

parent 2a771d57
...@@ -338,7 +338,7 @@ require('./task_list'); ...@@ -338,7 +338,7 @@ require('./task_list');
*/ */
Notes.prototype.renderDiscussionNote = function(note, $form) { Notes.prototype.renderDiscussionNote = function(note, $form) {
var discussionContainer, form, note_html, row, lineType, diffAvatarContainer; var discussionContainer, form, row, lineType, diffAvatarContainer;
if (!this.isNewNote(note)) { if (!this.isNewNote(note)) {
return; return;
} }
...@@ -347,45 +347,37 @@ require('./task_list'); ...@@ -347,45 +347,37 @@ require('./task_list');
row = form.closest("tr"); row = form.closest("tr");
lineType = this.isParallelView() ? form.find('#line_type').val() : 'old'; lineType = this.isParallelView() ? form.find('#line_type').val() : 'old';
diffAvatarContainer = row.prevAll('.line_holder').first().find('.js-avatar-container.' + lineType + '_line'); diffAvatarContainer = row.prevAll('.line_holder').first().find('.js-avatar-container.' + lineType + '_line');
note_html = $(note.html);
note_html.renderGFM();
// is this the first note of discussion? // is this the first note of discussion?
discussionContainer = $(".notes[data-discussion-id='" + note.discussion_id + "']"); discussionContainer = $(".notes[data-discussion-id='" + note.discussion_id + "']");
if (!discussionContainer.length) { if (!discussionContainer.length) {
discussionContainer = form.closest('.discussion').find('.notes'); discussionContainer = form.closest('.discussion').find('.notes');
} }
if (discussionContainer.length === 0) { if (discussionContainer.length === 0) {
if (!this.isParallelView() || row.hasClass('js-temp-notes-holder')) { if (note.diff_discussion_html) {
// insert the note and the reply button after the temp row var $discussion = $(note.diff_discussion_html).renderGFM();
row.after(note.diff_discussion_html);
// remove the note (will be added again below) if (!this.isParallelView() || row.hasClass('js-temp-notes-holder')) {
row.next().find(".note").remove(); // insert the note and the reply button after the temp row
} else { row.after($discussion);
// Merge new discussion HTML in } else {
var $discussion = $(note.diff_discussion_html); // Merge new discussion HTML in
var $notes = $discussion.find('.notes[data-discussion-id="' + note.discussion_id + '"]'); var $notes = $discussion.find('.notes[data-discussion-id="' + note.discussion_id + '"]');
var contentContainerClass = '.' + $notes.closest('.notes_content') var contentContainerClass = '.' + $notes.closest('.notes_content')
.attr('class') .attr('class')
.split(' ') .split(' ')
.join('.'); .join('.');
// remove the note (will be added again below) row.find(contentContainerClass + ' .content').append($notes.closest('.content').children());
$notes.find('.note').remove(); }
row.find(contentContainerClass + ' .content').append($notes.closest('.content').children());
} }
// Before that, the container didn't exist
discussionContainer = $(".notes[data-discussion-id='" + note.discussion_id + "']");
// Add note to 'Changes' page discussions
discussionContainer.append(note_html);
// Init discussion on 'Discussion' page if it is merge request page // Init discussion on 'Discussion' page if it is merge request page
if ($('body').attr('data-page').indexOf('projects:merge_request') === 0 || !note.diff_discussion_html) { if ($('body').attr('data-page').indexOf('projects:merge_request') === 0 || !note.diff_discussion_html) {
$('ul.main-notes-list').append(note.discussion_html).renderGFM(); $('ul.main-notes-list').append($(note.discussion_html).renderGFM());
} }
} else { } else {
// append new note to all matching discussions // append new note to all matching discussions
discussionContainer.append(note_html); discussionContainer.append($(note.html).renderGFM());
} }
if (typeof gl.diffNotesCompileComponents !== 'undefined' && note.discussion_resolvable) { if (typeof gl.diffNotesCompileComponents !== 'undefined' && note.discussion_resolvable) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
$.fn.renderGFM = function() { $.fn.renderGFM = function() {
this.find('.js-syntax-highlight').syntaxHighlight(); this.find('.js-syntax-highlight').syntaxHighlight();
this.find('.js-render-math').renderMath(); this.find('.js-render-math').renderMath();
return this;
}; };
$(document).on('ready load', function() { $(document).on('ready load', function() {
......
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