Commit 43c7b116 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Remove custom stages vuex code from root module

Replaces vuex code for custom stages in the
base vue file with the correct code from
the new module
parent 0f862023
...@@ -57,22 +57,24 @@ export default { ...@@ -57,22 +57,24 @@ export default {
'isLoading', 'isLoading',
'isLoadingStage', 'isLoadingStage',
'isEmptyStage', 'isEmptyStage',
'isSavingCustomStage',
'isCreatingCustomStage',
'isEditingCustomStage',
'selectedGroup', 'selectedGroup',
'selectedProjects', 'selectedProjects',
'selectedStage', 'selectedStage',
'stages', 'stages',
'summary', 'summary',
'currentStageEvents', 'currentStageEvents',
'customStageFormEvents',
'errorCode', 'errorCode',
'startDate', 'startDate',
'endDate', 'endDate',
'medians', 'medians',
'customStageFormErrors', ]),
'customStageFormInitialData', ...mapState('customStages', [
'isSavingCustomStage',
'isCreatingCustomStage',
'isEditingCustomStage',
'formEvents',
'formErrors',
'formInitialData',
]), ]),
...mapGetters([ ...mapGetters([
'hasNoAccessError', 'hasNoAccessError',
...@@ -81,8 +83,8 @@ export default { ...@@ -81,8 +83,8 @@ export default {
'selectedProjectIds', 'selectedProjectIds',
'enableCustomOrdering', 'enableCustomOrdering',
'cycleAnalyticsRequestParams', 'cycleAnalyticsRequestParams',
'customStageFormActive',
]), ]),
...mapGetters('customStages', ['customStageFormActive']),
shouldRenderEmptyState() { shouldRenderEmptyState() {
return !this.selectedGroup; return !this.selectedGroup;
}, },
...@@ -130,18 +132,20 @@ export default { ...@@ -130,18 +132,20 @@ export default {
'setSelectedGroup', 'setSelectedGroup',
'setSelectedProjects', 'setSelectedProjects',
'setSelectedStage', 'setSelectedStage',
'hideCustomStageForm',
'showCustomStageForm',
'showEditCustomStageForm',
'setDateRange', 'setDateRange',
'createCustomStage',
'updateStage', 'updateStage',
'removeStage', 'removeStage',
'setFeatureFlags', 'setFeatureFlags',
'clearCustomStageFormErrors',
'updateStage', 'updateStage',
'reorderStage', 'reorderStage',
]), ]),
...mapActions('customStages', [
'hideForm',
'showCreateForm',
'showEditForm',
'createStage',
'clearFormErrors',
]),
onGroupSelect(group) { onGroupSelect(group) {
this.setSelectedGroup(group); this.setSelectedGroup(group);
this.fetchCycleAnalyticsData(); this.fetchCycleAnalyticsData();
...@@ -151,18 +155,18 @@ export default { ...@@ -151,18 +155,18 @@ export default {
this.fetchCycleAnalyticsData(); this.fetchCycleAnalyticsData();
}, },
onStageSelect(stage) { onStageSelect(stage) {
this.hideCustomStageForm(); this.hideForm();
this.setSelectedStage(stage); this.setSelectedStage(stage);
this.fetchStageData(this.selectedStage.slug); this.fetchStageData(this.selectedStage.slug);
}, },
onShowAddStageForm() { onShowAddStageForm() {
this.showCustomStageForm(); this.showCreateForm();
}, },
onShowEditStageForm(initData = {}) { onShowEditStageForm(initData = {}) {
this.showEditCustomStageForm(initData); this.showEditForm(initData);
}, },
onCreateCustomStage(data) { onCreateCustomStage(data) {
this.createCustomStage(data); this.createStage(data);
}, },
onUpdateCustomStage(data) { onUpdateCustomStage(data) {
this.updateStage(data); this.updateStage(data);
...@@ -293,14 +297,14 @@ export default { ...@@ -293,14 +297,14 @@ export default {
</template> </template>
<template v-if="customStageFormActive" #content> <template v-if="customStageFormActive" #content>
<custom-stage-form <custom-stage-form
:events="customStageFormEvents" :events="formEvents"
:is-saving-custom-stage="isSavingCustomStage" :is-saving-custom-stage="isSavingCustomStage"
:initial-fields="customStageFormInitialData" :initial-fields="formInitialData"
:is-editing-custom-stage="isEditingCustomStage" :is-editing-custom-stage="isEditingCustomStage"
:errors="customStageFormErrors" :errors="formErrors"
@createStage="onCreateCustomStage" @createStage="onCreateCustomStage"
@updateStage="onUpdateCustomStage" @updateStage="onUpdateCustomStage"
@clearErrors="$emit('clearCustomStageFormErrors')" @clearErrors="$emit('clearFormErrors')"
/> />
</template> </template>
</stage-table> </stage-table>
......
...@@ -103,11 +103,12 @@ export const receiveCycleAnalyticsDataSuccess = ({ commit, dispatch }) => { ...@@ -103,11 +103,12 @@ export const receiveCycleAnalyticsDataSuccess = ({ commit, dispatch }) => {
dispatch('typeOfWork/fetchTopRankedGroupLabels'); dispatch('typeOfWork/fetchTopRankedGroupLabels');
}; };
export const receiveCycleAnalyticsDataError = ({ commit }, { response }) => { export const receiveCycleAnalyticsDataError = ({ commit }, error) => {
const { status } = response; console.log('error', error);
const { status = null } = error; // non api errors thrown wont have a status field
commit(types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR, status); commit(types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR, status);
if (status !== httpStatus.FORBIDDEN) if (!status || status !== httpStatus.FORBIDDEN)
createFlash(__('There was an error while fetching value stream analytics data.')); createFlash(__('There was an error while fetching value stream analytics data.'));
}; };
...@@ -122,50 +123,16 @@ export const fetchCycleAnalyticsData = ({ dispatch }) => { ...@@ -122,50 +123,16 @@ export const fetchCycleAnalyticsData = ({ dispatch }) => {
.catch(error => dispatch('receiveCycleAnalyticsDataError', error)); .catch(error => dispatch('receiveCycleAnalyticsDataError', error));
}; };
export const hideCustomStageForm = ({ commit }) => { export const requestGroupStages = ({ commit }) => commit(types.REQUEST_GROUP_STAGES);
commit(types.HIDE_CUSTOM_STAGE_FORM);
removeFlash();
};
export const showCustomStageForm = ({ commit }) => {
commit(types.SHOW_CUSTOM_STAGE_FORM);
removeFlash();
};
export const showEditCustomStageForm = ({ commit, dispatch }, selectedStage = {}) => {
const {
id = null,
name = null,
startEventIdentifier = null,
startEventLabel: { id: startEventLabelId = null } = {},
endEventIdentifier = null,
endEventLabel: { id: endEventLabelId = null } = {},
} = selectedStage;
commit(types.SHOW_EDIT_CUSTOM_STAGE_FORM, {
id,
name,
startEventIdentifier,
startEventLabelId,
endEventIdentifier,
endEventLabelId,
});
dispatch('setSelectedStage', selectedStage);
removeFlash();
};
export const requestGroupStagesAndEvents = ({ commit }) => export const receiveGroupStagesError = ({ commit }, error) => {
commit(types.REQUEST_GROUP_STAGES_AND_EVENTS); commit(types.RECEIVE_GROUP_STAGES_ERROR, error);
export const receiveGroupStagesAndEventsError = ({ commit }, error) => {
commit(types.RECEIVE_GROUP_STAGES_AND_EVENTS_ERROR, error);
createFlash(__('There was an error fetching value stream analytics stages.')); createFlash(__('There was an error fetching value stream analytics stages.'));
}; };
export const receiveGroupStagesAndEventsSuccess = ({ state, commit, dispatch }, data) => { export const receiveGroupStagesSuccess = ({ commit, dispatch }, stages) => {
commit(types.RECEIVE_GROUP_STAGES_AND_EVENTS_SUCCESS, data); commit(types.RECEIVE_GROUP_STAGES_SUCCESS, stages);
const { stages = [] } = state; if (stages.length) {
if (stages && stages.length) {
const [firstStage] = stages; const [firstStage] = stages;
dispatch('setSelectedStage', firstStage); dispatch('setSelectedStage', firstStage);
dispatch('fetchStageData', firstStage.slug); dispatch('fetchStageData', firstStage.slug);
...@@ -182,70 +149,25 @@ export const fetchGroupStagesAndEvents = ({ state, dispatch, getters }) => { ...@@ -182,70 +149,25 @@ export const fetchGroupStagesAndEvents = ({ state, dispatch, getters }) => {
const { const {
cycleAnalyticsRequestParams: { created_after, project_ids }, cycleAnalyticsRequestParams: { created_after, project_ids },
} = getters; } = getters;
dispatch('requestGroupStagesAndEvents'); dispatch('requestGroupStages');
dispatch('customStages/setStageEvents', []);
return Api.cycleAnalyticsGroupStagesAndEvents(fullPath, { return Api.cycleAnalyticsGroupStagesAndEvents(fullPath, {
start_date: created_after, start_date: created_after,
project_ids, project_ids,
}) })
.then(({ data }) => dispatch('receiveGroupStagesAndEventsSuccess', data)) .then(({ data: { stages = [], events = [] } }) => {
dispatch('receiveGroupStagesSuccess', stages);
dispatch('customStages/setStageEvents', events);
})
.catch(error => .catch(error =>
handleErrorOrRethrow({ handleErrorOrRethrow({
error, error,
action: () => dispatch('receiveGroupStagesAndEventsError', error), action: () => dispatch('receiveGroupStagesError', error),
}), }),
); );
}; };
export const clearCustomStageFormErrors = ({ commit }) => {
commit(types.CLEAR_CUSTOM_STAGE_FORM_ERRORS);
removeFlash();
};
export const requestCreateCustomStage = ({ commit }) => commit(types.REQUEST_CREATE_CUSTOM_STAGE);
export const receiveCreateCustomStageSuccess = ({ commit, dispatch }, { data: { title } }) => {
commit(types.RECEIVE_CREATE_CUSTOM_STAGE_SUCCESS);
createFlash(sprintf(__(`Your custom stage '%{title}' was created`), { title }), 'notice');
return Promise.resolve()
.then(() => dispatch('fetchGroupStagesAndEvents'))
.catch(() => {
createFlash(__('There was a problem refreshing the data, please try again'));
});
};
export const receiveCreateCustomStageError = (
{ commit },
{ status = 400, errors = {}, data = {} } = {},
) => {
commit(types.RECEIVE_CREATE_CUSTOM_STAGE_ERROR, { errors });
const { name = null } = data;
const flashMessage =
name && isStageNameExistsError({ status, errors })
? sprintf(__(`'%{name}' stage already exists`), { name })
: __('There was a problem saving your custom stage, please try again');
createFlash(flashMessage);
};
export const createCustomStage = ({ dispatch, state }, data) => {
const {
selectedGroup: { fullPath },
} = state;
dispatch('requestCreateCustomStage');
return Api.cycleAnalyticsCreateStage(fullPath, data)
.then(response => {
const { status, data: responseData } = response;
return dispatch('receiveCreateCustomStageSuccess', { status, data: responseData });
})
.catch(({ response } = {}) => {
const { data: { message, errors } = null, status = 400 } = response;
dispatch('receiveCreateCustomStageError', { data, message, errors, status });
});
};
export const requestUpdateStage = ({ commit }) => commit(types.REQUEST_UPDATE_STAGE); export const requestUpdateStage = ({ commit }) => commit(types.REQUEST_UPDATE_STAGE);
export const receiveUpdateStageSuccess = ({ commit, dispatch }, updatedData) => { export const receiveUpdateStageSuccess = ({ commit, dispatch }, updatedData) => {
commit(types.RECEIVE_UPDATE_STAGE_SUCCESS); commit(types.RECEIVE_UPDATE_STAGE_SUCCESS);
......
...@@ -4,6 +4,7 @@ import * as actions from './actions'; ...@@ -4,6 +4,7 @@ import * as actions from './actions';
import * as getters from './getters'; import * as getters from './getters';
import mutations from './mutations'; import mutations from './mutations';
import state from './state'; import state from './state';
import customStages from './modules/custom_stages/index';
import durationChart from './modules/duration_chart/index'; import durationChart from './modules/duration_chart/index';
import typeOfWork from './modules/type_of_work/index'; import typeOfWork from './modules/type_of_work/index';
...@@ -15,5 +16,5 @@ export default () => ...@@ -15,5 +16,5 @@ export default () =>
getters, getters,
mutations, mutations,
state, state,
modules: { durationChart, typeOfWork }, modules: { customStages, durationChart, typeOfWork },
}); });
...@@ -15,17 +15,17 @@ const isStageNameExistsError = ({ status, errors }) => { ...@@ -15,17 +15,17 @@ const isStageNameExistsError = ({ status, errors }) => {
export const setStageEvents = ({ commit }, data) => commit(types.SET_STAGE_EVENTS, data); export const setStageEvents = ({ commit }, data) => commit(types.SET_STAGE_EVENTS, data);
export const hideCustomStageForm = ({ commit }) => { export const hideForm = ({ commit }) => {
commit(types.HIDE_CUSTOM_STAGE_FORM); commit(types.HIDE_FORM);
removeFlash(); removeFlash();
}; };
export const showCustomStageForm = ({ commit }) => { export const showCreateForm = ({ commit }) => {
commit(types.SHOW_CUSTOM_STAGE_FORM); commit(types.SHOW_CREATE_FORM);
removeFlash(); removeFlash();
}; };
export const showEditCustomStageForm = ({ commit, dispatch }, selectedStage = {}) => { export const showEditForm = ({ commit, dispatch }, selectedStage = {}) => {
const { const {
id = null, id = null,
name = null, name = null,
...@@ -35,7 +35,7 @@ export const showEditCustomStageForm = ({ commit, dispatch }, selectedStage = {} ...@@ -35,7 +35,7 @@ export const showEditCustomStageForm = ({ commit, dispatch }, selectedStage = {}
endEventLabel: { id: endEventLabelId = null } = {}, endEventLabel: { id: endEventLabelId = null } = {},
} = selectedStage; } = selectedStage;
commit(types.SHOW_EDIT_CUSTOM_STAGE_FORM, { commit(types.SHOW_EDIT_FORM, {
id, id,
name, name,
startEventIdentifier, startEventIdentifier,
...@@ -47,14 +47,14 @@ export const showEditCustomStageForm = ({ commit, dispatch }, selectedStage = {} ...@@ -47,14 +47,14 @@ export const showEditCustomStageForm = ({ commit, dispatch }, selectedStage = {}
removeFlash(); removeFlash();
}; };
export const clearCustomStageFormErrors = ({ commit }) => { export const clearFormErrors = ({ commit }) => {
commit(types.CLEAR_CUSTOM_STAGE_FORM_ERRORS); commit(types.CLEAR_FORM_ERRORS);
removeFlash(); removeFlash();
}; };
export const requestCreateCustomStage = ({ commit }) => commit(types.REQUEST_CREATE_CUSTOM_STAGE); export const requestCreateStage = ({ commit }) => commit(types.REQUEST_CREATE_STAGE);
export const receiveCreateCustomStageSuccess = ({ commit, dispatch }, { data: { title } }) => { export const receiveCreateStageSuccess = ({ commit, dispatch }, { data: { title } }) => {
commit(types.RECEIVE_CREATE_CUSTOM_STAGE_SUCCESS); commit(types.RECEIVE_CREATE_STAGE_SUCCESS);
createFlash(sprintf(__(`Your custom stage '%{title}' was created`), { title }), 'notice'); createFlash(sprintf(__(`Your custom stage '%{title}' was created`), { title }), 'notice');
return Promise.resolve() return Promise.resolve()
...@@ -64,11 +64,11 @@ export const receiveCreateCustomStageSuccess = ({ commit, dispatch }, { data: { ...@@ -64,11 +64,11 @@ export const receiveCreateCustomStageSuccess = ({ commit, dispatch }, { data: {
}); });
}; };
export const receiveCreateCustomStageError = ( export const receiveCreateStageError = (
{ commit }, { commit },
{ status = 400, errors = {}, data = {} } = {}, { status = 400, errors = {}, data = {} } = {},
) => { ) => {
commit(types.RECEIVE_CREATE_CUSTOM_STAGE_ERROR, { errors }); commit(types.RECEIVE_CREATE_STAGE_ERROR, { errors });
const { name = null } = data; const { name = null } = data;
const flashMessage = const flashMessage =
name && isStageNameExistsError({ status, errors }) name && isStageNameExistsError({ status, errors })
...@@ -78,20 +78,20 @@ export const receiveCreateCustomStageError = ( ...@@ -78,20 +78,20 @@ export const receiveCreateCustomStageError = (
createFlash(flashMessage); createFlash(flashMessage);
}; };
export const createCustomStage = ({ dispatch, state }, data) => { export const createStage = ({ dispatch, state }, data) => {
const { const {
selectedGroup: { fullPath }, selectedGroup: { fullPath },
} = state; } = state;
dispatch('requestCreateCustomStage'); dispatch('requestCreateStage');
return Api.cycleAnalyticsCreateStage(fullPath, data) return Api.cycleAnalyticsCreateStage(fullPath, data)
.then(response => { .then(response => {
const { status, data: responseData } = response; const { status, data: responseData } = response;
return dispatch('receiveCreateCustomStageSuccess', { status, data: responseData }); return dispatch('receiveCreateStageSuccess', { status, data: responseData });
}) })
.catch(({ response } = {}) => { .catch(({ response } = {}) => {
const { data: { message, errors } = null, status = 400 } = response; const { data: { message, errors } = null, status = 400 } = response;
dispatch('receiveCreateCustomStageError', { data, message, errors, status }); dispatch('receiveCreateStageError', { data, message, errors, status });
}); });
}; };
export const SET_STAGE_EVENTS = 'SET_STAGE_EVENTS'; export const SET_STAGE_EVENTS = 'SET_STAGE_EVENTS';
export const HIDE_CUSTOM_STAGE_FORM = 'HIDE_CUSTOM_STAGE_FORM'; export const HIDE_FORM = 'SHOW_FORM';
export const SHOW_CUSTOM_STAGE_FORM = 'SHOW_CUSTOM_STAGE_FORM'; export const SHOW_CREATE_FORM = 'SHOW_CREATE_FORM';
export const SHOW_EDIT_CUSTOM_STAGE_FORM = 'SHOW_EDIT_CUSTOM_STAGE_FORM'; export const SHOW_EDIT_FORM = 'SHOW_EDIT_FORM';
export const CLEAR_CUSTOM_STAGE_FORM_ERRORS = 'CLEAR_CUSTOM_STAGE_FORM_ERRORS'; export const CLEAR_FORM_ERRORS = 'CLEAR_FORM_ERRORS';
export const REQUEST_CREATE_CUSTOM_STAGE = 'REQUEST_CREATE_CUSTOM_STAGE'; export const REQUEST_CREATE_STAGE = 'REQUEST_CREATE_STAGE';
export const RECEIVE_CREATE_CUSTOM_STAGE_SUCCESS = 'RECEIVE_CREATE_CUSTOM_STAGE_SUCCESS'; export const RECEIVE_CREATE_STAGE_SUCCESS = 'RECEIVE_CREATE_STAGE_SUCCESS';
export const RECEIVE_CREATE_CUSTOM_STAGE_ERROR = 'RECEIVE_CREATE_CUSTOM_STAGE_ERROR'; export const RECEIVE_CREATE_STAGE_ERROR = 'RECEIVE_CREATE_STAGE_ERROR';
...@@ -5,35 +5,35 @@ export default { ...@@ -5,35 +5,35 @@ export default {
[types.SET_STAGE_EVENTS](state, data = []) { [types.SET_STAGE_EVENTS](state, data = []) {
state.formEvents = data.map(ev => convertObjectPropsToCamelCase(ev, { deep: true })); state.formEvents = data.map(ev => convertObjectPropsToCamelCase(ev, { deep: true }));
}, },
[types.SHOW_CUSTOM_STAGE_FORM](state) { [types.SHOW_CREATE_FORM](state) {
state.isCreating = true; state.isCreatingCustomStage = true;
state.formInitialData = null; state.formInitialData = null;
state.formErrors = null; state.formErrors = null;
}, },
[types.SHOW_EDIT_CUSTOM_STAGE_FORM](state, initialData) { [types.SHOW_EDIT_FORM](state, initialData) {
state.isEditing = true; state.isEditingCustomStage = true;
state.formInitialData = initialData; state.formInitialData = initialData;
state.formErrors = null; state.formErrors = null;
}, },
[types.HIDE_CUSTOM_STAGE_FORM](state) { [types.HIDE_FORM](state) {
state.isEditing = false; state.isEditingCustomStage = false;
state.isCreating = false; state.isCreatingCustomStage = false;
state.formInitialData = null; state.formInitialData = null;
state.formErrors = null; state.formErrors = null;
}, },
[types.CLEAR_CUSTOM_STAGE_FORM_ERRORS](state) { [types.CLEAR_FORM_ERRORS](state) {
state.formErrors = null; state.formErrors = null;
}, },
[types.REQUEST_CREATE_CUSTOM_STAGE](state) { [types.REQUEST_CREATE_STAGE](state) {
state.isSaving = true; state.isSavingCustomStage = true;
state.formErrors = {}; state.formErrors = {};
}, },
[types.RECEIVE_CREATE_CUSTOM_STAGE_ERROR](state, { errors = null } = {}) { [types.RECEIVE_CREATE_STAGE_ERROR](state, { errors = null } = {}) {
state.isSaving = false; state.isSavingCustomStage = false;
state.formErrors = convertObjectPropsToCamelCase(errors, { deep: true }); state.formErrors = convertObjectPropsToCamelCase(errors, { deep: true });
}, },
[types.RECEIVE_CREATE_CUSTOM_STAGE_SUCCESS](state) { [types.RECEIVE_CREATE_STAGE_SUCCESS](state) {
state.isSaving = false; state.isSavingCustomStage = false;
state.formErrors = null; state.formErrors = null;
state.formInitialData = null; state.formInitialData = null;
}, },
......
export default () => ({ export default () => ({
isSaving: false, isSavingCustomStage: false,
isCreating: false, isCreatingCustomStage: false,
isEditing: false, isEditingCustomStage: false,
formEvents: [], formEvents: [],
formErrors: null, formErrors: null,
......
...@@ -17,18 +17,9 @@ export const REQUEST_STAGE_MEDIANS = 'REQUEST_STAGE_MEDIANS'; ...@@ -17,18 +17,9 @@ export const REQUEST_STAGE_MEDIANS = 'REQUEST_STAGE_MEDIANS';
export const RECEIVE_STAGE_MEDIANS_SUCCESS = 'RECEIVE_STAGE_MEDIANS_SUCCESS'; export const RECEIVE_STAGE_MEDIANS_SUCCESS = 'RECEIVE_STAGE_MEDIANS_SUCCESS';
export const RECEIVE_STAGE_MEDIANS_ERROR = 'RECEIVE_STAGE_MEDIANS_ERROR'; export const RECEIVE_STAGE_MEDIANS_ERROR = 'RECEIVE_STAGE_MEDIANS_ERROR';
export const HIDE_CUSTOM_STAGE_FORM = 'HIDE_CUSTOM_STAGE_FORM'; export const REQUEST_GROUP_STAGES = 'REQUEST_GROUP_STAGES';
export const SHOW_CUSTOM_STAGE_FORM = 'SHOW_CUSTOM_STAGE_FORM'; export const RECEIVE_GROUP_STAGES_SUCCESS = 'RECEIVE_GROUP_STAGES_SUCCESS';
export const SHOW_EDIT_CUSTOM_STAGE_FORM = 'SHOW_EDIT_CUSTOM_STAGE_FORM'; export const RECEIVE_GROUP_STAGES_ERROR = 'RECEIVE_GROUP_STAGES_ERROR';
export const CLEAR_CUSTOM_STAGE_FORM_ERRORS = 'CLEAR_CUSTOM_STAGE_FORM_ERRORS';
export const REQUEST_GROUP_STAGES_AND_EVENTS = 'REQUEST_GROUP_STAGES_AND_EVENTS';
export const RECEIVE_GROUP_STAGES_AND_EVENTS_SUCCESS = 'RECEIVE_GROUP_STAGES_AND_EVENTS_SUCCESS';
export const RECEIVE_GROUP_STAGES_AND_EVENTS_ERROR = 'RECEIVE_GROUP_STAGES_AND_EVENTS_ERROR';
export const REQUEST_CREATE_CUSTOM_STAGE = 'REQUEST_CREATE_CUSTOM_STAGE';
export const RECEIVE_CREATE_CUSTOM_STAGE_SUCCESS = 'RECEIVE_CREATE_CUSTOM_STAGE_SUCCESS';
export const RECEIVE_CREATE_CUSTOM_STAGE_ERROR = 'RECEIVE_CREATE_CUSTOM_STAGE_ERROR';
export const REQUEST_UPDATE_STAGE = 'REQUEST_UPDATE_STAGE'; export const REQUEST_UPDATE_STAGE = 'REQUEST_UPDATE_STAGE';
export const RECEIVE_UPDATE_STAGE_SUCCESS = 'RECEIVE_UPDATE_STAGE_SUCCESS'; export const RECEIVE_UPDATE_STAGE_SUCCESS = 'RECEIVE_UPDATE_STAGE_SUCCESS';
......
...@@ -63,55 +63,14 @@ export default { ...@@ -63,55 +63,14 @@ export default {
[types.RECEIVE_STAGE_MEDIANS_ERROR](state) { [types.RECEIVE_STAGE_MEDIANS_ERROR](state) {
state.medians = {}; state.medians = {};
}, },
[types.SHOW_CUSTOM_STAGE_FORM](state) { [types.REQUEST_GROUP_STAGES](state) {
state.isCreatingCustomStage = true;
state.isEditingCustomStage = false;
state.customStageFormInitialData = null;
state.customStageFormErrors = null;
},
[types.SHOW_EDIT_CUSTOM_STAGE_FORM](state, initialData) {
state.isEditingCustomStage = true;
state.isCreatingCustomStage = false;
state.customStageFormInitialData = initialData;
state.customStageFormErrors = null;
},
[types.HIDE_CUSTOM_STAGE_FORM](state) {
state.isEditingCustomStage = false;
state.isCreatingCustomStage = false;
state.customStageFormInitialData = null;
state.customStageFormErrors = null;
},
[types.CLEAR_CUSTOM_STAGE_FORM_ERRORS](state) {
state.customStageFormErrors = null;
},
[types.REQUEST_GROUP_STAGES_AND_EVENTS](state) {
state.stages = []; state.stages = [];
state.customStageFormEvents = [];
}, },
[types.RECEIVE_GROUP_STAGES_AND_EVENTS_ERROR](state) { [types.RECEIVE_GROUP_STAGES_ERROR](state) {
state.stages = []; state.stages = [];
state.customStageFormEvents = [];
}, },
[types.RECEIVE_GROUP_STAGES_AND_EVENTS_SUCCESS](state, data) { [types.RECEIVE_GROUP_STAGES_SUCCESS](state, stages) {
const { events = [], stages = [] } = data;
state.stages = transformRawStages(stages); state.stages = transformRawStages(stages);
state.customStageFormEvents = events.map(ev =>
convertObjectPropsToCamelCase(ev, { deep: true }),
);
},
[types.REQUEST_CREATE_CUSTOM_STAGE](state) {
state.isSavingCustomStage = true;
state.customStageFormErrors = {};
},
[types.RECEIVE_CREATE_CUSTOM_STAGE_ERROR](state, { errors = null } = {}) {
state.isSavingCustomStage = false;
state.customStageFormErrors = convertObjectPropsToCamelCase(errors, { deep: true });
},
[types.RECEIVE_CREATE_CUSTOM_STAGE_SUCCESS](state) {
state.isSavingCustomStage = false;
state.customStageFormErrors = null;
state.customStageFormInitialData = null;
}, },
[types.REQUEST_UPDATE_STAGE](state) { [types.REQUEST_UPDATE_STAGE](state) {
state.isLoading = true; state.isLoading = true;
......
...@@ -10,9 +10,6 @@ export default () => ({ ...@@ -10,9 +10,6 @@ export default () => ({
isEmptyStage: false, isEmptyStage: false,
errorCode: null, errorCode: null,
isSavingCustomStage: false,
isCreatingCustomStage: false,
isEditingCustomStage: false,
isSavingStageOrder: false, isSavingStageOrder: false,
errorSavingStageOrder: false, errorSavingStageOrder: false,
...@@ -25,8 +22,4 @@ export default () => ({ ...@@ -25,8 +22,4 @@ export default () => ({
stages: [], stages: [],
summary: [], summary: [],
medians: {}, medians: {},
customStageFormEvents: [],
customStageFormErrors: null,
customStageFormInitialData: 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