From a8816ef473c38a7cfd22696f3268ef64eebcef3d Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Tue, 1 Aug 2023 17:07:11 +0530 Subject: [PATCH] refactor: issue activity component (#1749) --- .../core/activity.tsx} | 239 ++++++++++++++++-- apps/app/components/core/index.ts | 1 + apps/app/components/issues/activity.tsx | 15 +- .../issues/comment/comment-card.tsx | 6 +- .../issues/comment/comment-reaction.tsx | 8 +- .../components/profile/overview/activity.tsx | 8 +- apps/app/types/issues.d.ts | 25 +- apps/app/types/users.d.ts | 26 +- 8 files changed, 243 insertions(+), 85 deletions(-) rename apps/app/{helpers/activity.helper.tsx => components/core/activity.tsx} (62%) diff --git a/apps/app/helpers/activity.helper.tsx b/apps/app/components/core/activity.tsx similarity index 62% rename from apps/app/helpers/activity.helper.tsx rename to apps/app/components/core/activity.tsx index af5d9bf12..078941b02 100644 --- a/apps/app/helpers/activity.helper.tsx +++ b/apps/app/components/core/activity.tsx @@ -1,5 +1,7 @@ +import { useRouter } from "next/router"; + // icons -import { Icon } from "components/ui"; +import { Icon, Tooltip } from "components/ui"; import { Squares2X2Icon } from "@heroicons/react/24/outline"; import { BlockedIcon, BlockerIcon } from "components/icons"; // helpers @@ -8,26 +10,65 @@ import { capitalizeFirstLetter } from "helpers/string.helper"; // types import { IIssueActivity } from "types"; -export const activityDetails: { +const IssueLink = ({ activity }: { activity: IIssueActivity }) => { + const router = useRouter(); + const { workspaceSlug } = router.query; + + return ( + + + {activity.issue_detail + ? `${activity.project_detail.identifier}-${activity.issue_detail.sequence_id}` + : "Issue"} + + + + ); +}; + +const activityDetails: { [key: string]: { - message: (activity: IIssueActivity) => React.ReactNode; + message: (activity: IIssueActivity, showIssue: boolean) => React.ReactNode; icon: React.ReactNode; }; } = { assignees: { - message: (activity) => { + message: (activity, showIssue) => { if (activity.old_value === "") return ( <> added a new assignee{" "} - {activity.new_value}. + {activity.new_value} + {showIssue && ( + <> + {" "} + to + + )} + . ); else return ( <> removed the assignee{" "} - {activity.old_value}. + {activity.old_value} + {showIssue && ( + <> + {" "} + from + + )} + . ); }, @@ -41,7 +82,7 @@ export const activityDetails: { icon: