mirror of
https://github.com/fleetdm/fleet
synced 2026-05-19 23:18:51 +00:00
## Issue Unreleased fix for #18115 ## Description - BE shows `0` count for empty state so FE needs to account for `0` instead of `undefined` ## Screenshot of fix <img width="1219" alt="Screenshot 2024-06-18 at 5 00 04 PM" src="https://github.com/fleetdm/fleet/assets/71795832/cd6ec944-ce99-4f8e-a630-9bf037abd0b9"> # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Manual QA for all new/changed functionality
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import React from "react";
|
|
|
|
import ReactTooltip from "react-tooltip";
|
|
import { COLORS } from "styles/var/colors";
|
|
import Icon from "components/Icon";
|
|
|
|
interface IIssuesIndicatorProps {
|
|
totalIssuesCount?: number;
|
|
failingPoliciesCount?: number;
|
|
/** Premium only */
|
|
criticalVulnerabilitiesCount?: number;
|
|
rowId?: number;
|
|
tooltipPosition?: "top" | "bottom";
|
|
}
|
|
|
|
const IssuesIndicator = ({
|
|
totalIssuesCount,
|
|
failingPoliciesCount,
|
|
criticalVulnerabilitiesCount,
|
|
rowId,
|
|
tooltipPosition = "top",
|
|
}: IIssuesIndicatorProps): JSX.Element => {
|
|
return (
|
|
<>
|
|
<span
|
|
className="host-issue tooltip tooltip__tooltip-icon"
|
|
data-tip
|
|
data-for={`host-issue-count-${rowId}`}
|
|
data-tip-disable={false}
|
|
>
|
|
<Icon name="error-outline" color="ui-fleet-black-50" />{" "}
|
|
{totalIssuesCount}
|
|
</span>
|
|
<ReactTooltip
|
|
place={tooltipPosition}
|
|
effect="solid"
|
|
backgroundColor={COLORS["tooltip-bg"]}
|
|
id={`host-issue-count-${rowId}`}
|
|
data-html
|
|
>
|
|
<span className={`tooltip__tooltip-text`}>
|
|
{!!criticalVulnerabilitiesCount &&
|
|
`Critical vulnerabilities (${criticalVulnerabilitiesCount})`}
|
|
{!!criticalVulnerabilitiesCount && !!failingPoliciesCount && <br />}
|
|
{!!failingPoliciesCount &&
|
|
`Failing policies (${failingPoliciesCount})`}
|
|
</span>
|
|
</ReactTooltip>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default IssuesIndicator;
|