2021-09-01 22:08:20 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import classnames from "classnames";
|
|
|
|
|
|
2026-04-02 17:32:30 +00:00
|
|
|
import TooltipWrapper from "components/TooltipWrapper";
|
2021-09-01 22:08:20 +00:00
|
|
|
|
2026-01-02 13:06:12 +00:00
|
|
|
import {
|
|
|
|
|
isPerformanceImpactIndicator,
|
|
|
|
|
PerformanceImpactIndicatorValue,
|
|
|
|
|
} from "interfaces/schedulable_query";
|
2026-04-02 17:32:30 +00:00
|
|
|
import { getPerformanceImpactIndicatorTooltip } from "utilities/helpers";
|
2026-01-02 13:06:12 +00:00
|
|
|
|
2023-12-14 19:49:56 +00:00
|
|
|
interface IPerformanceImpactCellValue {
|
|
|
|
|
indicator: string;
|
|
|
|
|
}
|
|
|
|
|
interface IPerformanceImpactCellProps {
|
|
|
|
|
value: IPerformanceImpactCellValue;
|
|
|
|
|
isHostSpecific?: boolean;
|
2021-09-01 22:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const generateClassTag = (rawValue: string): string => {
|
|
|
|
|
return rawValue.replace(" ", "-").toLowerCase();
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-14 19:49:56 +00:00
|
|
|
const baseClass = "performance-impact-cell";
|
|
|
|
|
|
|
|
|
|
const PerformanceImpactCell = ({
|
2023-07-19 18:02:53 +00:00
|
|
|
value,
|
2023-12-14 19:49:56 +00:00
|
|
|
isHostSpecific = false,
|
|
|
|
|
}: IPerformanceImpactCellProps): JSX.Element => {
|
2026-04-02 17:32:30 +00:00
|
|
|
const { indicator } = value;
|
2021-09-01 22:08:20 +00:00
|
|
|
const pillClassName = classnames(
|
|
|
|
|
"data-table__pill",
|
2022-12-07 17:59:38 +00:00
|
|
|
`data-table__pill--${generateClassTag(indicator || "")}`,
|
2022-07-15 19:10:35 +00:00
|
|
|
"tooltip"
|
2021-09-01 22:08:20 +00:00
|
|
|
);
|
|
|
|
|
|
2023-12-14 19:49:56 +00:00
|
|
|
const disableTooltip = ![
|
|
|
|
|
"Minimal",
|
|
|
|
|
"Considerable",
|
|
|
|
|
"Excessive",
|
|
|
|
|
"Undetermined",
|
|
|
|
|
].includes(indicator);
|
2021-09-01 22:08:20 +00:00
|
|
|
|
2026-01-02 13:06:12 +00:00
|
|
|
const indicatorValue = isPerformanceImpactIndicator(indicator)
|
|
|
|
|
? indicator
|
|
|
|
|
: PerformanceImpactIndicatorValue.UNDETERMINED;
|
|
|
|
|
|
2021-09-01 22:08:20 +00:00
|
|
|
return (
|
2023-12-14 19:49:56 +00:00
|
|
|
<span className={`${baseClass}`}>
|
2026-04-02 17:32:30 +00:00
|
|
|
<TooltipWrapper
|
|
|
|
|
tipContent={
|
|
|
|
|
<span
|
|
|
|
|
className={`tooltip ${generateClassTag(
|
|
|
|
|
indicator || ""
|
|
|
|
|
)}__tooltip-text`}
|
|
|
|
|
>
|
|
|
|
|
{getPerformanceImpactIndicatorTooltip(
|
|
|
|
|
indicatorValue,
|
|
|
|
|
isHostSpecific
|
|
|
|
|
)}
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
position="top"
|
|
|
|
|
disableTooltip={disableTooltip}
|
|
|
|
|
underline={false}
|
|
|
|
|
showArrow
|
|
|
|
|
// Pills require more gap from text to tooltip
|
|
|
|
|
tipOffset={indicatorValue === "Undetermined" ? 8 : 12}
|
2021-09-29 04:04:58 +00:00
|
|
|
>
|
2026-01-02 13:06:12 +00:00
|
|
|
<span className={pillClassName}>{indicatorValue}</span>
|
2026-04-02 17:32:30 +00:00
|
|
|
</TooltipWrapper>
|
2023-12-14 19:49:56 +00:00
|
|
|
</span>
|
2021-09-01 22:08:20 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-14 19:49:56 +00:00
|
|
|
export default PerformanceImpactCell;
|