Merge branch '38677-render-new-discussions-on-diff-tab' into 'master'
Added discussion_line_code value to note response and use it to query the right… Closes #38677 See merge request gitlab-org/gitlab-ce!14981
This commit is contained in:
commit
46dc343f60
5 changed files with 33 additions and 3 deletions
|
@ -413,8 +413,9 @@ export default class Notes {
|
|||
return;
|
||||
}
|
||||
this.note_ids.push(noteEntity.id);
|
||||
|
||||
form = $form || $(`.js-discussion-note-form[data-discussion-id="${noteEntity.discussion_id}"]`);
|
||||
row = form.closest('tr');
|
||||
row = (form.length || !noteEntity.discussion_line_code) ? form.closest('tr') : $(`#${noteEntity.discussion_line_code}`);
|
||||
|
||||
if (noteEntity.on_image) {
|
||||
row = form;
|
||||
|
|
|
@ -109,6 +109,8 @@ module NotesActions
|
|||
diff_discussion_html: diff_discussion_html(discussion),
|
||||
discussion_html: discussion_html(discussion)
|
||||
)
|
||||
|
||||
attrs[:discussion_line_code] = discussion.line_code if discussion.diff_discussion?
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Add new diff discussions on MR diffs tab in "realtime"
|
||||
merge_request: 14981
|
||||
author:
|
||||
type: fixed
|
|
@ -59,6 +59,7 @@ describe Projects::NotesController do
|
|||
expect(note_json[:id]).to eq(note.id)
|
||||
expect(note_json[:discussion_html]).not_to be_nil
|
||||
expect(note_json[:diff_discussion_html]).to be_nil
|
||||
expect(note_json[:discussion_line_code]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,6 +75,7 @@ describe Projects::NotesController do
|
|||
expect(note_json[:id]).to eq(note.id)
|
||||
expect(note_json[:discussion_html]).not_to be_nil
|
||||
expect(note_json[:diff_discussion_html]).not_to be_nil
|
||||
expect(note_json[:discussion_line_code]).not_to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -92,6 +94,7 @@ describe Projects::NotesController do
|
|||
expect(note_json[:id]).to eq(note.id)
|
||||
expect(note_json[:discussion_html]).not_to be_nil
|
||||
expect(note_json[:diff_discussion_html]).to be_nil
|
||||
expect(note_json[:discussion_line_code]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -104,6 +107,7 @@ describe Projects::NotesController do
|
|||
expect(note_json[:id]).to eq(note.id)
|
||||
expect(note_json[:discussion_html]).to be_nil
|
||||
expect(note_json[:diff_discussion_html]).to be_nil
|
||||
expect(note_json[:discussion_line_code]).to be_nil
|
||||
end
|
||||
|
||||
context 'when user cannot read commit' do
|
||||
|
@ -133,6 +137,7 @@ describe Projects::NotesController do
|
|||
expect(note_json[:html]).not_to be_nil
|
||||
expect(note_json[:discussion_html]).to be_nil
|
||||
expect(note_json[:diff_discussion_html]).to be_nil
|
||||
expect(note_json[:discussion_line_code]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -343,6 +343,7 @@ import '~/notes';
|
|||
diff_discussion_html: false,
|
||||
};
|
||||
$form = jasmine.createSpyObj('$form', ['closest', 'find']);
|
||||
$form.length = 1;
|
||||
row = jasmine.createSpyObj('row', ['prevAll', 'first', 'find']);
|
||||
|
||||
notes = jasmine.createSpyObj('notes', [
|
||||
|
@ -371,13 +372,29 @@ import '~/notes';
|
|||
$form.closest.and.returnValues(row, $form);
|
||||
$form.find.and.returnValues(discussionContainer);
|
||||
body.attr.and.returnValue('');
|
||||
|
||||
Notes.prototype.renderDiscussionNote.call(notes, note, $form);
|
||||
});
|
||||
|
||||
it('should call Notes.animateAppendNote', () => {
|
||||
Notes.prototype.renderDiscussionNote.call(notes, note, $form);
|
||||
|
||||
expect(Notes.animateAppendNote).toHaveBeenCalledWith(note.discussion_html, $('.main-notes-list'));
|
||||
});
|
||||
|
||||
it('should append to row selected with line_code', () => {
|
||||
$form.length = 0;
|
||||
note.discussion_line_code = 'line_code';
|
||||
note.diff_discussion_html = '<tr></tr>';
|
||||
|
||||
const line = document.createElement('div');
|
||||
line.id = note.discussion_line_code;
|
||||
document.body.appendChild(line);
|
||||
|
||||
$form.closest.and.returnValues($form);
|
||||
|
||||
Notes.prototype.renderDiscussionNote.call(notes, note, $form);
|
||||
|
||||
expect(line.nextSibling.outerHTML).toEqual(note.diff_discussion_html);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Discussion sub note', () => {
|
||||
|
|
Loading…
Reference in a new issue