Commit 4c7e2218 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'diff-fix-expanding' into 'master'

Fixed multiple diff line discussions not expanding

Closes #53600

See merge request gitlab-org/gitlab-ce!23539
parents acd18a09 7aa88030
......@@ -56,9 +56,12 @@ export default {
return `${noteData.author.name}: ${note}`;
},
toggleDiscussions() {
const forceExpanded = this.discussions.some(discussion => !discussion.expanded);
this.discussions.forEach(discussion => {
this.toggleDiscussion({
discussionId: discussion.id,
forceExpanded,
});
});
},
......
......@@ -178,9 +178,11 @@ export default {
}
},
[types.TOGGLE_DISCUSSION](state, { discussionId }) {
[types.TOGGLE_DISCUSSION](state, { discussionId, forceExpanded = null }) {
const discussion = utils.findNoteObjectById(state.discussions, discussionId);
Object.assign(discussion, { expanded: !discussion.expanded });
Object.assign(discussion, {
expanded: forceExpanded === null ? !discussion.expanded : forceExpanded,
});
},
[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,
forceExpanded: true,
},
]);
expect(component.$store.dispatch.calls.argsFor(1)).toEqual([
'toggleDiscussion',
{
discussionId: component.discussions[1].id,
forceExpanded: 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, forceExpanded: 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