mirror of
https://github.com/ansible/awx.git
synced 2026-04-06 18:49:21 -02:30
Fix List Navigation Pagination
Fix List Navigation Pagination. Add missing variable `page` to `handleSetPageSize`. Also update unittests impacted by this change. closes: https://github.com/ansible/awx/issues/5983
This commit is contained in:
@@ -43,11 +43,13 @@ class PaginatedDataList extends React.Component {
|
|||||||
this.pushHistoryState(replaceParams(oldParams, { page: pageNumber }));
|
this.pushHistoryState(replaceParams(oldParams, { page: pageNumber }));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSetPageSize(event, pageSize) {
|
handleSetPageSize(event, pageSize, page) {
|
||||||
const { history, qsConfig } = this.props;
|
const { history, qsConfig } = this.props;
|
||||||
const { search } = history.location;
|
const { search } = history.location;
|
||||||
const oldParams = parseQueryString(qsConfig, search);
|
const oldParams = parseQueryString(qsConfig, search);
|
||||||
this.pushHistoryState(replaceParams(oldParams, { page_size: pageSize }));
|
this.pushHistoryState(
|
||||||
|
replaceParams(oldParams, { page_size: pageSize, page })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushHistoryState(params) {
|
pushHistoryState(params) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ describe('<PaginatedDataList />', () => {
|
|||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('initially renders succesfully', () => {
|
test('initially renders successfully', () => {
|
||||||
mountWithContexts(
|
mountWithContexts(
|
||||||
<PaginatedDataList
|
<PaginatedDataList
|
||||||
items={mockData}
|
items={mockData}
|
||||||
@@ -83,11 +83,11 @@ describe('<PaginatedDataList />', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const pagination = wrapper.find('Pagination');
|
const pagination = wrapper.find('Pagination');
|
||||||
pagination.prop('onPerPageSelect')(null, 25);
|
pagination.prop('onPerPageSelect')(null, 25, 2);
|
||||||
expect(history.location.search).toEqual('?item.page_size=25');
|
expect(history.location.search).toEqual('?item.page=2&item.page_size=25');
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
// since page_size = 5 is the default, that should be strip out of the search
|
// since page_size = 5 is the default, that should be strip out of the search
|
||||||
pagination.prop('onPerPageSelect')(null, 5);
|
pagination.prop('onPerPageSelect')(null, 5, 2);
|
||||||
expect(history.location.search).toEqual('');
|
expect(history.location.search).toEqual('?item.page=2');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user