mirror of
https://github.com/fleetdm/fleet
synced 2026-05-05 06:18:25 +00:00
Co-authored-by: Jacob Shandling <jacob@fleetdm.com> Co-authored-by: Luke Heath <luke@fleetdm.com>
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import React from "react";
|
|
import classnames from "classnames";
|
|
import ReactTooltip from "react-tooltip";
|
|
|
|
interface IStatusCellProps {
|
|
value: string;
|
|
tooltip?: {
|
|
id: number;
|
|
tooltipText: string;
|
|
};
|
|
}
|
|
|
|
const generateClassTag = (rawValue: string): string => {
|
|
if (rawValue === "---") {
|
|
return "indeterminate";
|
|
}
|
|
return rawValue.replace(" ", "-").toLowerCase();
|
|
};
|
|
|
|
const StatusCell = ({ value, tooltip }: IStatusCellProps): JSX.Element => {
|
|
const classTag = generateClassTag(value);
|
|
const statusClassName = classnames(
|
|
"data-table__status",
|
|
`data-table__status--${classTag}`,
|
|
`status--${classTag}`
|
|
);
|
|
const cellContent = tooltip ? (
|
|
<>
|
|
<span
|
|
className="host-status tooltip tooltip__tooltip-icon"
|
|
data-tip
|
|
data-for={`status-${tooltip.id}`}
|
|
data-tip-disable={false}
|
|
>
|
|
{value}
|
|
</span>
|
|
<ReactTooltip
|
|
className="status-tooltip"
|
|
place="top"
|
|
type="dark"
|
|
effect="solid"
|
|
id={`status-${tooltip.id}`}
|
|
backgroundColor="#3e4771"
|
|
>
|
|
{tooltip.tooltipText}
|
|
</ReactTooltip>
|
|
</>
|
|
) : (
|
|
<>{value}</>
|
|
);
|
|
return <span className={statusClassName}>{cellContent}</span>;
|
|
};
|
|
|
|
export default StatusCell;
|