2021-09-04 01:27:46 +05:30
|
|
|
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
|
|
|
|
import { decorateData, decorateEvents, formatMedianValues } from '../utils';
|
2021-06-08 01:23:25 +05:30
|
|
|
import * as types from './mutation_types';
|
|
|
|
|
|
|
|
export default {
|
2021-09-04 01:27:46 +05:30
|
|
|
[types.INITIALIZE_VSA](state, { requestPath, fullPath }) {
|
2021-06-08 01:23:25 +05:30
|
|
|
state.requestPath = requestPath;
|
2021-09-04 01:27:46 +05:30
|
|
|
state.fullPath = fullPath;
|
|
|
|
},
|
|
|
|
[types.SET_LOADING](state, loadingState) {
|
|
|
|
state.isLoading = loadingState;
|
|
|
|
},
|
|
|
|
[types.SET_SELECTED_VALUE_STREAM](state, selectedValueStream = {}) {
|
|
|
|
state.selectedValueStream = convertObjectPropsToCamelCase(selectedValueStream, { deep: true });
|
2021-06-08 01:23:25 +05:30
|
|
|
},
|
|
|
|
[types.SET_SELECTED_STAGE](state, stage) {
|
|
|
|
state.selectedStage = stage;
|
|
|
|
},
|
|
|
|
[types.SET_DATE_RANGE](state, { startDate }) {
|
|
|
|
state.startDate = startDate;
|
|
|
|
},
|
2021-09-04 01:27:46 +05:30
|
|
|
[types.REQUEST_VALUE_STREAMS](state) {
|
|
|
|
state.valueStreams = [];
|
|
|
|
},
|
|
|
|
[types.RECEIVE_VALUE_STREAMS_SUCCESS](state, valueStreams = []) {
|
|
|
|
state.valueStreams = valueStreams;
|
|
|
|
},
|
|
|
|
[types.RECEIVE_VALUE_STREAMS_ERROR](state) {
|
|
|
|
state.valueStreams = [];
|
|
|
|
},
|
|
|
|
[types.REQUEST_VALUE_STREAM_STAGES](state) {
|
|
|
|
state.stages = [];
|
|
|
|
},
|
|
|
|
[types.RECEIVE_VALUE_STREAM_STAGES_SUCCESS](state, { stages = [] }) {
|
|
|
|
state.stages = stages.map((s) => ({
|
|
|
|
...convertObjectPropsToCamelCase(s, { deep: true }),
|
|
|
|
// NOTE: we set the component type here to match the current behaviour
|
|
|
|
// this can be removed when we migrate to the update stage table
|
|
|
|
// https://gitlab.com/gitlab-org/gitlab/-/issues/326704
|
|
|
|
component: `stage-${s.id}-component`,
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
[types.RECEIVE_VALUE_STREAM_STAGES_ERROR](state) {
|
|
|
|
state.stages = [];
|
|
|
|
},
|
2021-06-08 01:23:25 +05:30
|
|
|
[types.REQUEST_CYCLE_ANALYTICS_DATA](state) {
|
|
|
|
state.isLoading = true;
|
|
|
|
state.hasError = false;
|
|
|
|
},
|
|
|
|
[types.RECEIVE_CYCLE_ANALYTICS_DATA_SUCCESS](state, data) {
|
2021-09-04 01:27:46 +05:30
|
|
|
const { summary, medians } = decorateData(data);
|
|
|
|
state.permissions = data.permissions;
|
2021-06-08 01:23:25 +05:30
|
|
|
state.summary = summary;
|
2021-09-04 01:27:46 +05:30
|
|
|
state.medians = formatMedianValues(medians);
|
2021-06-08 01:23:25 +05:30
|
|
|
state.hasError = false;
|
|
|
|
},
|
|
|
|
[types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR](state) {
|
|
|
|
state.isLoading = false;
|
|
|
|
state.hasError = true;
|
|
|
|
},
|
|
|
|
[types.REQUEST_STAGE_DATA](state) {
|
|
|
|
state.isLoadingStage = true;
|
|
|
|
state.isEmptyStage = false;
|
|
|
|
state.selectedStageEvents = [];
|
|
|
|
state.hasError = false;
|
|
|
|
},
|
|
|
|
[types.RECEIVE_STAGE_DATA_SUCCESS](state, { events = [] }) {
|
|
|
|
const { selectedStage } = state;
|
|
|
|
state.isLoadingStage = false;
|
|
|
|
state.isEmptyStage = !events.length;
|
|
|
|
state.selectedStageEvents = decorateEvents(events, selectedStage);
|
|
|
|
state.hasError = false;
|
|
|
|
},
|
2021-09-04 01:27:46 +05:30
|
|
|
[types.RECEIVE_STAGE_DATA_ERROR](state, error) {
|
2021-06-08 01:23:25 +05:30
|
|
|
state.isLoadingStage = false;
|
|
|
|
state.isEmptyStage = true;
|
|
|
|
state.selectedStageEvents = [];
|
|
|
|
state.hasError = true;
|
2021-09-04 01:27:46 +05:30
|
|
|
state.selectedStageError = error;
|
2021-06-08 01:23:25 +05:30
|
|
|
},
|
|
|
|
};
|