Commit 9ee7ca27 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Refetch chart data when select value stream

parent 4cf5d287
...@@ -25,11 +25,8 @@ export default { ...@@ -25,11 +25,8 @@ export default {
return Boolean(this.durationChartPlottableData.length); return Boolean(this.durationChartPlottableData.length);
}, },
}, },
mounted() {
this.fetchDurationData();
},
methods: { methods: {
...mapActions('durationChart', ['fetchDurationData', 'updateSelectedDurationChartStages']), ...mapActions('durationChart', ['updateSelectedDurationChartStages']),
onDurationStageSelect(stages) { onDurationStageSelect(stages) {
this.updateSelectedDurationChartStages(stages); this.updateSelectedDurationChartStages(stages);
}, },
......
...@@ -125,7 +125,6 @@ export const fetchCycleAnalyticsData = ({ dispatch }) => { ...@@ -125,7 +125,6 @@ export const fetchCycleAnalyticsData = ({ dispatch }) => {
return Promise.resolve() return Promise.resolve()
.then(() => dispatch('fetchValueStreams')) .then(() => dispatch('fetchValueStreams'))
.then(() => dispatch('fetchStageMedianValues'))
.then(() => dispatch('receiveCycleAnalyticsDataSuccess')) .then(() => dispatch('receiveCycleAnalyticsDataSuccess'))
.catch(error => dispatch('receiveCycleAnalyticsDataError', error)); .catch(error => dispatch('receiveCycleAnalyticsDataError', error));
}; };
...@@ -314,7 +313,10 @@ export const createValueStream = ({ commit, dispatch, getters }, data) => { ...@@ -314,7 +313,10 @@ export const createValueStream = ({ commit, dispatch, getters }, data) => {
export const setSelectedValueStream = ({ commit, dispatch }, streamId) => { export const setSelectedValueStream = ({ commit, dispatch }, streamId) => {
commit(types.SET_SELECTED_VALUE_STREAM, streamId); commit(types.SET_SELECTED_VALUE_STREAM, streamId);
return dispatch('fetchGroupStagesAndEvents'); return Promise.resolve()
.then(() => dispatch('fetchGroupStagesAndEvents'))
.then(() => dispatch('fetchStageMedianValues'))
.then(() => dispatch('durationChart/fetchDurationData'));
}; };
export const receiveValueStreamsSuccess = ({ commit, dispatch }, data = []) => { export const receiveValueStreamsSuccess = ({ commit, dispatch }, data = []) => {
......
...@@ -453,6 +453,7 @@ describe('Cycle Analytics component', () => { ...@@ -453,6 +453,7 @@ describe('Cycle Analytics component', () => {
StageNavItem, StageNavItem,
}, },
}, },
withValueStreamSelected: false,
withStageSelected: true, withStageSelected: true,
}); });
}); });
......
...@@ -91,13 +91,17 @@ describe('Cycle analytics actions', () => { ...@@ -91,13 +91,17 @@ describe('Cycle analytics actions', () => {
describe('setSelectedValueStream', () => { describe('setSelectedValueStream', () => {
const vs = { id: 'vs-1', name: 'Value stream 1' }; const vs = { id: 'vs-1', name: 'Value stream 1' };
it('dispatches the fetchCycleAnalyticsData action', () => { it('refetches the cycle analytics data', () => {
return testAction( return testAction(
actions.setSelectedValueStream, actions.setSelectedValueStream,
vs, vs,
{ ...state, selectedValueStream: {} }, { ...state, selectedValueStream: {} },
[{ type: types.SET_SELECTED_VALUE_STREAM, payload: vs }], [{ type: types.SET_SELECTED_VALUE_STREAM, payload: vs }],
[{ type: 'fetchGroupStagesAndEvents' }], [
{ type: 'fetchGroupStagesAndEvents' },
{ type: 'fetchStageMedianValues' },
{ type: 'durationChart/fetchDurationData' },
],
); );
}); });
}); });
...@@ -276,7 +280,6 @@ describe('Cycle analytics actions', () => { ...@@ -276,7 +280,6 @@ describe('Cycle analytics actions', () => {
[ [
{ type: 'requestCycleAnalyticsData' }, { type: 'requestCycleAnalyticsData' },
{ type: 'fetchValueStreams' }, { type: 'fetchValueStreams' },
{ type: 'fetchStageMedianValues' },
{ type: 'receiveCycleAnalyticsDataSuccess' }, { type: 'receiveCycleAnalyticsDataSuccess' },
], ],
); );
......
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