Resolves peers list search bug

This commit is contained in:
Alex Corey 2022-09-13 09:43:49 -04:00 committed by Jeff Bradberry
parent b4edfc24ac
commit 532ad777a3
2 changed files with 11 additions and 7 deletions

View File

@ -18,8 +18,8 @@ class Instances extends Base {
return this.http.get(`${this.baseUrl}${instanceId}/health_check/`);
}
readPeers(instanceId) {
return this.http.get(`${this.baseUrl}${instanceId}/peers`);
readPeers(instanceId, params) {
return this.http.get(`${this.baseUrl}${instanceId}/peers/`, { params });
}
readInstanceGroup(instanceId) {

View File

@ -7,8 +7,8 @@ import PaginatedTable, {
HeaderRow,
} from 'components/PaginatedTable';
import useRequest, { useDismissableError } from 'hooks/useRequest';
import { getQSConfig } from 'util/qs';
import { useParams } from 'react-router-dom';
import { getQSConfig, parseQueryString } from 'util/qs';
import { useLocation, useParams } from 'react-router-dom';
import DataListToolbar from 'components/DataListToolbar';
import { InstancesAPI } from 'api';
import useExpanded from 'hooks/useExpanded';
@ -25,6 +25,7 @@ const QS_CONFIG = getQSConfig('peer', {
});
function InstancePeerList() {
const location = useLocation();
const { id } = useParams();
const {
isLoading,
@ -33,13 +34,14 @@ function InstancePeerList() {
result: { peers, count, relatedSearchableKeys, searchableKeys },
} = useRequest(
useCallback(async () => {
const params = parseQueryString(QS_CONFIG, location.search);
const [
{
data: { results, count: itemNumber },
},
actions,
] = await Promise.all([
InstancesAPI.readPeers(id),
InstancesAPI.readPeers(id, params),
InstancesAPI.readOptions(),
]);
return {
@ -50,7 +52,7 @@ function InstancePeerList() {
),
searchableKeys: getSearchableKeys(actions.data.actions?.GET),
};
}, [id]),
}, [id, location]),
{
peers: [],
count: 0,
@ -59,7 +61,9 @@ function InstancePeerList() {
}
);
useEffect(() => fetchPeers(), [fetchPeers, id]);
useEffect(() => {
fetchPeers();
}, [fetchPeers]);
const { selected, isAllSelected, handleSelect, clearSelected, selectAll } =
useSelected(peers.filter((i) => i.node_type !== 'hop'));