mirror of
https://github.com/fleetdm/fleet
synced 2026-04-28 08:57:30 +00:00
relates to #12926 This implements the changes to the Controls page that add the windows Bitlocker functionality. There is some work that needs to be complete when the API is done. For now we are mocking the new disk encryption API response **new column for windows hosts:**  also includes various other changes behind the scenes that include windows hosts into the disk encryption as well as changes to the profiles status summary to use StatusIndicatorWithIcon - [x] Changes file added for user-visible changes in `changes/` or `orbit/changes/`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Manual QA for all new/changed functionality
84 lines
2 KiB
TypeScript
84 lines
2 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";
|
|
|
|
export type IndicatorStatus =
|
|
| "success"
|
|
| "successPartial"
|
|
| "pending"
|
|
| "pendingPartial"
|
|
| "error";
|
|
|
|
interface IStatusIndicatorWithIconProps {
|
|
status: IndicatorStatus;
|
|
value: string;
|
|
tooltip?: {
|
|
tooltipText: string | JSX.Element;
|
|
position?: "top" | "bottom";
|
|
};
|
|
layout?: "horizontal" | "vertical";
|
|
className?: string;
|
|
/** Classname to add to the value text */
|
|
valueClassName?: string;
|
|
}
|
|
|
|
const statusIconNameMapping: Record<IndicatorStatus, IconNames> = {
|
|
success: "success",
|
|
successPartial: "success-partial",
|
|
pending: "pending",
|
|
pendingPartial: "pending-partial",
|
|
error: "error",
|
|
};
|
|
|
|
const StatusIndicatorWithIcon = ({
|
|
status,
|
|
value,
|
|
tooltip,
|
|
layout = "horizontal",
|
|
className,
|
|
valueClassName,
|
|
}: IStatusIndicatorWithIconProps) => {
|
|
const classNames = classnames(baseClass, className);
|
|
const id = `status-${uniqueId()}`;
|
|
|
|
const valueClasses = classnames(`${baseClass}__value`, valueClassName, {
|
|
[`${baseClass}__value-vertical`]: layout === "vertical",
|
|
});
|
|
const valueContent = (
|
|
<span className={valueClasses}>
|
|
<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;
|