Fleet UI: Fix manage host page for invalid query strings spinner (#9198)

This commit is contained in:
RachelElysia 2023-01-09 15:16:17 -05:00 committed by GitHub
parent 4f8be572f8
commit 907dfd0a7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View file

@ -0,0 +1 @@
- Invalid query string will not result in neverending spinner

View file

@ -351,7 +351,7 @@ const ManageHostsPage = ({
}
);
useQuery<IStoredPolicyResponse, Error>(
const { isLoading: isLoadingPolicy } = useQuery<IStoredPolicyResponse, Error>(
["policy"],
() => globalPoliciesAPI.load(policyId),
{
@ -359,6 +359,9 @@ const ManageHostsPage = ({
onSuccess: ({ policy: policyAPIResponse }) => {
setPolicy(policyAPIResponse);
},
onError: () => {
setHasHostErrors(true);
},
}
);
@ -1647,7 +1650,14 @@ const ManageHostsPage = ({
};
const renderTable = () => {
if (!config || !currentUser || !hosts || !teamSync) {
if (
!config ||
!currentUser ||
isHostCountLoading ||
isHostsLoading ||
isLoadingPolicy ||
!teamSync
) {
return <Spinner />;
}
@ -1755,7 +1765,7 @@ const ManageHostsPage = ({
return (
<TableContainer
columns={tableColumns}
data={hosts}
data={hosts || []}
isLoading={isHostsLoading || isHostCountLoading}
manualSortBy
defaultSortHeader={(sortBy[0] && sortBy[0].key) || DEFAULT_SORT_HEADER}