Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WEB-1696] chore: rendering mention comments in notification modal (#4903)

guru_sainath7c4c777c99b2
diff --git a/web/core/components/notifications/notification-card.tsx b/web/core/components/notifications/notification-card.tsx
index 7c4a8313ec..9b540d1185 100644
--- a/web/core/components/notifications/notification-card.tsx
+++ b/web/core/components/notifications/notification-card.tsx
@@ -8,7 +8,6 @@ import { ArchiveRestore, Clock, MessageSquare, MoreVertical, User2 } from "lucid
import { Menu } from "@headlessui/react";
// type
import type { IUserNotification, NotificationType } from "@plane/types";
-// ui
import { ArchiveIcon, CustomMenu, Tooltip, TOAST_TYPE, setToast } from "@plane/ui";
// constants
import {
@@ -20,6 +19,7 @@ import {
import { snoozeOptions } from "@/constants/notification";
// helper
import { calculateTimeAgo, renderFormattedTime, renderFormattedDate, getDate } from "@/helpers/date-time.helper";
+import { sanitizeCommentForNotification } from "@/helpers/notification.helper";
import { replaceUnderscoreIfSnakeCase, truncateText, stripAndTruncateHTML } from "@/helpers/string.helper";
// hooks
import { useEventTracker } from "@/hooks/store";
@@ -206,11 +206,7 @@ export const NotificationCard: React.FC<NotificationCardProps> = (props) => {
)
) : (
<span>
- {`"`}
- {notification.data.issue_activity.new_value.length > 55
- ? notification?.data?.issue_activity?.issue_comment?.slice(0, 50) + "..."
- : notification.data.issue_activity.issue_comment}
- {`"`}
+ {sanitizeCommentForNotification(notification.data.issue_activity.new_value ?? undefined)}
</span>
)
) : (
diff --git a/web/helpers/notification.helper.ts b/web/helpers/notification.helper.ts
new file mode 100644
index 0000000000..fbc77d21bf
--- /dev/null
+++ b/web/helpers/notification.helper.ts
@@ -0,0 +1,8 @@
+import { stripAndTruncateHTML } from "./string.helper";
+
+export const sanitizeCommentForNotification = (mentionContent: string | undefined) =>
+ mentionContent
+ ? stripAndTruncateHTML(
+ mentionContent.replace(/<mention-component\b[^>]*\blabel="([^"]*)"[^>]*><\/mention-component>/g, "$1")
+ )
+ : mentionContent;