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