import { FC, useState } from "react"; // hooks // ui import { Pencil, Trash2, LinkIcon } from "lucide-react"; import { ExternalLinkIcon, Tooltip, TOAST_TYPE, setToast } from "@plane/ui"; // icons // types // helpers import { calculateTimeAgo } from "helpers/date-time.helper"; import { copyTextToClipboard } from "helpers/string.helper"; import { useIssueDetail, useMember } from "hooks/store"; import { usePlatformOS } from "hooks/use-platform-os"; import { IssueLinkCreateUpdateModal, TLinkOperationsModal } from "./create-update-link-modal"; export type TIssueLinkDetail = { linkId: string; linkOperations: TLinkOperationsModal; isNotAllowed: boolean; }; export const IssueLinkDetail: FC = (props) => { // props const { linkId, linkOperations, isNotAllowed } = props; // hooks const { toggleIssueLinkModal: toggleIssueLinkModalStore, link: { getLinkById }, } = useIssueDetail(); const { getUserDetails } = useMember(); // state const [isIssueLinkModalOpen, setIsIssueLinkModalOpen] = useState(false); const toggleIssueLinkModal = (modalToggle: boolean) => { toggleIssueLinkModalStore(modalToggle); setIsIssueLinkModalOpen(modalToggle); }; const { isMobile } = usePlatformOS(); const linkDetail = getLinkById(linkId); if (!linkDetail) return <>; const createdByDetails = getUserDetails(linkDetail.created_by_id); return (
{ copyTextToClipboard(linkDetail.url); setToast({ type: TOAST_TYPE.SUCCESS, title: "Link copied!", message: "Link copied to clipboard", }); }} >
{linkDetail.title && linkDetail.title !== "" ? linkDetail.title : linkDetail.url}
{!isNotAllowed && (
)}

Added {calculateTimeAgo(linkDetail.created_at)}
{createdByDetails && ( <> by {createdByDetails?.is_bot ? createdByDetails?.first_name + " Bot" : createdByDetails?.display_name} )}

); };