diff options
Diffstat (limited to 'app/assets/javascripts/cycle_analytics/store')
5 files changed, 15 insertions, 49 deletions
diff --git a/app/assets/javascripts/cycle_analytics/store/actions.js b/app/assets/javascripts/cycle_analytics/store/actions.js index e0156b24f9d..5c2e29bfa74 100644 --- a/app/assets/javascripts/cycle_analytics/store/actions.js +++ b/app/assets/javascripts/cycle_analytics/store/actions.js @@ -1,7 +1,6 @@ import { getProjectValueStreamStages, getProjectValueStreams, - getProjectValueStreamMetrics, getValueStreamStageMedian, getValueStreamStageRecords, getValueStreamStageCounts, @@ -52,24 +51,6 @@ export const fetchValueStreams = ({ commit, dispatch, state }) => { commit(types.RECEIVE_VALUE_STREAMS_ERROR, status); }); }; -export const fetchCycleAnalyticsData = ({ - state: { - endpoints: { requestPath }, - }, - getters: { legacyFilterParams }, - commit, -}) => { - commit(types.REQUEST_CYCLE_ANALYTICS_DATA); - - return getProjectValueStreamMetrics(requestPath, legacyFilterParams) - .then(({ data }) => commit(types.RECEIVE_CYCLE_ANALYTICS_DATA_SUCCESS, data)) - .catch(() => { - commit(types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR); - createFlash({ - message: __('There was an error while fetching value stream summary data.'), - }); - }); -}; export const fetchStageData = ({ getters: { requestParams, filterParams, paginationParams }, @@ -153,7 +134,6 @@ export const fetchStageCountValues = ({ export const fetchValueStreamStageData = ({ dispatch }) => Promise.all([ - dispatch('fetchCycleAnalyticsData'), dispatch('fetchStageData'), dispatch('fetchStageMedians'), dispatch('fetchStageCountValues'), @@ -178,6 +158,11 @@ export const setDateRange = ({ dispatch, commit }, { createdAfter, createdBefore }; export const setInitialStage = ({ dispatch, commit, state: { stages } }, stage) => { + if (!stages.length && !stage) { + commit(types.SET_NO_ACCESS_ERROR); + return null; + } + const selectedStage = stage || stages[0]; commit(types.SET_SELECTED_STAGE, selectedStage); return dispatch('fetchValueStreamStageData'); diff --git a/app/assets/javascripts/cycle_analytics/store/getters.js b/app/assets/javascripts/cycle_analytics/store/getters.js index 962e1d50d12..6fe353405d4 100644 --- a/app/assets/javascripts/cycle_analytics/store/getters.js +++ b/app/assets/javascripts/cycle_analytics/store/getters.js @@ -49,12 +49,6 @@ const dateRangeParams = ({ createdAfter, createdBefore }) => ({ created_before: createdBefore ? dateFormat(createdBefore, dateFormats.isoDate) : null, }); -export const legacyFilterParams = ({ daysInPast }) => { - return { - 'cycle_analytics[start_date]': daysInPast, - }; -}; - export const filterParams = (state) => { return { ...filterBarParams(state), diff --git a/app/assets/javascripts/cycle_analytics/store/mutation_types.js b/app/assets/javascripts/cycle_analytics/store/mutation_types.js index 0ad67d4e6bd..9376d81f317 100644 --- a/app/assets/javascripts/cycle_analytics/store/mutation_types.js +++ b/app/assets/javascripts/cycle_analytics/store/mutation_types.js @@ -5,6 +5,7 @@ export const SET_SELECTED_VALUE_STREAM = 'SET_SELECTED_VALUE_STREAM'; export const SET_SELECTED_STAGE = 'SET_SELECTED_STAGE'; export const SET_DATE_RANGE = 'SET_DATE_RANGE'; export const SET_PAGINATION = 'SET_PAGINATION'; +export const SET_NO_ACCESS_ERROR = 'SET_NO_ACCESS_ERROR'; export const REQUEST_VALUE_STREAMS = 'REQUEST_VALUE_STREAMS'; export const RECEIVE_VALUE_STREAMS_SUCCESS = 'RECEIVE_VALUE_STREAMS_SUCCESS'; @@ -14,10 +15,6 @@ export const REQUEST_VALUE_STREAM_STAGES = 'REQUEST_VALUE_STREAM_STAGES'; export const RECEIVE_VALUE_STREAM_STAGES_SUCCESS = 'RECEIVE_VALUE_STREAM_STAGES_SUCCESS'; export const RECEIVE_VALUE_STREAM_STAGES_ERROR = 'RECEIVE_VALUE_STREAM_STAGES_ERROR'; -export const REQUEST_CYCLE_ANALYTICS_DATA = 'REQUEST_CYCLE_ANALYTICS_DATA'; -export const RECEIVE_CYCLE_ANALYTICS_DATA_SUCCESS = 'RECEIVE_CYCLE_ANALYTICS_DATA_SUCCESS'; -export const RECEIVE_CYCLE_ANALYTICS_DATA_ERROR = 'RECEIVE_CYCLE_ANALYTICS_DATA_ERROR'; - export const REQUEST_STAGE_DATA = 'REQUEST_STAGE_DATA'; export const RECEIVE_STAGE_DATA_SUCCESS = 'RECEIVE_STAGE_DATA_SUCCESS'; export const RECEIVE_STAGE_DATA_ERROR = 'RECEIVE_STAGE_DATA_ERROR'; diff --git a/app/assets/javascripts/cycle_analytics/store/mutations.js b/app/assets/javascripts/cycle_analytics/store/mutations.js index 64930a5b51f..8567529caf2 100644 --- a/app/assets/javascripts/cycle_analytics/store/mutations.js +++ b/app/assets/javascripts/cycle_analytics/store/mutations.js @@ -41,6 +41,9 @@ export default { direction: direction || PAGINATION_SORT_DIRECTION_DESC, }); }, + [types.SET_NO_ACCESS_ERROR](state) { + state.hasNoAccessError = true; + }, [types.REQUEST_VALUE_STREAMS](state) { state.valueStreams = []; }, @@ -59,23 +62,12 @@ export default { [types.RECEIVE_VALUE_STREAM_STAGES_ERROR](state) { state.stages = []; }, - [types.REQUEST_CYCLE_ANALYTICS_DATA](state) { - state.isLoading = true; - state.hasError = false; - }, - [types.RECEIVE_CYCLE_ANALYTICS_DATA_SUCCESS](state, data) { - state.permissions = data?.permissions || {}; - 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; + + state.hasNoAccessError = false; }, [types.RECEIVE_STAGE_DATA_SUCCESS](state, events = []) { state.isLoadingStage = false; @@ -83,13 +75,14 @@ export default { state.selectedStageEvents = events.map((ev) => convertObjectPropsToCamelCase(ev, { deep: true }), ); - state.hasError = false; + + state.hasNoAccessError = false; }, [types.RECEIVE_STAGE_DATA_ERROR](state, error) { state.isLoadingStage = false; state.isEmptyStage = true; state.selectedStageEvents = []; - state.hasError = true; + state.selectedStageError = error; }, [types.REQUEST_STAGE_MEDIANS](state) { diff --git a/app/assets/javascripts/cycle_analytics/store/state.js b/app/assets/javascripts/cycle_analytics/store/state.js index 52bc01cafa4..8d662333afa 100644 --- a/app/assets/javascripts/cycle_analytics/store/state.js +++ b/app/assets/javascripts/cycle_analytics/store/state.js @@ -10,9 +10,7 @@ export default () => ({ createdAfter: null, createdBefore: null, stages: [], - summary: [], analytics: [], - stats: [], valueStreams: [], selectedValueStream: {}, selectedStage: {}, @@ -20,11 +18,10 @@ export default () => ({ selectedStageError: '', medians: {}, stageCounts: {}, - hasError: false, + hasNoAccessError: false, isLoading: false, isLoadingStage: false, isEmptyStage: false, - permissions: {}, pagination: { page: null, hasNextPage: false, |