2023-12-12 21:03:33 +00:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
|
|
import TextCell from "components/TableContainer/DataTable/TextCell";
|
2024-06-17 17:47:24 +00:00
|
|
|
import TooltipWrapper from "components/TooltipWrapper";
|
2023-12-12 21:03:33 +00:00
|
|
|
|
2024-05-09 21:44:50 +00:00
|
|
|
const generateText = <T extends { version: string }>(versions: T[] | null) => {
|
2024-01-25 18:03:44 +00:00
|
|
|
if (!versions) {
|
2024-07-18 09:20:17 +00:00
|
|
|
return <TextCell value="---" grey />;
|
2024-01-25 18:03:44 +00:00
|
|
|
}
|
2023-12-12 21:03:33 +00:00
|
|
|
const text =
|
|
|
|
|
versions.length !== 1 ? `${versions.length} versions` : versions[0].version;
|
2024-07-03 16:40:03 +00:00
|
|
|
return <TextCell value={text} italic={versions.length !== 1} />;
|
2023-12-12 21:03:33 +00:00
|
|
|
};
|
|
|
|
|
|
2024-05-09 21:44:50 +00:00
|
|
|
interface IVersionCellProps<T extends { version: string }> {
|
|
|
|
|
versions: T[] | null;
|
2023-12-12 21:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
2024-05-09 21:44:50 +00:00
|
|
|
const VersionCell = <T extends { version: string }>({
|
|
|
|
|
versions,
|
|
|
|
|
}: IVersionCellProps<T>) => {
|
2023-12-12 21:03:33 +00:00
|
|
|
// only one version, no need for tooltip
|
|
|
|
|
const cellText = generateText(versions);
|
2024-05-13 14:36:13 +00:00
|
|
|
if (!versions || versions.length <= 1) {
|
2023-12-12 21:03:33 +00:00
|
|
|
return <>{cellText}</>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2024-06-17 17:47:24 +00:00
|
|
|
<TooltipWrapper
|
2024-07-03 16:40:03 +00:00
|
|
|
tipContent={<>{versions.map((version) => version.version).join(", ")}</>}
|
2024-06-17 17:47:24 +00:00
|
|
|
tipOffset={14}
|
|
|
|
|
position="top"
|
|
|
|
|
showArrow
|
|
|
|
|
underline={false}
|
|
|
|
|
>
|
|
|
|
|
{cellText}
|
|
|
|
|
</TooltipWrapper>
|
2023-12-12 21:03:33 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default VersionCell;
|