Fixed empty table showing while retrieving results (#2271)

Relates to #2269
This commit is contained in:
Martavis Parker 2021-09-28 21:28:39 -07:00 committed by GitHub
parent e60f21ea18
commit 29aa6610b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 18 deletions

View File

@ -0,0 +1 @@
- Fixed empty table showing while retrieving results

View File

@ -186,6 +186,28 @@ const QueryResults = ({
};
const renderTable = () => {
const emptyResults = !queryResults || !queryResults.length;
const hasNoResultsYet = !isQueryFinished && emptyResults;
const finishedWithNoResults =
isQueryFinished && (!hostsCount.successful || emptyResults);
if (hasNoResultsYet) {
return null;
}
if (finishedWithNoResults) {
return (
<p className="no-results-message">
Your live query returned no results.
<span>
Expecting to see results? Check to see if the hosts you targeted
reported &ldquo;Online&rdquo; or check out the &ldquo;Errors&rdquo;
table.
</span>
</p>
);
}
return (
<div className={`${baseClass}__results-table-container`}>
<Button
@ -263,10 +285,6 @@ const QueryResults = ({
</div>
);
const hasNoResults =
isQueryFinished &&
(!hostsCount.successful || !queryResults || !queryResults.length);
const firstTabClass = classnames("react-tabs__tab", "no-count", {
"errors-empty": !errors || errors?.length === 0,
});
@ -299,20 +317,7 @@ const QueryResults = ({
{NAV_TITLES.ERRORS}
</Tab>
</TabList>
<TabPanel>
{isQueryFinished && hasNoResults ? (
<p className="no-results-message">
Your live query returned no results.
<span>
Expecting to see results? Check to see if the hosts you
targeted reported &ldquo;Online&rdquo; or check out the
&ldquo;Errors&rdquo; table.
</span>
</p>
) : (
renderTable()
)}
</TabPanel>
<TabPanel>{renderTable()}</TabPanel>
<TabPanel>{renderErrorsTable()}</TabPanel>
</Tabs>
</div>