mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
## Addresses [confidential/2940](https://github.com/fleetdm/confidential/issues/2940) Patched a potential security issue in UI # 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>
44 lines
1 KiB
TypeScript
44 lines
1 KiB
TypeScript
import classnames from "classnames";
|
|
import React from "react";
|
|
|
|
import * as DOMPurify from "dompurify";
|
|
|
|
interface ITooltipWrapperProps {
|
|
children: string;
|
|
tipContent: string;
|
|
position?: "top" | "bottom";
|
|
isDelayed?: boolean;
|
|
className?: string;
|
|
}
|
|
|
|
const baseClass = "component__tooltip-wrapper";
|
|
|
|
const TooltipWrapper = ({
|
|
children,
|
|
tipContent,
|
|
position = "bottom",
|
|
isDelayed,
|
|
className,
|
|
}: ITooltipWrapperProps): JSX.Element => {
|
|
const classname = classnames(baseClass, className);
|
|
const tipClass = isDelayed
|
|
? `${baseClass}__tip-text delayed-tip`
|
|
: `${baseClass}__tip-text`;
|
|
|
|
const sanitizedTipContent = DOMPurify.sanitize(tipContent);
|
|
|
|
return (
|
|
<div className={classname} data-position={position}>
|
|
<div className={`${baseClass}__element`}>
|
|
{children}
|
|
<div className={`${baseClass}__underline`} data-text={children} />
|
|
</div>
|
|
<div
|
|
className={tipClass}
|
|
dangerouslySetInnerHTML={{ __html: sanitizedTipContent }}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default TooltipWrapper;
|