From 679734ed8dfe34d6d3338d5b18f00718c571b215 Mon Sep 17 00:00:00 2001 From: gillespi314 <73313222+gillespi314@users.noreply.github.com> Date: Fri, 12 Nov 2021 16:33:19 -0600 Subject: [PATCH] Fix empty state of policies table (#2905) --- .../hosts/HostDetailsPage/HostDetailsPage.tsx | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/frontend/pages/hosts/HostDetailsPage/HostDetailsPage.tsx b/frontend/pages/hosts/HostDetailsPage/HostDetailsPage.tsx index 9cdcb0355c..a635ceb3e7 100644 --- a/frontend/pages/hosts/HostDetailsPage/HostDetailsPage.tsx +++ b/frontend/pages/hosts/HostDetailsPage/HostDetailsPage.tsx @@ -654,24 +654,39 @@ const HostDetailsPage = ({ }; const renderPolicies = () => { + if (!host?.policies?.length) { + return ( +
+

Policies

+
+ No policies are checked for this host. +

+ Expecting to see policies? Try selecting “Refetch” to ask this + host to report new vitals. +

+
+
+ ); + } + const tableHeaders = generatePolicyTableHeaders(togglePolicyDetailsModal); const noResponses: IHostPolicy[] = - host?.policies.filter( + host?.policies?.filter( (policy) => !isValidPolicyResponse(policy.response) ) || []; const failingResponses: IHostPolicy[] = - host?.policies.filter((policy) => policy.response === "fail") || []; + host?.policies?.filter((policy) => policy.response === "fail") || []; return (

Policies

- {host?.policies.length && ( + {host?.policies?.length && ( <> - {failingResponses.length > 0 && ( + {failingResponses?.length > 0 && ( )} - {noResponses.length > 0 && ( + {noResponses?.length > 0 && (

This host is not updating the response for some policies. @@ -1138,7 +1153,7 @@ const HostDetailsPage = ({ {renderSchedule()} {renderPacks()} - {host?.policies && renderPolicies()} + {renderPolicies()}