import { useEffect } from "react"; import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; // store hooks // icons import { TagIcon, CopyPlus, Calendar, Link2Icon, Users2Icon, ArchiveIcon, PaperclipIcon, ContrastIcon, TriangleIcon, LayoutGridIcon, SignalMediumIcon, MessageSquareIcon, UsersIcon, } from "lucide-react"; import { Tooltip, BlockedIcon, BlockerIcon, RelatedIcon, LayersIcon, DiceIcon } from "@plane/ui"; // helpers import { renderFormattedDate } from "helpers/date-time.helper"; import { capitalizeFirstLetter } from "helpers/string.helper"; import { useEstimate, useEventTracker, useLabel } from "hooks/store"; // types import { IIssueActivity } from "@plane/types"; // constants import { ISSUE_OPENED, elementFromPath } from "constants/event-tracker"; export const IssueLink = ({ activity }: { activity: IIssueActivity }) => { const router = useRouter(); const { workspaceSlug } = router.query; // store hooks const { captureEvent } = useEventTracker(); return ( {activity?.issue_detail ? ( { captureEvent(ISSUE_OPENED, { ...elementFromPath(router.asPath), element_id: "activity", mode: "detail", }); }} target={activity.issue === null ? "_self" : "_blank"} rel={activity.issue === null ? "" : "noopener noreferrer"} className="inline-flex items-center gap-1 font-medium text-custom-text-100 hover:underline" > {`${activity.project_detail.identifier}-${activity.issue_detail.sequence_id}`}{" "} {activity.issue_detail?.name} ) : ( {" an Issue"}{" "} )} ); }; const UserLink = ({ activity }: { activity: IIssueActivity }) => { const router = useRouter(); const { workspaceSlug } = router.query; return ( {activity.new_value && activity.new_value !== "" ? activity.new_value : activity.old_value} ); }; const LabelPill = observer(({ labelId, workspaceSlug }: { labelId: string; workspaceSlug: string }) => { // store hooks const { workspaceLabels, fetchWorkspaceLabels } = useLabel(); useEffect(() => { if (!workspaceLabels) fetchWorkspaceLabels(workspaceSlug); }, [fetchWorkspaceLabels, workspaceLabels, workspaceSlug]); return ( l.id === labelId)?.color ?? "#000000", }} aria-hidden="true" /> ); }); const EstimatePoint = observer((props: { point: string }) => { const { point } = props; const { areEstimatesEnabledForCurrentProject, getEstimatePointValue } = useEstimate(); const currentPoint = Number(point) + 1; const estimateValue = getEstimatePointValue(Number(point), null); return ( {areEstimatesEnabledForCurrentProject ? estimateValue : `${currentPoint} ${currentPoint > 1 ? "points" : "point"}`} ); }); const activityDetails: { [key: string]: { message: (activity: IIssueActivity, showIssue: boolean, workspaceSlug: string) => React.ReactNode; icon: React.ReactNode; }; } = { assignees: { message: (activity, showIssue) => { if (activity.old_value === "") return ( <> added a new assignee {showIssue && ( <> {" "} to )} ); else return ( <> removed the assignee {showIssue && ( <> {" "} from )} ); }, icon: