mirror of
https://github.com/ansible/awx.git
synced 2026-03-24 20:35:02 -02:30
reset page to 1 after activity stream type changes
This commit is contained in:
@@ -18,7 +18,12 @@ import PaginatedTable, {
|
|||||||
HeaderCell,
|
HeaderCell,
|
||||||
} from '../../components/PaginatedTable';
|
} from '../../components/PaginatedTable';
|
||||||
import useRequest from '../../util/useRequest';
|
import useRequest from '../../util/useRequest';
|
||||||
import { getQSConfig, parseQueryString } from '../../util/qs';
|
import {
|
||||||
|
getQSConfig,
|
||||||
|
parseQueryString,
|
||||||
|
replaceParams,
|
||||||
|
encodeNonDefaultQueryString,
|
||||||
|
} from '../../util/qs';
|
||||||
import { ActivityStreamAPI } from '../../api';
|
import { ActivityStreamAPI } from '../../api';
|
||||||
|
|
||||||
import ActivityStreamListItem from './ActivityStreamListItem';
|
import ActivityStreamListItem from './ActivityStreamListItem';
|
||||||
@@ -89,6 +94,19 @@ function ActivityStream({ i18n }) {
|
|||||||
fetchActivityStream();
|
fetchActivityStream();
|
||||||
}, [fetchActivityStream]);
|
}, [fetchActivityStream]);
|
||||||
|
|
||||||
|
const pushHistoryState = urlParams => {
|
||||||
|
let searchParams = parseQueryString(QS_CONFIG, location.search);
|
||||||
|
searchParams = replaceParams(searchParams, { page: 1 });
|
||||||
|
const encodedParams = encodeNonDefaultQueryString(QS_CONFIG, searchParams, {
|
||||||
|
type: urlParams.get('type'),
|
||||||
|
});
|
||||||
|
history.push(
|
||||||
|
encodedParams
|
||||||
|
? `${location.pathname}?${encodedParams}`
|
||||||
|
: location.pathname
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<PageSection
|
<PageSection
|
||||||
@@ -110,7 +128,7 @@ function ActivityStream({ i18n }) {
|
|||||||
urlParams.set('type', selection);
|
urlParams.set('type', selection);
|
||||||
}
|
}
|
||||||
setIsTypeDropdownOpen(false);
|
setIsTypeDropdownOpen(false);
|
||||||
history.push(`${location.pathname}?${urlParams.toString()}`);
|
pushHistoryState(urlParams);
|
||||||
}}
|
}}
|
||||||
selections={activityStreamType}
|
selections={activityStreamType}
|
||||||
isOpen={isTypeDropdownOpen}
|
isOpen={isTypeDropdownOpen}
|
||||||
|
|||||||
Reference in New Issue
Block a user