From 937161a2d1d0b257923a2fad6e1a8e5eaaa4b963 Mon Sep 17 00:00:00 2001 From: Martavis Parker <47053705+martavis@users.noreply.github.com> Date: Mon, 4 Oct 2021 08:31:55 -0700 Subject: [PATCH] Fixed table sort URL lag (#2340) * fixed table sort url lag * lint fixes --- .../hosts/ManageHostsPage/ManageHostsPage.tsx | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx index 9d945d5ceb..4dd0638bfd 100644 --- a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx +++ b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx @@ -478,18 +478,6 @@ const ManageHostsPage = ({ router.goBack(); }; - // const onShowEnrollSecretClick = ( - // evt: React.MouseEvent - // ) => { - // evt.preventDefault(); - // toggleEnrollSecretModal(); - // }; - - // const onAddHostClick = (evt: React.MouseEvent) => { - // evt.preventDefault(); - // toggleAddHostModal(); - // }; - // NOTE: this is called once on the initial rendering. The initial render of // the TableContainer child component will call this handler. const onTableQueryChange = async (newTableQuery: ITableQueryProps) => { @@ -533,22 +521,19 @@ const ManageHostsPage = ({ if (!isEmpty(searchQuery)) { newQueryParams.query = searchQuery; } - if (sortBy[0] && sortBy[0].key) { - newQueryParams.order_key = sortBy[0].key; - } else { - newQueryParams.order_key = DEFAULT_SORT_HEADER; - } - if (sortBy[0] && sortBy[0].direction) { - newQueryParams.order_direction = sortBy[0].direction; - } else { - newQueryParams.order_direction = DEFAULT_SORT_DIRECTION; - } + + newQueryParams.order_key = sort[0].key || DEFAULT_SORT_HEADER; + newQueryParams.order_direction = + sort[0].direction || DEFAULT_SORT_DIRECTION; + if (teamId) { newQueryParams.team_id = teamId; } + if (policyId) { newQueryParams.policy_id = policyId; } + if (policyResponse) { newQueryParams.policy_response = policyResponse; }