From 532ad777a32f2fa64ed7d35067f16e2762246759 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Tue, 13 Sep 2022 09:43:49 -0400 Subject: [PATCH] Resolves peers list search bug --- awx/ui/src/api/models/Instances.js | 4 ++-- .../Instances/InstancePeers/InstancePeerList.js | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/awx/ui/src/api/models/Instances.js b/awx/ui/src/api/models/Instances.js index 9434c94be3..5552e85e69 100644 --- a/awx/ui/src/api/models/Instances.js +++ b/awx/ui/src/api/models/Instances.js @@ -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) { diff --git a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js index 649a78e0e0..d717cbcda0 100644 --- a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js +++ b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js @@ -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'));