mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Fleet UI bug fix: Show software card with no vulnerabilities (#11431)
This commit is contained in:
parent
5544b2c579
commit
146beb0c50
2 changed files with 42 additions and 4 deletions
1
changes/11413-dashboard-vuln-card-bug
Normal file
1
changes/11413-dashboard-vuln-card-bug
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
- Bug fix: If there is software but no vulnerabilities, still show software card on dashboard when clicking on vulnerabilities
|
||||||
|
|
@ -22,13 +22,16 @@ import {
|
||||||
IMdmSummaryResponse,
|
IMdmSummaryResponse,
|
||||||
} from "interfaces/mdm";
|
} from "interfaces/mdm";
|
||||||
import { ISelectedPlatform } from "interfaces/platform";
|
import { ISelectedPlatform } from "interfaces/platform";
|
||||||
import { ISoftwareResponse } from "interfaces/software";
|
import { ISoftwareResponse, ISoftwareCountResponse } from "interfaces/software";
|
||||||
import { ITeam } from "interfaces/team";
|
import { ITeam } from "interfaces/team";
|
||||||
import { useTeamIdParam } from "hooks/useTeamIdParam";
|
import { useTeamIdParam } from "hooks/useTeamIdParam";
|
||||||
import enrollSecretsAPI from "services/entities/enroll_secret";
|
import enrollSecretsAPI from "services/entities/enroll_secret";
|
||||||
import hostSummaryAPI from "services/entities/host_summary";
|
import hostSummaryAPI from "services/entities/host_summary";
|
||||||
import macadminsAPI from "services/entities/macadmins";
|
import macadminsAPI from "services/entities/macadmins";
|
||||||
import softwareAPI, { ISoftwareQueryKey } from "services/entities/software";
|
import softwareAPI, {
|
||||||
|
ISoftwareQueryKey,
|
||||||
|
ISoftwareCountQueryKey,
|
||||||
|
} from "services/entities/software";
|
||||||
import teamsAPI, { ILoadTeamsResponse } from "services/entities/teams";
|
import teamsAPI, { ILoadTeamsResponse } from "services/entities/teams";
|
||||||
import hosts from "services/entities/hosts";
|
import hosts from "services/entities/hosts";
|
||||||
import sortUtils from "utilities/sort";
|
import sortUtils from "utilities/sort";
|
||||||
|
|
@ -126,6 +129,7 @@ const DashboardPage = ({ router, location }: IDashboardProps): JSX.Element => {
|
||||||
const [softwareActionUrl, setSoftwareActionUrl] = useState<string>();
|
const [softwareActionUrl, setSoftwareActionUrl] = useState<string>();
|
||||||
const [showMunkiCard, setShowMunkiCard] = useState(true);
|
const [showMunkiCard, setShowMunkiCard] = useState(true);
|
||||||
const [showMdmCard, setShowMdmCard] = useState(true);
|
const [showMdmCard, setShowMdmCard] = useState(true);
|
||||||
|
const [showSoftwareCard, setShowSoftwareCard] = useState(false);
|
||||||
const [showAddHostsModal, setShowAddHostsModal] = useState(false);
|
const [showAddHostsModal, setShowAddHostsModal] = useState(false);
|
||||||
const [showOperatingSystemsUI, setShowOperatingSystemsUI] = useState(false);
|
const [showOperatingSystemsUI, setShowOperatingSystemsUI] = useState(false);
|
||||||
const [showHostsUI, setShowHostsUI] = useState(false); // Hides UI on first load only
|
const [showHostsUI, setShowHostsUI] = useState(false); // Hides UI on first load only
|
||||||
|
|
@ -267,7 +271,7 @@ const DashboardPage = ({ router, location }: IDashboardProps): JSX.Element => {
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
staleTime: 30000, // stale time can be adjusted if fresher data is desired based on software inventory interval
|
staleTime: 30000, // stale time can be adjusted if fresher data is desired based on software inventory interval
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
if (data.software?.length !== 0) {
|
if (data.software?.length > 0) {
|
||||||
setSoftwareTitleDetail &&
|
setSoftwareTitleDetail &&
|
||||||
setSoftwareTitleDetail(
|
setSoftwareTitleDetail(
|
||||||
<LastUpdatedText
|
<LastUpdatedText
|
||||||
|
|
@ -275,11 +279,38 @@ const DashboardPage = ({ router, location }: IDashboardProps): JSX.Element => {
|
||||||
whatToRetrieve={"software"}
|
whatToRetrieve={"software"}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
setShowSoftwareCard(true);
|
||||||
|
} else {
|
||||||
|
setShowSoftwareCard(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// If no vulnerable software, !software?.software can return undefined
|
||||||
|
// Must check non-vuln software count > 0 to show software card iff API returning undefined
|
||||||
|
const { data: softwareCount } = useQuery<
|
||||||
|
ISoftwareCountResponse,
|
||||||
|
Error,
|
||||||
|
number,
|
||||||
|
ISoftwareCountQueryKey[]
|
||||||
|
>(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
scope: "softwareCount",
|
||||||
|
teamId: teamIdForApi,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
({ queryKey }) => softwareAPI.count(queryKey[0]),
|
||||||
|
{
|
||||||
|
enabled: isRouteOk && !software?.software,
|
||||||
|
keepPreviousData: true,
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
retry: 1,
|
||||||
|
select: (data) => data.count,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const { isFetching: isMdmFetching, error: errorMdm } = useQuery<
|
const { isFetching: isMdmFetching, error: errorMdm } = useQuery<
|
||||||
IMdmSummaryResponse,
|
IMdmSummaryResponse,
|
||||||
Error
|
Error
|
||||||
|
|
@ -354,6 +385,12 @@ const DashboardPage = ({ router, location }: IDashboardProps): JSX.Element => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
softwareCount && softwareCount > 0
|
||||||
|
? setShowSoftwareCard(true)
|
||||||
|
: setShowSoftwareCard(false);
|
||||||
|
}, [softwareCount]);
|
||||||
|
|
||||||
// Sets selected platform label id for links to filtered manage host page
|
// Sets selected platform label id for links to filtered manage host page
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (labels) {
|
if (labels) {
|
||||||
|
|
@ -596,7 +633,7 @@ const DashboardPage = ({ router, location }: IDashboardProps): JSX.Element => {
|
||||||
{LearnFleetCard}
|
{LearnFleetCard}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{software?.software && SoftwareCard}
|
{showSoftwareCard && SoftwareCard}
|
||||||
{!isAnyTeamSelected && isOnGlobalTeam && <>{ActivityFeedCard}</>}
|
{!isAnyTeamSelected && isOnGlobalTeam && <>{ActivityFeedCard}</>}
|
||||||
{showMdmCard && <>{MDMCard}</>}
|
{showMdmCard && <>{MDMCard}</>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue