Commit 96b703f5 authored by Eulyeon Ko's avatar Eulyeon Ko

Apply reviewer suggestions

- Use an action name that follows the guideline
- Destructure objects consistently
parent 1e990c8c
...@@ -340,12 +340,21 @@ export default { ...@@ -340,12 +340,21 @@ export default {
dispatch('moveIssueCard', moveData); dispatch('moveIssueCard', moveData);
dispatch('updateMovedIssue', moveData); dispatch('updateMovedIssue', moveData);
dispatch('requestIssueMoveListMutation', { moveData }); dispatch('updateIssueOrder', { moveData });
}, },
moveIssueCard: ({ commit }, moveData) => { moveIssueCard: ({ commit }, moveData) => {
const { reordering, shouldClone, itemNotInToList } = moveData; const {
const { itemId, fromListId, toListId, moveBeforeId, moveAfterId } = moveData; reordering,
shouldClone,
itemNotInToList,
originalIndex,
itemId,
fromListId,
toListId,
moveBeforeId,
moveAfterId,
} = moveData;
commit(types.REMOVE_BOARD_ITEM_FROM_LIST, { itemId, listId: fromListId }); commit(types.REMOVE_BOARD_ITEM_FROM_LIST, { itemId, listId: fromListId });
...@@ -370,8 +379,6 @@ export default { ...@@ -370,8 +379,6 @@ export default {
} }
if (shouldClone) { if (shouldClone) {
const { originalIndex } = moveData;
commit(types.ADD_BOARD_ITEM_TO_LIST, { itemId, listId: fromListId, atIndex: originalIndex }); commit(types.ADD_BOARD_ITEM_TO_LIST, { itemId, listId: fromListId, atIndex: originalIndex });
} }
}, },
...@@ -390,9 +397,16 @@ export default { ...@@ -390,9 +397,16 @@ export default {
}, },
undoMoveIssueCard: ({ commit }, moveData) => { undoMoveIssueCard: ({ commit }, moveData) => {
const { reordering, shouldClone, itemNotInToList } = moveData; const {
const { itemId, fromListId, toListId } = moveData; reordering,
const { originalIssue, originalIndex } = moveData; shouldClone,
itemNotInToList,
itemId,
fromListId,
toListId,
originalIssue,
originalIndex,
} = moveData;
commit(types.UPDATE_BOARD_ITEM, originalIssue); commit(types.UPDATE_BOARD_ITEM, originalIssue);
...@@ -412,10 +426,7 @@ export default { ...@@ -412,10 +426,7 @@ export default {
commit(types.ADD_BOARD_ITEM_TO_LIST, { itemId, listId: fromListId, atIndex: originalIndex }); commit(types.ADD_BOARD_ITEM_TO_LIST, { itemId, listId: fromListId, atIndex: originalIndex });
}, },
requestIssueMoveListMutation: async ( updateIssueOrder: async ({ commit, dispatch, state }, { moveData, mutationVariables = {} }) => {
{ commit, dispatch, state },
{ moveData, mutationVariables = {} },
) => {
try { try {
const { itemId, fromListId, toListId, moveBeforeId, moveAfterId } = moveData; const { itemId, fromListId, toListId, moveBeforeId, moveAfterId } = moveData;
const { const {
......
...@@ -488,7 +488,7 @@ export default { ...@@ -488,7 +488,7 @@ export default {
dispatch('moveIssueCard', moveData); dispatch('moveIssueCard', moveData);
dispatch('updateMovedIssue', moveData); dispatch('updateMovedIssue', moveData);
dispatch('updateEpicForIssue', { itemId, epicId }); dispatch('updateEpicForIssue', { itemId, epicId });
dispatch('requestIssueMoveListMutation', { dispatch('updateIssueOrder', {
moveData, moveData,
mutationVariables: { epicId }, mutationVariables: { epicId },
}); });
......
...@@ -921,7 +921,7 @@ describe('moveIssue', () => { ...@@ -921,7 +921,7 @@ describe('moveIssue', () => {
{ type: 'updateMovedIssue', payload: moveData }, { type: 'updateMovedIssue', payload: moveData },
{ type: 'updateEpicForIssue', payload: { itemId: params.itemId, epicId: 'some-epic-id' } }, { type: 'updateEpicForIssue', payload: { itemId: params.itemId, epicId: 'some-epic-id' } },
{ {
type: 'requestIssueMoveListMutation', type: 'updateIssueOrder',
payload: { payload: {
moveData, moveData,
mutationVariables: { mutationVariables: {
......
...@@ -666,7 +666,7 @@ describe('moveIssue', () => { ...@@ -666,7 +666,7 @@ describe('moveIssue', () => {
expectedActions: [ expectedActions: [
{ type: 'moveIssueCard', payload: mockMoveData }, { type: 'moveIssueCard', payload: mockMoveData },
{ type: 'updateMovedIssue', payload: mockMoveData }, { type: 'updateMovedIssue', payload: mockMoveData },
{ type: 'requestIssueMoveListMutation', payload: { moveData: mockMoveData } }, { type: 'updateIssueOrder', payload: { moveData: mockMoveData } },
], ],
}); });
}); });
...@@ -938,7 +938,7 @@ describe('updateMovedIssueCard', () => { ...@@ -938,7 +938,7 @@ describe('updateMovedIssueCard', () => {
); );
}); });
describe('requestIssueMoveListMutation', () => { describe('updateIssueOrder', () => {
const issues = { const issues = {
436: mockIssue, 436: mockIssue,
437: mockIssue2, 437: mockIssue2,
...@@ -977,10 +977,7 @@ describe('requestIssueMoveListMutation', () => { ...@@ -977,10 +977,7 @@ describe('requestIssueMoveListMutation', () => {
}, },
}); });
actions.requestIssueMoveListMutation( actions.updateIssueOrder({ state, commit: () => {}, dispatch: () => {} }, { moveData });
{ state, commit: () => {}, dispatch: () => {} },
{ moveData },
);
expect(gqlClient.mutate).toHaveBeenCalledWith(mutationVariables); expect(gqlClient.mutate).toHaveBeenCalledWith(mutationVariables);
}); });
...@@ -996,7 +993,7 @@ describe('requestIssueMoveListMutation', () => { ...@@ -996,7 +993,7 @@ describe('requestIssueMoveListMutation', () => {
}); });
testAction( testAction(
actions.requestIssueMoveListMutation, actions.updateIssueOrder,
{ moveData }, { moveData },
state, state,
[ [
...@@ -1020,7 +1017,7 @@ describe('requestIssueMoveListMutation', () => { ...@@ -1020,7 +1017,7 @@ describe('requestIssueMoveListMutation', () => {
}); });
testAction( testAction(
actions.requestIssueMoveListMutation, actions.updateIssueOrder,
{ moveData }, { moveData },
state, state,
[ [
......
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