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 {
'milestones',
'timeframe',
'extendedTimeframe',
'windowResizeInProgress',
'epicsFetchInProgress',
'epicsFetchForTimeframeInProgress',
'epicsFetchResultEmpty',
......@@ -53,12 +52,7 @@ export default {
return this.timeframe[last];
},
showRoadmap() {
return (
!this.windowResizeInProgress &&
!this.epicsFetchFailure &&
!this.epicsFetchInProgress &&
!this.epicsFetchResultEmpty
);
return !this.epicsFetchFailure && !this.epicsFetchInProgress && !this.epicsFetchResultEmpty;
},
},
mounted() {
......@@ -67,7 +61,6 @@ export default {
},
methods: {
...mapActions([
'setWindowResizeInProgress',
'fetchEpics',
'fetchEpicsForTimeframe',
'extendTimeframe',
......
......@@ -19,9 +19,6 @@ import * as types from './mutation_types';
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 = (
{ epicIid, fullPath, epicsState, sortedBy, presetType, filterParams, timeframe },
defaultTimeframe,
......@@ -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 = (
{ commit, dispatch, state, getters },
{ rawEpics, newEpic, timeframeExtended },
......@@ -153,8 +148,8 @@ export const receiveChildrenSuccess = (
commit(types.RECEIVE_CHILDREN_SUCCESS, { parentItemId, children });
};
export const fetchEpics = ({ state, dispatch }) => {
dispatch('requestEpics');
export const fetchEpics = ({ state, commit, dispatch }) => {
commit(types.REQUEST_EPICS);
fetchGroupEpics(state)
.then(rawEpics => {
......@@ -163,8 +158,8 @@ export const fetchEpics = ({ state, dispatch }) => {
.catch(() => dispatch('receiveEpicsFailure'));
};
export const fetchEpicsForTimeframe = ({ state, dispatch }, { timeframe }) => {
dispatch('requestEpicsForTimeframe');
export const fetchEpicsForTimeframe = ({ state, commit, dispatch }, { timeframe }) => {
commit(types.REQUEST_EPICS_FOR_TIMEFRAME);
return fetchGroupEpics(state, timeframe)
.then(rawEpics => {
......
......@@ -2,8 +2,6 @@ export const SET_INITIAL_DATA = 'SET_INITIAL_DATA';
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 REQUEST_EPICS = 'REQUEST_EPICS';
......
......@@ -11,10 +11,6 @@ export default {
state.epics = epics;
},
[types.SET_WINDOW_RESIZE_IN_PROGRESS](state, inProgress) {
state.windowResizeInProgress = inProgress;
},
[types.UPDATE_EPIC_IDS](state, epicId) {
state.epicIds.push(epicId);
},
......
......@@ -26,7 +26,6 @@ export default () => ({
// UI Flags
defaultInnerHeight: 0,
isChildEpics: false,
windowResizeInProgress: false,
epicsFetchInProgress: false,
epicsFetchForTimeframeInProgress: false,
epicsFetchFailure: false,
......
......@@ -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', () => {
it('should set formatted epics array and epicId to IDs array in state based on provided epics list', () => {
return testAction(
......@@ -216,7 +186,7 @@ describe('Roadmap Vuex Actions', () => {
});
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(
Promise.resolve({
data: mockGroupEpicsQueryResponse.data,
......@@ -227,11 +197,12 @@ describe('Roadmap Vuex Actions', () => {
actions.fetchEpics,
null,
state,
[],
[
{
type: 'requestEpics',
type: types.REQUEST_EPICS,
},
],
[
{
type: 'receiveEpicsSuccess',
payload: { rawEpics: mockGroupEpicsQueryResponseFormatted },
......@@ -242,18 +213,19 @@ describe('Roadmap Vuex Actions', () => {
});
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'));
return testAction(
actions.fetchEpics,
null,
state,
[],
[
{
type: 'requestEpics',
type: types.REQUEST_EPICS,
},
],
[
{
type: 'receiveEpicsFailure',
},
......@@ -265,7 +237,7 @@ describe('Roadmap Vuex Actions', () => {
describe('fetchEpicsForTimeframe', () => {
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(
Promise.resolve({
data: mockGroupEpicsQueryResponse.data,
......@@ -276,11 +248,12 @@ describe('Roadmap Vuex Actions', () => {
actions.fetchEpicsForTimeframe,
{ timeframe: mockTimeframeMonths },
state,
[],
[
{
type: 'requestEpicsForTimeframe',
type: types.REQUEST_EPICS_FOR_TIMEFRAME,
},
],
[
{
type: 'receiveEpicsSuccess',
payload: {
......@@ -295,18 +268,19 @@ describe('Roadmap Vuex Actions', () => {
});
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();
return testAction(
actions.fetchEpicsForTimeframe,
{ timeframe: mockTimeframeMonths },
state,
[],
[
{
type: 'requestEpicsForTimeframe',
type: types.REQUEST_EPICS_FOR_TIMEFRAME,
},
],
[
{
type: 'receiveEpicsFailure',
},
......
......@@ -15,7 +15,6 @@ describe('Roadmap Store Mutations', () => {
describe('SET_INITIAL_DATA', () => {
it('Should set initial Roadmap data to state', () => {
const initialData = {
windowResizeInProgress: false,
epicsFetchInProgress: false,
epicsFetchForTimeframeInProgress: false,
epicsFetchFailure: false,
......@@ -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', () => {
it('Should insert provided epicId to epicIds array in state', () => {
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