[WEB-1034] fix: inbox issue user activity (#4251)

* fix: inbox issue user activity

* chore: code refactor

* fix: sentry issue
This commit is contained in:
Anmol Singh Bhatia 2024-04-23 13:01:26 +05:30 committed by GitHub
parent 51ade1295c
commit 9659da5b31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 52 additions and 4 deletions

View File

@ -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: {
<span className="font-medium text-custom-text-100">{renderFormattedDate(activity.new_value)}</span>
{showIssue && (
<>
{" "}
for <IssueLink activity={activity} />
<IssueLink activity={activity} />
</>
)}
</>
@ -667,6 +701,20 @@ const activityDetails: {
},
icon: <Calendar size={12} color="#6b7280" aria-hidden="true" />,
},
inbox: {
message: (activity, showIssue) => (
<>
{getInboxUserActivityMessage(activity, showIssue)}
{showIssue && (
<>
{" "}
<IssueLink activity={activity} />
</>
)}
</>
),
icon: <Inbox size={12} color="#6b7280" aria-hidden="true" />,
},
};
export const ActivityIcon = ({ activity }: { activity: IIssueActivity }) => (

View File

@ -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"
);
});