From ee7253294246f8d7e51084a1e47d39f6a8dff42c Mon Sep 17 00:00:00 2001 From: noahtalerman <47070608+noahtalerman@users.noreply.github.com> Date: Tue, 2 Feb 2021 12:11:03 -0800 Subject: [PATCH] Display status indicator when live query results are empty (#257) These changes resolve the case during which a host goes offline after a live query begins. Now, the status indicator is displayed during, and after, a query is running and the live query results are empty. Additional changes: - Add no results messaging for the case when there are no results and no errors (rendered when live query is completed) --- .../QueryProgressDetails.jsx | 11 +++++++---- .../QueryProgressDetails.tests.jsx | 19 +++++++++++++++++++ .../QueryResultsTable/QueryResultsTable.jsx | 3 ++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/frontend/components/queries/QueryProgressDetails/QueryProgressDetails.jsx b/frontend/components/queries/QueryProgressDetails/QueryProgressDetails.jsx index 86adaae10f..b7a0d7bcda 100644 --- a/frontend/components/queries/QueryProgressDetails/QueryProgressDetails.jsx +++ b/frontend/components/queries/QueryProgressDetails/QueryProgressDetails.jsx @@ -11,14 +11,17 @@ const baseClass = 'query-progress-details'; const QueryProgressDetails = ({ campaign, className, onRunQuery, onStopQuery, queryIsRunning, queryTimerMilliseconds, disableRun }) => { const { hosts_count: hostsCount } = campaign; - const { Metrics: metrics = {} } = campaign; const { errors } = campaign; + + const totalHostsOnline = get(campaign, ['totals', 'online'], 0); + const totalHostsOffline = get(campaign, ['totals', 'offline'], 0); const totalHostsCount = get(campaign, ['totals', 'count'], 0); const totalRowsCount = get(campaign, ['query_results', 'length'], 0); + const campaignIsEmpty = !hostsCount.successful && hostsCount.successful !== 0; - const onlineHostsTotalDisplay = metrics.OnlineHosts === 1 ? '1 host' : `${metrics.OnlineHosts} hosts`; + const onlineHostsTotalDisplay = totalHostsOnline === 1 ? '1 host' : `${totalHostsOnline} hosts`; const onlineResultsTotalDisplay = totalRowsCount === 1 ? '1 result' : `${totalRowsCount} results`; - const offlineHostsTotalDisplay = metrics.OfflineHosts === 1 ? '1 host' : `${metrics.OfflineHosts} hosts`; + const offlineHostsTotalDisplay = totalHostsOffline === 1 ? '1 host' : `${totalHostsOffline} hosts`; const failedHostsTotalDisplay = hostsCount.failed === 1 ? '1 host' : `${hostsCount.failed} hosts`; let totalErrorsDisplay = '0 errors'; if (errors) { @@ -50,7 +53,7 @@ const QueryProgressDetails = ({ campaign, className, onRunQuery, onStopQuery, qu ); - if (!hostsCount.total) { + if (!hostsCount.total && campaignIsEmpty) { return (