Commit 8610efde authored by Phil Hughes's avatar Phil Hughes Committed by GitLab

Fixed multiple diff line discussions not expanding

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53600
parent 241a5a38
......@@ -56,9 +56,12 @@ export default {
return `${noteData.author.name}: ${note}`;
},
toggleDiscussions() {
const shouldExpand = this.discussions.some(discussion => !discussion.expanded);
this.discussions.forEach(discussion => {
this.toggleDiscussion({
discussionId: discussion.id,
shouldExpand,
});
});
},
......
......@@ -178,9 +178,11 @@ export default {
}
},
[types.TOGGLE_DISCUSSION](state, { discussionId }) {
[types.TOGGLE_DISCUSSION](state, { discussionId, shouldExpand = null }) {
const discussion = utils.findNoteObjectById(state.discussions, discussionId);
Object.assign(discussion, { expanded: !discussion.expanded });
Object.assign(discussion, {
expanded: shouldExpand === null ? !discussion.expanded : shouldExpand,
});
},
[types.UPDATE_NOTE](state, note) {
......
---
title: Fixed multiple diff line discussions not expanding
merge_request:
author:
type: fixed
......@@ -89,6 +89,35 @@ describe('DiffGutterAvatars', () => {
expect(component.discussions[0].expanded).toEqual(false);
component.$store.dispatch('setInitialNotes', []);
});
it('forces expansion of all discussions', () => {
spyOn(component.$store, 'dispatch');
component.discussions[0].expanded = true;
component.discussions.push({
...component.discussions[0],
id: '123test',
expanded: false,
});
component.toggleDiscussions();
expect(component.$store.dispatch.calls.argsFor(0)).toEqual([
'toggleDiscussion',
{
discussionId: component.discussions[0].id,
shouldExpand: true,
},
]);
expect(component.$store.dispatch.calls.argsFor(1)).toEqual([
'toggleDiscussion',
{
discussionId: component.discussions[1].id,
shouldExpand: true,
},
]);
});
});
});
......
......@@ -297,6 +297,16 @@ describe('Notes Store mutations', () => {
expect(state.discussions[0].expanded).toEqual(false);
});
it('forces a discussions expanded state', () => {
const state = {
discussions: [{ ...discussionMock, expanded: false }],
};
mutations.TOGGLE_DISCUSSION(state, { discussionId: discussionMock.id, shouldExpand: true });
expect(state.discussions[0].expanded).toEqual(true);
});
});
describe('UPDATE_NOTE', () => {
......
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