Commit 62561263 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Kushal Pandya

Fix extra cycle analytics data request

parent 8be71768
...@@ -157,7 +157,6 @@ export default { ...@@ -157,7 +157,6 @@ export default {
'removeStage', 'removeStage',
'updateStage', 'updateStage',
'reorderStage', 'reorderStage',
'setSelectedFilters',
]), ]),
...mapActions('customStages', [ ...mapActions('customStages', [
'hideForm', 'hideForm',
......
...@@ -91,6 +91,7 @@ export const fetchStageMedianValues = ({ dispatch, getters }) => { ...@@ -91,6 +91,7 @@ export const fetchStageMedianValues = ({ dispatch, getters }) => {
}; };
export const requestCycleAnalyticsData = ({ commit }) => commit(types.REQUEST_CYCLE_ANALYTICS_DATA); export const requestCycleAnalyticsData = ({ commit }) => commit(types.REQUEST_CYCLE_ANALYTICS_DATA);
export const receiveCycleAnalyticsDataSuccess = ({ commit, dispatch }) => { export const receiveCycleAnalyticsDataSuccess = ({ commit, dispatch }) => {
commit(types.RECEIVE_CYCLE_ANALYTICS_DATA_SUCCESS); commit(types.RECEIVE_CYCLE_ANALYTICS_DATA_SUCCESS);
dispatch('typeOfWork/fetchTopRankedGroupLabels'); dispatch('typeOfWork/fetchTopRankedGroupLabels');
...@@ -237,14 +238,8 @@ export const removeStage = ({ dispatch, state }, stageId) => { ...@@ -237,14 +238,8 @@ export const removeStage = ({ dispatch, state }, stageId) => {
.catch(error => dispatch('receiveRemoveStageError', error)); .catch(error => dispatch('receiveRemoveStageError', error));
}; };
export const setSelectedFilters = ({ commit, dispatch, getters }, filters = {}) => { export const setSelectedFilters = ({ commit }, filters = {}) =>
commit(types.SET_SELECTED_FILTERS, filters); commit(types.SET_SELECTED_FILTERS, filters);
const { currentGroupPath } = getters;
if (currentGroupPath) {
return dispatch('fetchCycleAnalyticsData');
}
return Promise.resolve();
};
export const initializeCycleAnalyticsSuccess = ({ commit }) => export const initializeCycleAnalyticsSuccess = ({ commit }) =>
commit(types.INITIALIZE_CYCLE_ANALYTICS_SUCCESS); commit(types.INITIALIZE_CYCLE_ANALYTICS_SUCCESS);
......
...@@ -76,10 +76,15 @@ export const fetchAssignees = ({ commit, rootGetters }, query = '') => { ...@@ -76,10 +76,15 @@ export const fetchAssignees = ({ commit, rootGetters }, query = '') => {
}); });
}; };
export const setFilters = ({ dispatch }, nextFilters) => export const setFilters = ({ dispatch }, nextFilters) => {
dispatch('setSelectedFilters', nextFilters, { root: true }); return Promise.resolve()
.then(() => dispatch('setSelectedFilters', nextFilters, { root: true }))
.then(() => dispatch('fetchCycleAnalyticsData', null, { root: true }));
};
export const initialize = ({ dispatch, commit }, initialFilters) => { export const initialize = ({ dispatch, commit }, initialFilters) => {
commit(types.INITIALIZE, initialFilters); commit(types.INITIALIZE, initialFilters);
return dispatch('setPaths', initialFilters).then(() => dispatch('setFilters', initialFilters)); return Promise.resolve()
.then(() => dispatch('setPaths', initialFilters))
.then(() => dispatch('setSelectedFilters', initialFilters, { root: true }));
}; };
---
title: Fix duplicate dispatch of 'fetchCycleAnalyticsData' action
merge_request: 37458
author:
type: fixed
...@@ -39,7 +39,7 @@ describe('Filters actions', () => { ...@@ -39,7 +39,7 @@ describe('Filters actions', () => {
selectedMilestone: 'NEXT', selectedMilestone: 'NEXT',
}; };
it('dispatches setPaths, setFilters', () => { it('dispatches setPaths, setSelectedFilters', () => {
return actions return actions
.initialize( .initialize(
{ {
...@@ -52,7 +52,9 @@ describe('Filters actions', () => { ...@@ -52,7 +52,9 @@ describe('Filters actions', () => {
.then(() => { .then(() => {
expect(mockDispatch).toHaveBeenCalledTimes(2); expect(mockDispatch).toHaveBeenCalledTimes(2);
expect(mockDispatch).toHaveBeenCalledWith('setPaths', initialData); expect(mockDispatch).toHaveBeenCalledWith('setPaths', initialData);
expect(mockDispatch).toHaveBeenCalledWith('setFilters', initialData); expect(mockDispatch).toHaveBeenCalledWith('setSelectedFilters', initialData, {
root: true,
});
}); });
}); });
...@@ -78,7 +80,7 @@ describe('Filters actions', () => { ...@@ -78,7 +80,7 @@ describe('Filters actions', () => {
selectedMilestone: 'NEXT', selectedMilestone: 'NEXT',
}; };
it('dispatches the root/setSelectedFilters action', () => { it('dispatches the root/setSelectedFilters and root/fetchCycleAnalyticsData actions', () => {
return testAction( return testAction(
actions.setFilters, actions.setFilters,
nextFilters, nextFilters,
...@@ -89,6 +91,10 @@ describe('Filters actions', () => { ...@@ -89,6 +91,10 @@ describe('Filters actions', () => {
type: 'setSelectedFilters', type: 'setSelectedFilters',
payload: nextFilters, payload: nextFilters,
}, },
{
type: 'fetchCycleAnalyticsData',
payload: null,
},
], ],
); );
}); });
...@@ -107,6 +113,10 @@ describe('Filters actions', () => { ...@@ -107,6 +113,10 @@ describe('Filters actions', () => {
selectedLabels: [filterLabels[1].title], selectedLabels: [filterLabels[1].title],
}, },
}, },
{
type: 'fetchCycleAnalyticsData',
payload: null,
},
], ],
); );
}); });
......
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