Fix placeholder note rendering
This commit is contained in:
parent
70f4a26b6e
commit
e3b96ad76b
3 changed files with 32 additions and 1 deletions
|
@ -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 {
|
||||||
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 });
|
||||||
|
|
5
changelogs/unreleased/_acet-fix-placeholder-note.yml
Normal file
5
changelogs/unreleased/_acet-fix-placeholder-note.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Fix rendering placeholder notes
|
||||||
|
merge_request: 22078
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue