fleet/frontend/components/ProbabilityOfExploit/ProbabilityOfExploit.tsx
Jacob Shandling b9fc6968a5 UI – Vulnerability details page (#16665)
### _Draft until available to address feedback and merge on Monday –
ready for review_

## Addresses #16472 
- Full accounting of features in linked ticket

<img width="1676" alt="Screenshot 2024-02-07 at 10 24 03 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/aa0cd3b5-9191-4078-b57c-ee451dc5c632">

<img width="909" alt="Screenshot 2024-02-07 at 10 38 52 PM"
src="https://github.com/fleetdm/fleet/assets/61553566/ea1b0067-bb91-4502-bde0-0e36914a0829">

## Checklist for submitter
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-02-15 10:35:06 -07:00

63 lines
1.6 KiB
TypeScript

import React from "react";
import { uniqueId } from "lodash";
import ReactTooltip from "react-tooltip";
import { formatFloatAsPercentage } from "utilities/helpers";
import Icon from "components/Icon";
import { COLORS } from "styles/var/colors";
const baseClass = "probability-of-exploit";
interface IProbabilityOfExploit {
probabilityOfExploit: number;
cisaKnownExploit?: boolean | null;
tooltipPosition?: "top" | "bottom" | "left" | "right";
}
const ProbabilityOfExploit = ({
probabilityOfExploit,
cisaKnownExploit,
tooltipPosition = "top",
}: IProbabilityOfExploit) => {
const renderExploitedIcon = () => {
const tooltipId = uniqueId();
return (
<>
<span
className={`${baseClass} tooltip tooltip__tooltip-icon`}
data-tip
data-for={tooltipId}
>
<Icon name="error" size="small" color="status-error" />
</span>
<ReactTooltip
place={tooltipPosition}
effect="solid"
backgroundColor={COLORS["tooltip-bg"]}
id={tooltipId}
data-html
>
<span className={`tooltip__tooltip-text`}>
<>
The vulnerability has been actively exploited in the wild. This
data is reported by the Cybersecurity and Infrastructure Security
Agency (CISA).
</>
</span>
</ReactTooltip>
</>
);
};
return (
<span className={baseClass}>
{formatFloatAsPercentage(probabilityOfExploit)}
{cisaKnownExploit && renderExploitedIcon()}
</span>
);
};
export default ProbabilityOfExploit;