UI - remove extra loading Spinner from Software page (#12519)

## Addresses #11355, pt.1 (pt. 2 already fixed)

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/` 
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
This commit is contained in:
Jacob Shandling 2023-06-28 08:57:02 -07:00 committed by GitHub
parent 642ad21087
commit 569bf15fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 51 deletions

View File

@ -0,0 +1 @@
- Fix a bug where an extraneous loading spinner was rendered on the Software page.

View File

@ -613,12 +613,64 @@ const ManageSoftwarePage = ({
searchQuery !== "" ||
queryParams.vulnerable === "true");
return !isRouteOk ||
(isPremiumTier && !userTeams) ||
!globalConfig ||
(!softwareConfig && !softwareConfigError) ? (
<Spinner />
) : (
const renderSoftwareTable = () => {
if (
isFetchingCount ||
isFetchingSoftware ||
!globalConfig ||
(!softwareConfig && !softwareConfigError)
) {
return <Spinner />;
}
if (
(softwareError && !isFetchingSoftware) ||
(softwareConfigError && !isFetchingSoftwareConfig)
) {
return <TableDataError />;
}
return (
<TableContainer
columns={softwareTableHeaders}
data={(isSoftwareEnabled && software?.software) || []}
isLoading={false}
resultsTitle={"software items"}
emptyComponent={() => (
<EmptySoftwareTable
isSoftwareDisabled={!isSoftwareEnabled}
isFilterVulnerable={filterVuln}
isSandboxMode={isSandboxMode}
isCollectingSoftware={isCollectingInventory}
isSearching={searchQuery !== ""}
noSandboxHosts={noSandboxHosts}
/>
)}
defaultSortHeader={sortHeader || DEFAULT_SORT_HEADER}
defaultSortDirection={sortDirection || DEFAULT_SORT_DIRECTION}
defaultPageIndex={page || 0}
defaultSearchQuery={searchQuery}
manualSortBy
pageSize={DEFAULT_PAGE_SIZE}
showMarkAllPages={false}
isAllPagesSelected={false}
resetPageIndex={resetPageIndex}
disableNextPage={isLastPage}
searchable={searchable}
inputPlaceHolder="Search software by name or vulnerabilities (CVEs)"
onQueryChange={onQueryChange}
additionalQueries={filterVuln ? "vulnerable" : ""} // additionalQueries serves as a trigger
// for the useDeepEffect hook to fire onQueryChange for events happeing outside of
// the TableContainer
customControl={searchable ? renderVulnFilterDropdown : undefined}
stackControls
renderCount={renderSoftwareCount}
renderFooter={renderTableFooter}
disableMultiRowSelect
onSelectSingleRow={handleRowSelect}
/>
);
};
return (
<MainContent>
<div className={`${baseClass}__wrapper`}>
<div className={`${baseClass}__header-wrap`}>
@ -655,51 +707,7 @@ const ManageSoftwarePage = ({
<div className={`${baseClass}__description`}>
{renderHeaderDescription()}
</div>
<div className={`${baseClass}__table`}>
{(softwareError && !isFetchingSoftware) ||
(softwareConfigError && !isFetchingSoftwareConfig) ? (
<TableDataError />
) : (
<TableContainer
columns={softwareTableHeaders}
data={(isSoftwareEnabled && software?.software) || []}
isLoading={isFetchingSoftware || isFetchingCount}
resultsTitle={"software items"}
emptyComponent={() => (
<EmptySoftwareTable
isSoftwareDisabled={!isSoftwareEnabled}
isFilterVulnerable={filterVuln}
isSandboxMode={isSandboxMode}
isCollectingSoftware={isCollectingInventory}
isSearching={searchQuery !== ""}
noSandboxHosts={noSandboxHosts}
/>
)}
defaultSortHeader={sortHeader || DEFAULT_SORT_HEADER}
defaultSortDirection={sortDirection || DEFAULT_SORT_DIRECTION}
defaultPageIndex={page || 0}
defaultSearchQuery={searchQuery}
manualSortBy
pageSize={DEFAULT_PAGE_SIZE}
showMarkAllPages={false}
isAllPagesSelected={false}
resetPageIndex={resetPageIndex}
disableNextPage={isLastPage}
searchable={searchable}
inputPlaceHolder="Search software by name or vulnerabilities (CVEs)"
onQueryChange={onQueryChange}
additionalQueries={filterVuln ? "vulnerable" : ""} // additionalQueries serves as a trigger
// for the useDeepEffect hook to fire onQueryChange for events happeing outside of
// the TableContainer
customControl={searchable ? renderVulnFilterDropdown : undefined}
stackControls
renderCount={renderSoftwareCount}
renderFooter={renderTableFooter}
disableMultiRowSelect
onSelectSingleRow={handleRowSelect}
/>
)}
</div>
<div className={`${baseClass}__table`}>{renderSoftwareTable()}</div>
{showManageAutomationsModal && (
<ManageAutomationsModal
onCancel={toggleManageAutomationsModal}