Commit e57a016d authored by Justin Boyson's avatar Justin Boyson Committed by Jose Ivan Vargas

Code review updates

Remove mapMutation usage
Add action
Update specs
Fix lint error
parent 33d7ba0d
......@@ -208,6 +208,7 @@ export default {
'scrollToNoteIfNeeded',
'updateAssignees',
'setSelectedCommentPositionHover',
'updateDiscussionPosition',
]),
editHandler() {
this.isEditing = true;
......@@ -250,8 +251,13 @@ export default {
...this.note.position,
};
if (this.commentLineStart && this.line)
if (this.discussionRoot && this.commentLineStart && this.line) {
position.line_range = formatLineRange(this.commentLineStart, this.line);
this.updateDiscussionPosition({
discussionId: this.note.discussion_id,
position,
});
}
this.$emit('handleUpdateNote', {
note: this.note,
......
......@@ -708,3 +708,7 @@ export const receiveDeleteDescriptionVersionError = ({ commit }, error) => {
export const updateAssignees = ({ commit }, assignees) => {
commit(types.UPDATE_ASSIGNEES, assignees);
};
export const updateDiscussionPosition = ({ commit }, updatedPosition) => {
commit(types.UPDATE_DISCUSSION_POSITION, updatedPosition);
};
......@@ -12,6 +12,7 @@ export const SHOW_PLACEHOLDER_NOTE = 'SHOW_PLACEHOLDER_NOTE';
export const TOGGLE_AWARD = 'TOGGLE_AWARD';
export const UPDATE_NOTE = 'UPDATE_NOTE';
export const UPDATE_DISCUSSION = 'UPDATE_DISCUSSION';
export const UPDATE_DISCUSSION_POSITION = 'UPDATE_DISCUSSION_POSITION';
export const SET_DISCUSSION_DIFF_LINES = 'SET_DISCUSSION_DIFF_LINES';
export const SET_NOTES_FETCHED_STATE = 'SET_NOTES_FETCHED_STATE';
export const SET_NOTES_LOADING_STATE = 'SET_NOTES_LOADING_STATE';
......
......@@ -278,6 +278,11 @@ export default {
Object.assign(selectedDiscussion, { ...note });
},
[types.UPDATE_DISCUSSION_POSITION](state, { discussionId, position }) {
const selectedDiscussion = state.discussions.find(disc => disc.id === discussionId);
if (selectedDiscussion) Object.assign(selectedDiscussion.position, { ...position });
},
[types.CLOSE_ISSUE](state) {
Object.assign(state.noteableData, { state: constants.CLOSED });
},
......
---
title: Fix highlight commented rows
merge_request: 38420
author:
type: fixed
......@@ -1322,4 +1322,18 @@ describe('Actions Notes Store', () => {
});
});
});
describe('updateDiscussionPosition', () => {
it('update the assignees state', done => {
const updatedPosition = { discussionId: 1, position: { test: true } };
testAction(
actions.updateDiscussionPosition,
updatedPosition,
{ state: { discussions: [] } },
[{ type: mutationTypes.UPDATE_DISCUSSION_POSITION, payload: updatedPosition }],
[],
done,
);
});
});
});
......@@ -865,4 +865,20 @@ describe('Notes Store mutations', () => {
expect(state.noteableData.assignees).toEqual([userDataMock.id]);
});
});
describe('UPDATE_DISCUSSION_POSITION', () => {
it('should upate the discusion position', () => {
const discussion1 = { id: 1, position: { line_code: 'abc_1_1' } };
const discussion2 = { id: 2, position: { line_code: 'abc_2_2' } };
const discussion3 = { id: 3, position: { line_code: 'abc_3_3' } };
const state = {
discussions: [discussion1, discussion2, discussion3],
};
const discussion1Position = { ...discussion1.position };
const position = { ...discussion1Position, test: true };
mutations.UPDATE_DISCUSSION_POSITION(state, { discussionId: discussion1.id, position });
expect(state.discussions[0].position).toEqual(position);
});
});
});
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