Commit e3e4d5c0 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '215077-remove-unused-roadmap-state' into 'master'

Remove unused state in Epics Roadmap

See merge request gitlab-org/gitlab!30984
parents 4c36ac03 75f83901
...@@ -37,7 +37,6 @@ export default { ...@@ -37,7 +37,6 @@ export default {
'milestones', 'milestones',
'timeframe', 'timeframe',
'extendedTimeframe', 'extendedTimeframe',
'windowResizeInProgress',
'epicsFetchInProgress', 'epicsFetchInProgress',
'epicsFetchForTimeframeInProgress', 'epicsFetchForTimeframeInProgress',
'epicsFetchResultEmpty', 'epicsFetchResultEmpty',
...@@ -53,12 +52,7 @@ export default { ...@@ -53,12 +52,7 @@ export default {
return this.timeframe[last]; return this.timeframe[last];
}, },
showRoadmap() { showRoadmap() {
return ( return !this.epicsFetchFailure && !this.epicsFetchInProgress && !this.epicsFetchResultEmpty;
!this.windowResizeInProgress &&
!this.epicsFetchFailure &&
!this.epicsFetchInProgress &&
!this.epicsFetchResultEmpty
);
}, },
}, },
mounted() { mounted() {
...@@ -67,7 +61,6 @@ export default { ...@@ -67,7 +61,6 @@ export default {
}, },
methods: { methods: {
...mapActions([ ...mapActions([
'setWindowResizeInProgress',
'fetchEpics', 'fetchEpics',
'fetchEpicsForTimeframe', 'fetchEpicsForTimeframe',
'extendTimeframe', 'extendTimeframe',
......
...@@ -19,9 +19,6 @@ import * as types from './mutation_types'; ...@@ -19,9 +19,6 @@ import * as types from './mutation_types';
export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DATA, data); export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DATA, data);
export const setWindowResizeInProgress = ({ commit }, inProgress) =>
commit(types.SET_WINDOW_RESIZE_IN_PROGRESS, inProgress);
const fetchGroupEpics = ( const fetchGroupEpics = (
{ epicIid, fullPath, epicsState, sortedBy, presetType, filterParams, timeframe }, { epicIid, fullPath, epicsState, sortedBy, presetType, filterParams, timeframe },
defaultTimeframe, defaultTimeframe,
...@@ -80,8 +77,6 @@ export const fetchChildrenEpics = (state, { parentItem }) => { ...@@ -80,8 +77,6 @@ export const fetchChildrenEpics = (state, { parentItem }) => {
}); });
}; };
export const requestEpics = ({ commit }) => commit(types.REQUEST_EPICS);
export const requestEpicsForTimeframe = ({ commit }) => commit(types.REQUEST_EPICS_FOR_TIMEFRAME);
export const receiveEpicsSuccess = ( export const receiveEpicsSuccess = (
{ commit, dispatch, state, getters }, { commit, dispatch, state, getters },
{ rawEpics, newEpic, timeframeExtended }, { rawEpics, newEpic, timeframeExtended },
...@@ -153,8 +148,8 @@ export const receiveChildrenSuccess = ( ...@@ -153,8 +148,8 @@ export const receiveChildrenSuccess = (
commit(types.RECEIVE_CHILDREN_SUCCESS, { parentItemId, children }); commit(types.RECEIVE_CHILDREN_SUCCESS, { parentItemId, children });
}; };
export const fetchEpics = ({ state, dispatch }) => { export const fetchEpics = ({ state, commit, dispatch }) => {
dispatch('requestEpics'); commit(types.REQUEST_EPICS);
fetchGroupEpics(state) fetchGroupEpics(state)
.then(rawEpics => { .then(rawEpics => {
...@@ -163,8 +158,8 @@ export const fetchEpics = ({ state, dispatch }) => { ...@@ -163,8 +158,8 @@ export const fetchEpics = ({ state, dispatch }) => {
.catch(() => dispatch('receiveEpicsFailure')); .catch(() => dispatch('receiveEpicsFailure'));
}; };
export const fetchEpicsForTimeframe = ({ state, dispatch }, { timeframe }) => { export const fetchEpicsForTimeframe = ({ state, commit, dispatch }, { timeframe }) => {
dispatch('requestEpicsForTimeframe'); commit(types.REQUEST_EPICS_FOR_TIMEFRAME);
return fetchGroupEpics(state, timeframe) return fetchGroupEpics(state, timeframe)
.then(rawEpics => { .then(rawEpics => {
......
...@@ -2,8 +2,6 @@ export const SET_INITIAL_DATA = 'SET_INITIAL_DATA'; ...@@ -2,8 +2,6 @@ export const SET_INITIAL_DATA = 'SET_INITIAL_DATA';
export const SET_EPICS = 'SET_EPICS'; export const SET_EPICS = 'SET_EPICS';
export const SET_WINDOW_RESIZE_IN_PROGRESS = 'SET_WINDOW_RESIZE_IN_PROGRESS';
export const UPDATE_EPIC_IDS = 'UPDATE_EPIC_IDS'; export const UPDATE_EPIC_IDS = 'UPDATE_EPIC_IDS';
export const REQUEST_EPICS = 'REQUEST_EPICS'; export const REQUEST_EPICS = 'REQUEST_EPICS';
......
...@@ -11,10 +11,6 @@ export default { ...@@ -11,10 +11,6 @@ export default {
state.epics = epics; state.epics = epics;
}, },
[types.SET_WINDOW_RESIZE_IN_PROGRESS](state, inProgress) {
state.windowResizeInProgress = inProgress;
},
[types.UPDATE_EPIC_IDS](state, epicId) { [types.UPDATE_EPIC_IDS](state, epicId) {
state.epicIds.push(epicId); state.epicIds.push(epicId);
}, },
......
...@@ -26,7 +26,6 @@ export default () => ({ ...@@ -26,7 +26,6 @@ export default () => ({
// UI Flags // UI Flags
defaultInnerHeight: 0, defaultInnerHeight: 0,
isChildEpics: false, isChildEpics: false,
windowResizeInProgress: false,
epicsFetchInProgress: false, epicsFetchInProgress: false,
epicsFetchForTimeframeInProgress: false, epicsFetchForTimeframeInProgress: false,
epicsFetchFailure: false, epicsFetchFailure: false,
......
...@@ -70,36 +70,6 @@ describe('Roadmap Vuex Actions', () => { ...@@ -70,36 +70,6 @@ describe('Roadmap Vuex Actions', () => {
}); });
}); });
describe('setWindowResizeInProgress', () => {
it('should set value of `state.windowResizeInProgress` based on provided value', () => {
return testAction(
actions.setWindowResizeInProgress,
true,
state,
[{ type: types.SET_WINDOW_RESIZE_IN_PROGRESS, payload: true }],
[],
);
});
});
describe('requestEpics', () => {
it('should set `epicsFetchInProgress` to true', () => {
return testAction(actions.requestEpics, {}, state, [{ type: 'REQUEST_EPICS' }], []);
});
});
describe('requestEpicsForTimeframe', () => {
it('should set `epicsFetchForTimeframeInProgress` to true', () => {
return testAction(
actions.requestEpicsForTimeframe,
{},
state,
[{ type: types.REQUEST_EPICS_FOR_TIMEFRAME }],
[],
);
});
});
describe('receiveEpicsSuccess', () => { describe('receiveEpicsSuccess', () => {
it('should set formatted epics array and epicId to IDs array in state based on provided epics list', () => { it('should set formatted epics array and epicId to IDs array in state based on provided epics list', () => {
return testAction( return testAction(
...@@ -216,7 +186,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -216,7 +186,7 @@ describe('Roadmap Vuex Actions', () => {
}); });
describe('success', () => { describe('success', () => {
it('should dispatch requestEpics and receiveEpicsSuccess when request is successful', () => { it('should perform REQUEST_EPICS mutation dispatch receiveEpicsSuccess action when request is successful', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue( jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: mockGroupEpicsQueryResponse.data, data: mockGroupEpicsQueryResponse.data,
...@@ -227,11 +197,12 @@ describe('Roadmap Vuex Actions', () => { ...@@ -227,11 +197,12 @@ describe('Roadmap Vuex Actions', () => {
actions.fetchEpics, actions.fetchEpics,
null, null,
state, state,
[],
[ [
{ {
type: 'requestEpics', type: types.REQUEST_EPICS,
}, },
],
[
{ {
type: 'receiveEpicsSuccess', type: 'receiveEpicsSuccess',
payload: { rawEpics: mockGroupEpicsQueryResponseFormatted }, payload: { rawEpics: mockGroupEpicsQueryResponseFormatted },
...@@ -242,18 +213,19 @@ describe('Roadmap Vuex Actions', () => { ...@@ -242,18 +213,19 @@ describe('Roadmap Vuex Actions', () => {
}); });
describe('failure', () => { describe('failure', () => {
it('should dispatch requestEpics and receiveEpicsFailure when request fails', () => { it('should perform REQUEST_EPICS mutation and dispatch receiveEpicsFailure action when request fails', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockRejectedValue(new Error('error message')); jest.spyOn(epicUtils.gqClient, 'query').mockRejectedValue(new Error('error message'));
return testAction( return testAction(
actions.fetchEpics, actions.fetchEpics,
null, null,
state, state,
[],
[ [
{ {
type: 'requestEpics', type: types.REQUEST_EPICS,
}, },
],
[
{ {
type: 'receiveEpicsFailure', type: 'receiveEpicsFailure',
}, },
...@@ -265,7 +237,7 @@ describe('Roadmap Vuex Actions', () => { ...@@ -265,7 +237,7 @@ describe('Roadmap Vuex Actions', () => {
describe('fetchEpicsForTimeframe', () => { describe('fetchEpicsForTimeframe', () => {
describe('success', () => { describe('success', () => {
it('should dispatch requestEpicsForTimeframe and receiveEpicsSuccess when request is successful', () => { it('should perform REQUEST_EPICS_FOR_TIMEFRAME mutation and dispatch receiveEpicsSuccess action when request is successful', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue( jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: mockGroupEpicsQueryResponse.data, data: mockGroupEpicsQueryResponse.data,
...@@ -276,11 +248,12 @@ describe('Roadmap Vuex Actions', () => { ...@@ -276,11 +248,12 @@ describe('Roadmap Vuex Actions', () => {
actions.fetchEpicsForTimeframe, actions.fetchEpicsForTimeframe,
{ timeframe: mockTimeframeMonths }, { timeframe: mockTimeframeMonths },
state, state,
[],
[ [
{ {
type: 'requestEpicsForTimeframe', type: types.REQUEST_EPICS_FOR_TIMEFRAME,
}, },
],
[
{ {
type: 'receiveEpicsSuccess', type: 'receiveEpicsSuccess',
payload: { payload: {
...@@ -295,18 +268,19 @@ describe('Roadmap Vuex Actions', () => { ...@@ -295,18 +268,19 @@ describe('Roadmap Vuex Actions', () => {
}); });
describe('failure', () => { describe('failure', () => {
it('should dispatch requestEpicsForTimeframe and requestEpicsFailure when request fails', () => { it('should perform REQUEST_EPICS_FOR_TIMEFRAME mutation and dispatch requestEpicsFailure action when request fails', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockRejectedValue(); jest.spyOn(epicUtils.gqClient, 'query').mockRejectedValue();
return testAction( return testAction(
actions.fetchEpicsForTimeframe, actions.fetchEpicsForTimeframe,
{ timeframe: mockTimeframeMonths }, { timeframe: mockTimeframeMonths },
state, state,
[],
[ [
{ {
type: 'requestEpicsForTimeframe', type: types.REQUEST_EPICS_FOR_TIMEFRAME,
}, },
],
[
{ {
type: 'receiveEpicsFailure', type: 'receiveEpicsFailure',
}, },
......
...@@ -15,7 +15,6 @@ describe('Roadmap Store Mutations', () => { ...@@ -15,7 +15,6 @@ describe('Roadmap Store Mutations', () => {
describe('SET_INITIAL_DATA', () => { describe('SET_INITIAL_DATA', () => {
it('Should set initial Roadmap data to state', () => { it('Should set initial Roadmap data to state', () => {
const initialData = { const initialData = {
windowResizeInProgress: false,
epicsFetchInProgress: false, epicsFetchInProgress: false,
epicsFetchForTimeframeInProgress: false, epicsFetchForTimeframeInProgress: false,
epicsFetchFailure: false, epicsFetchFailure: false,
...@@ -48,14 +47,6 @@ describe('Roadmap Store Mutations', () => { ...@@ -48,14 +47,6 @@ describe('Roadmap Store Mutations', () => {
}); });
}); });
describe('SET_WINDOW_RESIZE_IN_PROGRESS', () => {
it('Should set value of `state.windowResizeInProgress` based on provided value', () => {
mutations[types.SET_WINDOW_RESIZE_IN_PROGRESS](state, true);
expect(state.windowResizeInProgress).toEqual(true);
});
});
describe('UPDATE_EPIC_IDS', () => { describe('UPDATE_EPIC_IDS', () => {
it('Should insert provided epicId to epicIds array in state', () => { it('Should insert provided epicId to epicIds array in state', () => {
mutations[types.UPDATE_EPIC_IDS](state, 22); mutations[types.UPDATE_EPIC_IDS](state, 22);
......
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