2023-08-22 13:20:40 +00:00
|
|
|
// Utilizes Link over Button so we can right click links
|
2021-04-12 13:32:25 +00:00
|
|
|
import React from "react";
|
2022-04-22 16:45:35 +00:00
|
|
|
|
2023-08-22 13:20:40 +00:00
|
|
|
import { Link } from "react-router";
|
|
|
|
|
import classnames from "classnames";
|
2023-09-13 17:19:56 +00:00
|
|
|
import TooltipWrapper from "components/TooltipWrapper";
|
2025-04-10 19:42:10 +00:00
|
|
|
import TooltipTruncatedTextCell from "../TooltipTruncatedTextCell";
|
2021-02-11 16:22:22 +00:00
|
|
|
|
2022-04-07 19:12:38 +00:00
|
|
|
interface ILinkCellProps {
|
2024-07-30 20:50:15 +00:00
|
|
|
value: string | JSX.Element;
|
2025-04-10 19:42:10 +00:00
|
|
|
path?: string;
|
2023-08-22 13:20:40 +00:00
|
|
|
className?: string;
|
|
|
|
|
customOnClick?: (e: React.MouseEvent) => void;
|
|
|
|
|
/** allows viewing overflow for tooltip */
|
2023-11-07 21:15:49 +00:00
|
|
|
tooltipContent?: string | React.ReactNode;
|
2021-04-29 13:47:33 +00:00
|
|
|
title?: string;
|
2025-04-10 19:42:10 +00:00
|
|
|
/** Used to create TooltipTruncationText on link cell */
|
|
|
|
|
tooltipTruncate?: boolean;
|
|
|
|
|
/** Optionally add unstyled prefix before tooltip truncation */
|
|
|
|
|
prefix?: JSX.Element;
|
|
|
|
|
/** Optionally add unstyled suffix after tooltip truncation */
|
|
|
|
|
suffix?: JSX.Element;
|
2021-03-03 16:51:39 +00:00
|
|
|
}
|
|
|
|
|
|
2023-08-22 13:20:40 +00:00
|
|
|
const baseClass = "link-cell";
|
|
|
|
|
|
2022-04-07 19:12:38 +00:00
|
|
|
const LinkCell = ({
|
|
|
|
|
value,
|
2025-04-10 19:42:10 +00:00
|
|
|
path = "",
|
2023-08-22 13:20:40 +00:00
|
|
|
className,
|
2023-05-08 13:17:19 +00:00
|
|
|
customOnClick,
|
2023-08-22 13:20:40 +00:00
|
|
|
title,
|
2023-09-13 17:19:56 +00:00
|
|
|
tooltipContent,
|
2025-04-10 19:42:10 +00:00
|
|
|
tooltipTruncate = false,
|
|
|
|
|
prefix,
|
|
|
|
|
suffix,
|
2022-04-07 19:12:38 +00:00
|
|
|
}: ILinkCellProps): JSX.Element => {
|
2025-09-29 17:10:41 +00:00
|
|
|
const cellClasses = classnames(baseClass, className, {
|
|
|
|
|
[`${baseClass}--tooltip`]: !!tooltipContent,
|
|
|
|
|
[`${baseClass}--tooltip-truncate`]: tooltipTruncate,
|
|
|
|
|
});
|
2023-08-22 13:20:40 +00:00
|
|
|
|
|
|
|
|
const onClick = (e: React.MouseEvent): void => {
|
|
|
|
|
customOnClick && customOnClick(e);
|
2021-02-11 16:22:22 +00:00
|
|
|
};
|
|
|
|
|
|
2025-04-10 19:42:10 +00:00
|
|
|
if (tooltipTruncate)
|
|
|
|
|
return (
|
|
|
|
|
<Link
|
|
|
|
|
className={cellClasses}
|
|
|
|
|
to={path}
|
|
|
|
|
onClick={customOnClick}
|
|
|
|
|
title={title}
|
|
|
|
|
>
|
|
|
|
|
<TooltipTruncatedTextCell
|
|
|
|
|
value={value}
|
|
|
|
|
prefix={prefix}
|
|
|
|
|
suffix={suffix}
|
|
|
|
|
/>
|
2023-09-13 17:19:56 +00:00
|
|
|
</Link>
|
2025-04-10 19:42:10 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (tooltipContent)
|
|
|
|
|
return (
|
|
|
|
|
<TooltipWrapper
|
|
|
|
|
className="link-cell-tooltip-wrapper"
|
|
|
|
|
tipContent={tooltipContent}
|
|
|
|
|
>
|
|
|
|
|
<Link className={cellClasses} to={path} onClick={onClick} title={title}>
|
|
|
|
|
{value}
|
|
|
|
|
</Link>
|
|
|
|
|
</TooltipWrapper>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
2023-09-13 17:19:56 +00:00
|
|
|
<Link
|
|
|
|
|
className={cellClasses}
|
|
|
|
|
to={path}
|
|
|
|
|
onClick={customOnClick}
|
|
|
|
|
title={title}
|
|
|
|
|
>
|
2021-02-11 16:22:22 +00:00
|
|
|
{value}
|
2023-08-22 13:20:40 +00:00
|
|
|
</Link>
|
2021-02-11 16:22:22 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default LinkCell;
|