Commit 1a2fe72b authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'ek-fix-apply-label-url-params-onload' into 'master'

Fix: Apply VSA filters to records endpoint

See merge request gitlab-org/gitlab!60991
parents f8e16579 529fb359
...@@ -82,6 +82,7 @@ export default { ...@@ -82,6 +82,7 @@ export default {
'enableCustomOrdering', 'enableCustomOrdering',
'cycleAnalyticsRequestParams', 'cycleAnalyticsRequestParams',
'pathNavigationData', 'pathNavigationData',
'isOverviewStageSelected',
]), ]),
...mapGetters('customStages', ['customStageFormActive']), ...mapGetters('customStages', ['customStageFormActive']),
shouldRenderEmptyState() { shouldRenderEmptyState() {
...@@ -90,9 +91,6 @@ export default { ...@@ -90,9 +91,6 @@ export default {
shouldDisplayFilters() { shouldDisplayFilters() {
return !this.errorCode; return !this.errorCode;
}, },
isOverviewStageSelected() {
return this.selectedStage?.id === OVERVIEW_STAGE_ID;
},
shouldDisplayDurationChart() { shouldDisplayDurationChart() {
return ( return (
!this.featureFlags.hasPathNavigation || !this.featureFlags.hasPathNavigation ||
......
...@@ -36,11 +36,12 @@ export const setSelectedStage = ({ commit, getters: { paginationParams } }, stag ...@@ -36,11 +36,12 @@ export const setSelectedStage = ({ commit, getters: { paginationParams } }, stag
commit(types.SET_PAGINATION, { ...paginationParams, page: 1, hasNextPage: null }); commit(types.SET_PAGINATION, { ...paginationParams, page: 1, hasNextPage: null });
}; };
export const setDateRange = ({ commit, dispatch }, { skipFetch = false, startDate, endDate }) => { export const setDateRange = (
{ commit, dispatch, getters: { isOverviewStageSelected }, state: { selectedStage } },
{ startDate, endDate },
) => {
commit(types.SET_DATE_RANGE, { startDate, endDate }); commit(types.SET_DATE_RANGE, { startDate, endDate });
if (selectedStage && !isOverviewStageSelected) dispatch('fetchStageData', selectedStage.id);
if (skipFetch) return false;
return dispatch('fetchCycleAnalyticsData'); return dispatch('fetchCycleAnalyticsData');
}; };
...@@ -341,7 +342,6 @@ export const initializeCycleAnalytics = ({ dispatch, commit }, initialData = {}) ...@@ -341,7 +342,6 @@ export const initializeCycleAnalytics = ({ dispatch, commit }, initialData = {})
selectedStage selectedStage
? dispatch('setSelectedStage', selectedStage) ? dispatch('setSelectedStage', selectedStage)
: dispatch('setDefaultSelectedStage'), : dispatch('setDefaultSelectedStage'),
selectedStage?.id ? dispatch('fetchStageData', selectedStage.id) : Promise.resolve(),
dispatch('setPaths', { groupPath: group.fullPath, milestonesPath, labelsPath }), dispatch('setPaths', { groupPath: group.fullPath, milestonesPath, labelsPath }),
dispatch('filters/initialize', { dispatch('filters/initialize', {
selectedAuthor, selectedAuthor,
...@@ -352,7 +352,12 @@ export const initializeCycleAnalytics = ({ dispatch, commit }, initialData = {}) ...@@ -352,7 +352,12 @@ export const initializeCycleAnalytics = ({ dispatch, commit }, initialData = {})
dispatch('durationChart/setLoading', true), dispatch('durationChart/setLoading', true),
dispatch('typeOfWork/setLoading', true), dispatch('typeOfWork/setLoading', true),
]) ])
.then(() => dispatch('fetchCycleAnalyticsData')) .then(() =>
Promise.all([
selectedStage?.id ? dispatch('fetchStageData', selectedStage.id) : Promise.resolve(),
dispatch('fetchCycleAnalyticsData'),
]),
)
.then(() => dispatch('initializeCycleAnalyticsSuccess')); .then(() => dispatch('initializeCycleAnalyticsSuccess'));
} }
...@@ -477,7 +482,12 @@ export const fetchValueStreams = ({ commit, dispatch, getters }) => { ...@@ -477,7 +482,12 @@ export const fetchValueStreams = ({ commit, dispatch, getters }) => {
}); });
}; };
export const setFilters = ({ dispatch }) => { export const setFilters = ({
dispatch,
getters: { isOverviewStageSelected },
state: { selectedStage },
}) => {
if (selectedStage && !isOverviewStageSelected) dispatch('fetchStageData', selectedStage.id);
return dispatch('fetchCycleAnalyticsData'); return dispatch('fetchCycleAnalyticsData');
}; };
......
...@@ -4,7 +4,12 @@ import { getIdFromGraphQLId } from '~/graphql_shared/utils'; ...@@ -4,7 +4,12 @@ import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import httpStatus from '~/lib/utils/http_status'; import httpStatus from '~/lib/utils/http_status';
import { filterToQueryObject } from '~/vue_shared/components/filtered_search_bar/filtered_search_utils'; import { filterToQueryObject } from '~/vue_shared/components/filtered_search_bar/filtered_search_utils';
import { dateFormats } from '../../shared/constants'; import { dateFormats } from '../../shared/constants';
import { DEFAULT_VALUE_STREAM_ID, OVERVIEW_STAGE_CONFIG, PAGINATION_TYPE } from '../constants'; import {
DEFAULT_VALUE_STREAM_ID,
OVERVIEW_STAGE_CONFIG,
PAGINATION_TYPE,
OVERVIEW_STAGE_ID,
} from '../constants';
import { transformStagesForPathNavigation } from '../utils'; import { transformStagesForPathNavigation } from '../utils';
export const hasNoAccessError = (state) => state.errorCode === httpStatus.FORBIDDEN; export const hasNoAccessError = (state) => state.errorCode === httpStatus.FORBIDDEN;
...@@ -63,6 +68,9 @@ export const enableCustomOrdering = ({ stages, errorSavingStageOrder }) => ...@@ -63,6 +68,9 @@ export const enableCustomOrdering = ({ stages, errorSavingStageOrder }) =>
export const customStageFormActive = ({ isCreatingCustomStage, isEditingCustomStage }) => export const customStageFormActive = ({ isCreatingCustomStage, isEditingCustomStage }) =>
Boolean(isCreatingCustomStage || isEditingCustomStage); Boolean(isCreatingCustomStage || isEditingCustomStage);
export const isOverviewStageSelected = ({ selectedStage }) =>
selectedStage?.id === OVERVIEW_STAGE_ID;
/** /**
* Until there are controls in place to edit stages outside of the stage table, * Until there are controls in place to edit stages outside of the stage table,
* the path navigation component will only display active stages. * the path navigation component will only display active stages.
......
---
title: Refetch VSA stage data when filters change
merge_request: 60991
author:
type: fixed
...@@ -140,20 +140,6 @@ describe('Value Stream Analytics actions', () => { ...@@ -140,20 +140,6 @@ describe('Value Stream Analytics actions', () => {
}); });
}); });
describe('setDateRange', () => {
const payload = { startDate, endDate };
it('dispatches the fetchCycleAnalyticsData action', () => {
return testAction(
actions.setDateRange,
payload,
state,
[{ type: types.SET_DATE_RANGE, payload: { startDate, endDate } }],
[{ type: 'fetchCycleAnalyticsData' }],
);
});
});
describe('fetchStageData', () => { describe('fetchStageData', () => {
const headers = { const headers = {
'X-Next-Page': 2, 'X-Next-Page': 2,
...@@ -1363,9 +1349,34 @@ describe('Value Stream Analytics actions', () => { ...@@ -1363,9 +1349,34 @@ describe('Value Stream Analytics actions', () => {
}); });
}); });
describe('setFilters', () => { describe.each`
targetAction | payload | mutations
${actions.setDateRange} | ${{ startDate, endDate }} | ${[{ type: 'SET_DATE_RANGE', payload: { startDate, endDate } }]}
${actions.setFilters} | ${''} | ${[]}
`('$action', ({ targetAction, payload, mutations }) => {
let stateWithOverview = null;
beforeEach(() => {
stateWithOverview = { ...state, isOverviewStageSelected: () => true };
});
it('dispatches the fetchCycleAnalyticsData action', () => { it('dispatches the fetchCycleAnalyticsData action', () => {
return testAction(actions.setFilters, null, state, [], [{ type: 'fetchCycleAnalyticsData' }]); return testAction(targetAction, payload, stateWithOverview, mutations, [
{ type: 'fetchCycleAnalyticsData' },
]);
});
describe('with a stage selected', () => {
beforeEach(() => {
stateWithOverview = { ...state, selectedStage };
});
it('dispatches the fetchStageData action', () => {
return testAction(targetAction, payload, stateWithOverview, mutations, [
{ type: 'fetchStageData', payload: selectedStage.id },
{ type: 'fetchCycleAnalyticsData' },
]);
});
}); });
}); });
}); });
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