import React from "react";
import classnames from "classnames";
import { uniqueId } from "lodash";
import ReactTooltip from "react-tooltip";
interface IPillCellProps {
value: { indicator: string; id: number };
customIdPrefix?: string;
hostDetails?: boolean;
}
const generateClassTag = (rawValue: string): string => {
return rawValue.replace(" ", "-").toLowerCase();
};
const PillCell = ({
value,
customIdPrefix,
hostDetails,
}: IPillCellProps): JSX.Element => {
const { indicator, id } = value;
const pillClassName = classnames(
"data-table__pill",
`data-table__pill--${generateClassTag(indicator || "")}`,
"tooltip"
);
const disable = () => {
switch (indicator) {
case "Minimal":
return false;
case "Considerable":
return false;
case "Excessive":
return false;
case "Undetermined":
return false;
default:
return true;
}
};
const tooltipText = () => {
switch (indicator) {
case "Minimal":
return (
<>
Running this query very
frequently has little to no
impact on your device’s
performance.
>
);
case "Considerable":
return (
<>
Running this query
frequently can have a
noticeable
impact on your
device’s performance.
>
);
case "Excessive":
return (
<>
Running this query, even
infrequently, can have a
significant impact on your
device’s performance.
>
);
case "Denylisted":
return (
<>
This query has been
stopped from running
because of
excessive
resource consumption.
>
);
case "Undetermined":
return (
<>
To see performance
impact, this query must
run as a
scheduled query
on {hostDetails ? "this" : "at least one"}{" "}
host.
>
);
default:
return null;
}
};
const tooltipId = uniqueId();
return (
<>
{indicator}
{tooltipText()}
>
);
};
export default PillCell;