From 9659da5b315d3b1a92b8edab6d225b16cb891d61 Mon Sep 17 00:00:00 2001
From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com>
Date: Tue, 23 Apr 2024 13:01:26 +0530
Subject: [PATCH] [WEB-1034] fix: inbox issue user activity (#4251)
* fix: inbox issue user activity
* chore: code refactor
* fix: sentry issue
---
web/components/core/activity.tsx | 52 ++++++++++++++++++++++++++++++--
web/store/label.store.ts | 4 +--
2 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/web/components/core/activity.tsx b/web/components/core/activity.tsx
index 31a796949..629e9908d 100644
--- a/web/components/core/activity.tsx
+++ b/web/components/core/activity.tsx
@@ -17,6 +17,7 @@ import {
SignalMediumIcon,
MessageSquareIcon,
UsersIcon,
+ Inbox,
} from "lucide-react";
import { IIssueActivity } from "@plane/types";
import { Tooltip, BlockedIcon, BlockerIcon, RelatedIcon, LayersIcon, DiceIcon } from "@plane/ui";
@@ -112,6 +113,40 @@ const EstimatePoint = observer((props: { point: string }) => {
);
});
+const inboxActivityMessage = {
+ declined: {
+ showIssue: "declined issue",
+ noIssue: "declined this issue from inbox.",
+ },
+ snoozed: {
+ showIssue: "snoozed issue",
+ noIssue: "snoozed this issue.",
+ },
+ accepted: {
+ showIssue: "accepted issue",
+ noIssue: "accepted this issue from inbox.",
+ },
+ markedDuplicate: {
+ showIssue: "declined issue",
+ noIssue: "declined this issue from inbox by marking a duplicate issue.",
+ },
+};
+
+const getInboxUserActivityMessage = (activity: IIssueActivity, showIssue: boolean) => {
+ switch (activity.verb) {
+ case "-1":
+ return showIssue ? inboxActivityMessage.declined.showIssue : inboxActivityMessage.declined.noIssue;
+ case "0":
+ return showIssue ? inboxActivityMessage.snoozed.showIssue : inboxActivityMessage.snoozed.noIssue;
+ case "1":
+ return showIssue ? inboxActivityMessage.accepted.showIssue : inboxActivityMessage.accepted.noIssue;
+ case "2":
+ return showIssue ? inboxActivityMessage.markedDuplicate.showIssue : inboxActivityMessage.markedDuplicate.noIssue;
+ default:
+ return "updated inbox issue status.";
+ }
+};
+
const activityDetails: {
[key: string]: {
message: (activity: IIssueActivity, showIssue: boolean, workspaceSlug: string) => React.ReactNode;
@@ -658,8 +693,7 @@ const activityDetails: {
{renderFormattedDate(activity.new_value)}
{showIssue && (
<>
- {" "}
- for
+
>
)}
>
@@ -667,6 +701,20 @@ const activityDetails: {
},
icon: ,
},
+ inbox: {
+ message: (activity, showIssue) => (
+ <>
+ {getInboxUserActivityMessage(activity, showIssue)}
+ {showIssue && (
+ <>
+ {" "}
+
+ >
+ )}
+ >
+ ),
+ icon: ,
+ },
};
export const ActivityIcon = ({ activity }: { activity: IIssueActivity }) => (
diff --git a/web/store/label.store.ts b/web/store/label.store.ts
index 3f343f9a4..e6b95da90 100644
--- a/web/store/label.store.ts
+++ b/web/store/label.store.ts
@@ -96,7 +96,7 @@ export class LabelStore implements ILabelStore {
const workspaceSlug = this.rootStore.app.router.workspaceSlug || "";
if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[workspaceSlug])) return;
return sortBy(
- Object.values(this.labelMap).filter((label) => label.project_id === projectId),
+ Object.values(this.labelMap).filter((label) => label?.project_id === projectId),
"sort_order"
);
}
@@ -113,7 +113,7 @@ export class LabelStore implements ILabelStore {
const workspaceSlug = this.rootStore.app.router.workspaceSlug || "";
if (!projectId || !(this.fetchedMap[projectId] || this.fetchedMap[workspaceSlug])) return;
return sortBy(
- Object.values(this.labelMap).filter((label) => label.project_id === projectId),
+ Object.values(this.labelMap).filter((label) => label?.project_id === projectId),
"sort_order"
);
});