Commit f4db21eb authored by Phil Hughes's avatar Phil Hughes

Merge branch '_acet-fix-placeholder-note' into 'master'

Fix placeholder note rendering.

Closes #48933

See merge request gitlab-org/gitlab-ce!22078
parents cf26610f e3b96ad7
...@@ -191,6 +191,7 @@ export default { ...@@ -191,6 +191,7 @@ export default {
if (note.placeholderType === SYSTEM_NOTE) { if (note.placeholderType === SYSTEM_NOTE) {
return placeholderSystemNote; return placeholderSystemNote;
} }
return placeholderNote; return placeholderNote;
} }
...@@ -201,7 +202,7 @@ export default { ...@@ -201,7 +202,7 @@ export default {
return noteableNote; return noteableNote;
}, },
componentData(note) { componentData(note) {
return note.isPlaceholderNote ? this.discussion.notes[0] : note; return note.isPlaceholderNote ? note.notes[0] : note;
}, },
toggleDiscussionHandler() { toggleDiscussionHandler() {
this.toggleDiscussion({ discussionId: this.discussion.id }); this.toggleDiscussion({ discussionId: this.discussion.id });
......
---
title: Fix rendering placeholder notes
merge_request: 22078
author:
type: fixed
...@@ -133,4 +133,29 @@ describe('noteable_discussion component', () => { ...@@ -133,4 +133,29 @@ describe('noteable_discussion component', () => {
}); });
}); });
}); });
describe('componentData', () => {
it('should return first note object for placeholder note', () => {
const data = {
isPlaceholderNote: true,
notes: [
{ body: 'hello world!' },
],
};
const note = vm.componentData(data);
expect(note).toEqual(data.notes[0]);
});
it('should return given note for nonplaceholder notes', () => {
const data = {
notes: [
{ id: 12 },
],
};
const note = vm.componentData(data);
expect(note).toEqual(data);
});
});
}); });
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