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