Commit 1f2f4d52 authored by Fatih Acet's avatar Fatih Acet

Merge branch...

Merge branch '32546-productivity-analytics-reset-mr-table-page-when-any-of-the-filters-changes' into 'master'

Resolve "Productivity Analytics: Reset MR table page when any of the filters changes"

Closes #32546

See merge request gitlab-org/gitlab!17668
parents 77543954 e0aabc79
...@@ -93,17 +93,10 @@ export default { ...@@ -93,17 +93,10 @@ export default {
methods: { methods: {
...mapActions(['setEndpoint']), ...mapActions(['setEndpoint']),
...mapActions('charts', ['fetchChartData', 'setMetricType', 'chartItemClicked']), ...mapActions('charts', ['fetchChartData', 'setMetricType', 'chartItemClicked']),
...mapActions('table', [ ...mapActions('table', ['setSortField', 'setPage', 'toggleSortOrder', 'setColumnMetric']),
'setSortField',
'setMergeRequestsPage',
'toggleSortOrder',
'setColumnMetric',
]),
onMainChartItemClicked({ params }) { onMainChartItemClicked({ params }) {
const itemValue = params.data.value[0]; const itemValue = params.data.value[0];
this.chartItemClicked({ chartKey: this.chartKeys.main, item: itemValue }); this.chartItemClicked({ chartKey: this.chartKeys.main, item: itemValue });
// let's reset the page on the MR table
this.setMergeRequestsPage(0);
}, },
getColumnChartOption(chartKey) { getColumnChartOption(chartKey) {
return { return {
...@@ -295,7 +288,7 @@ export default { ...@@ -295,7 +288,7 @@ export default {
:metric-type="columnMetric" :metric-type="columnMetric"
:metric-label="columnMetricLabel" :metric-label="columnMetricLabel"
@columnMetricChange="setColumnMetric" @columnMetricChange="setColumnMetric"
@pageChange="setMergeRequestsPage" @pageChange="setPage"
/> />
<div v-if="showMergeRequestTableNoData" class="js-no-data bs-callout bs-callout-info"> <div v-if="showMergeRequestTableNoData" class="js-no-data bs-callout bs-callout-info">
{{ __('There is no data available. Please change your selection.') }} {{ __('There is no data available. Please change your selection.') }}
......
...@@ -53,8 +53,8 @@ export const chartItemClicked = ({ commit, dispatch }, { chartKey, item }) => { ...@@ -53,8 +53,8 @@ export const chartItemClicked = ({ commit, dispatch }, { chartKey, item }) => {
// update secondary charts // update secondary charts
dispatch('fetchSecondaryChartData'); dispatch('fetchSecondaryChartData');
// update table // let's reset the page on the MR table and fetch data
dispatch('table/fetchMergeRequests', null, { root: true }); dispatch('table/setPage', 0, { root: true });
}; };
// prevent babel-plugin-rewire from generating an invalid default during karma tests // prevent babel-plugin-rewire from generating an invalid default during karma tests
......
...@@ -8,7 +8,8 @@ export const setGroupNamespace = ({ commit, dispatch }, groupNamespace) => { ...@@ -8,7 +8,8 @@ export const setGroupNamespace = ({ commit, dispatch }, groupNamespace) => {
// if there's no 403, then we fetch all remaining chart data and table data // if there's no 403, then we fetch all remaining chart data and table data
return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => { return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => {
dispatch('charts/fetchSecondaryChartData', null, { root: true }); dispatch('charts/fetchSecondaryChartData', null, { root: true });
dispatch('table/fetchMergeRequests', null, { root: true }); // let's reset the page on the MR table and fetch data
dispatch('table/setPage', 0, { root: true });
}); });
}; };
...@@ -17,7 +18,8 @@ export const setProjectPath = ({ commit, dispatch }, projectPath) => { ...@@ -17,7 +18,8 @@ export const setProjectPath = ({ commit, dispatch }, projectPath) => {
return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => { return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => {
dispatch('charts/fetchSecondaryChartData', null, { root: true }); dispatch('charts/fetchSecondaryChartData', null, { root: true });
dispatch('table/fetchMergeRequests', null, { root: true }); // let's reset the page on the MR table and fetch data
dispatch('table/setPage', 0, { root: true });
}); });
}; };
...@@ -26,7 +28,8 @@ export const setPath = ({ commit, dispatch }, path) => { ...@@ -26,7 +28,8 @@ export const setPath = ({ commit, dispatch }, path) => {
return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => { return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => {
dispatch('charts/fetchSecondaryChartData', null, { root: true }); dispatch('charts/fetchSecondaryChartData', null, { root: true });
dispatch('table/fetchMergeRequests', null, { root: true }); // let's reset the page on the MR table and fetch data
dispatch('table/setPage', 0, { root: true });
}); });
}; };
...@@ -35,7 +38,8 @@ export const setDaysInPast = ({ commit, dispatch }, days) => { ...@@ -35,7 +38,8 @@ export const setDaysInPast = ({ commit, dispatch }, days) => {
return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => { return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => {
dispatch('charts/fetchSecondaryChartData', null, { root: true }); dispatch('charts/fetchSecondaryChartData', null, { root: true });
dispatch('table/fetchMergeRequests', null, { root: true }); // let's reset the page on the MR table and fetch data
dispatch('table/setPage', 0, { root: true });
}); });
}; };
......
...@@ -57,8 +57,8 @@ export const toggleSortOrder = ({ commit, dispatch }) => { ...@@ -57,8 +57,8 @@ export const toggleSortOrder = ({ commit, dispatch }) => {
export const setColumnMetric = ({ commit }, data) => commit(types.SET_COLUMN_METRIC, data); export const setColumnMetric = ({ commit }, data) => commit(types.SET_COLUMN_METRIC, data);
export const setMergeRequestsPage = ({ commit, dispatch }, data) => { export const setPage = ({ commit, dispatch }, data) => {
commit(types.SET_MERGE_REQUESTS_PAGE, data); commit(types.SET_PAGE, data);
dispatch('fetchMergeRequests'); dispatch('fetchMergeRequests');
}; };
......
...@@ -6,4 +6,4 @@ export const SET_SORT_FIELD = 'SET_SORT_FIELD'; ...@@ -6,4 +6,4 @@ export const SET_SORT_FIELD = 'SET_SORT_FIELD';
export const TOGGLE_SORT_ORDER = 'TOGGLE_SORT_ORDER'; export const TOGGLE_SORT_ORDER = 'TOGGLE_SORT_ORDER';
export const SET_COLUMN_METRIC = 'SET_COLUMN_METRIC'; export const SET_COLUMN_METRIC = 'SET_COLUMN_METRIC';
export const SET_MERGE_REQUESTS_PAGE = 'SET_MERGE_REQUESTS_PAGE'; export const SET_PAGE = 'SET_PAGE';
...@@ -29,7 +29,7 @@ export default { ...@@ -29,7 +29,7 @@ export default {
[types.SET_COLUMN_METRIC](state, columnMetric) { [types.SET_COLUMN_METRIC](state, columnMetric) {
state.columnMetric = columnMetric; state.columnMetric = columnMetric;
}, },
[types.SET_MERGE_REQUESTS_PAGE](state, page) { [types.SET_PAGE](state, page) {
state.pageInfo = { ...state.pageInfo, page }; state.pageInfo = { ...state.pageInfo, page };
}, },
}; };
...@@ -27,7 +27,7 @@ describe('ProductivityApp component', () => { ...@@ -27,7 +27,7 @@ describe('ProductivityApp component', () => {
const actionSpies = { const actionSpies = {
chartItemClicked: jest.fn(), chartItemClicked: jest.fn(),
setSortField: jest.fn(), setSortField: jest.fn(),
setMergeRequestsPage: jest.fn(), setPage: jest.fn(),
toggleSortOrder: jest.fn(), toggleSortOrder: jest.fn(),
setColumnMetric: jest.fn(), setColumnMetric: jest.fn(),
}; };
...@@ -166,10 +166,6 @@ describe('ProductivityApp component', () => { ...@@ -166,10 +166,6 @@ describe('ProductivityApp component', () => {
item: 0, item: 0,
}); });
}); });
it('dispatches setMergeRequestsPage action', () => {
expect(actionSpies.setMergeRequestsPage).toHaveBeenCalledWith(0);
});
}); });
describe('Time based histogram', () => { describe('Time based histogram', () => {
...@@ -348,7 +344,7 @@ describe('ProductivityApp component', () => { ...@@ -348,7 +344,7 @@ describe('ProductivityApp component', () => {
it('should change the page', () => { it('should change the page', () => {
const page = 2; const page = 2;
findMrTable().vm.$emit('pageChange', page); findMrTable().vm.$emit('pageChange', page);
expect(actionSpies.setMergeRequestsPage).toHaveBeenCalledWith(page); expect(actionSpies.setPage).toHaveBeenCalledWith(page);
}); });
describe('sort controls', () => { describe('sort controls', () => {
......
...@@ -200,7 +200,7 @@ describe('Productivity analytics chart actions', () => { ...@@ -200,7 +200,7 @@ describe('Productivity analytics chart actions', () => {
{ chartKey, item }, { chartKey, item },
mockedContext.state, mockedContext.state,
[{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item } }], [{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item } }],
[{ type: 'fetchSecondaryChartData' }, { type: 'table/fetchMergeRequests', payload: null }], [{ type: 'fetchSecondaryChartData' }, { type: 'table/setPage', payload: 0 }],
done, done,
); );
}); });
......
...@@ -32,11 +32,7 @@ describe('Productivity analytics filter actions', () => { ...@@ -32,11 +32,7 @@ describe('Productivity analytics filter actions', () => {
{ root: true }, { root: true },
]); ]);
expect(store.dispatch.mock.calls[2]).toEqual([ expect(store.dispatch.mock.calls[2]).toEqual(['table/setPage', 0, { root: true }]);
'table/fetchMergeRequests',
null,
{ root: true },
]);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -67,11 +63,7 @@ describe('Productivity analytics filter actions', () => { ...@@ -67,11 +63,7 @@ describe('Productivity analytics filter actions', () => {
{ root: true }, { root: true },
]); ]);
expect(store.dispatch.mock.calls[2]).toEqual([ expect(store.dispatch.mock.calls[2]).toEqual(['table/setPage', 0, { root: true }]);
'table/fetchMergeRequests',
null,
{ root: true },
]);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -102,11 +94,7 @@ describe('Productivity analytics filter actions', () => { ...@@ -102,11 +94,7 @@ describe('Productivity analytics filter actions', () => {
{ root: true }, { root: true },
]); ]);
expect(store.dispatch.mock.calls[2]).toEqual([ expect(store.dispatch.mock.calls[2]).toEqual(['table/setPage', 0, { root: true }]);
'table/fetchMergeRequests',
null,
{ root: true },
]);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -137,11 +125,7 @@ describe('Productivity analytics filter actions', () => { ...@@ -137,11 +125,7 @@ describe('Productivity analytics filter actions', () => {
{ root: true }, { root: true },
]); ]);
expect(store.dispatch.mock.calls[2]).toEqual([ expect(store.dispatch.mock.calls[2]).toEqual(['table/setPage', 0, { root: true }]);
'table/fetchMergeRequests',
null,
{ root: true },
]);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
...@@ -235,13 +235,13 @@ describe('Productivity analytics table actions', () => { ...@@ -235,13 +235,13 @@ describe('Productivity analytics table actions', () => {
)); ));
}); });
describe('setMergeRequestsPage', () => { describe('setPage', () => {
it('should commit setMergeRequestsPage', done => it('should commit setPage', done =>
testAction( testAction(
actions.setMergeRequestsPage, actions.setPage,
2, 2,
mockedContext.state, mockedContext.state,
[{ type: types.SET_MERGE_REQUESTS_PAGE, payload: 2 }], [{ type: types.SET_PAGE, payload: 2 }],
[{ type: 'fetchMergeRequests' }], [{ type: 'fetchMergeRequests' }],
done, done,
)); ));
......
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