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