mirror of
https://github.com/fleetdm/fleet
synced 2026-05-18 06:28:40 +00:00
related to #9402 and #9404 Implements UI for toggling off and on fleet mdm disk encryption management and also the disk encryption aggregate data tables. **Toggling disk encryption:**  **disk encryption aggregate:**  - [x] Changes file added for user-visible changes in `changes/` or `orbit/changes/`. - [x] Manual QA for all new/changed functionality
69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import React from "react";
|
|
import ReactTooltip from "react-tooltip";
|
|
import { uniqueId } from "lodash";
|
|
import classnames from "classnames";
|
|
|
|
import { IconNames } from "components/icons";
|
|
import Icon from "components/Icon";
|
|
import { COLORS } from "styles/var/colors";
|
|
|
|
const baseClass = "status-indicator-with-icon";
|
|
|
|
type Status = "success" | "pending" | "error";
|
|
|
|
interface IStatusIndicatorWithIconProps {
|
|
status: Status;
|
|
value: string;
|
|
tooltip?: {
|
|
tooltipText: string | JSX.Element;
|
|
position?: "top" | "bottom";
|
|
};
|
|
className?: string;
|
|
}
|
|
|
|
const statusIconNameMapping: Record<Status, IconNames> = {
|
|
success: "success",
|
|
pending: "pending",
|
|
error: "error",
|
|
};
|
|
|
|
const StatusIndicatorWithIcon = ({
|
|
status,
|
|
value,
|
|
tooltip,
|
|
className,
|
|
}: IStatusIndicatorWithIconProps) => {
|
|
const classNames = classnames(baseClass, className);
|
|
const id = `status-${uniqueId()}`;
|
|
|
|
const valueContent = (
|
|
<span className={`${baseClass}__value`}>
|
|
<Icon name={statusIconNameMapping[status]} />
|
|
<span>{value}</span>
|
|
</span>
|
|
);
|
|
|
|
const indicatorContent = tooltip ? (
|
|
<>
|
|
<span data-tip data-for={id}>
|
|
{valueContent}
|
|
</span>
|
|
<ReactTooltip
|
|
className={`${baseClass}__tooltip`}
|
|
place={tooltip?.position ? tooltip.position : "top"}
|
|
type="dark"
|
|
effect="solid"
|
|
id={id}
|
|
backgroundColor={COLORS["tooltip-bg"]}
|
|
>
|
|
{tooltip.tooltipText}
|
|
</ReactTooltip>
|
|
</>
|
|
) : (
|
|
<span>{valueContent}</span>
|
|
);
|
|
|
|
return <div className={classNames}>{indicatorContent}</div>;
|
|
};
|
|
|
|
export default StatusIndicatorWithIcon;
|