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

* chore: rendering mention comments in notification modal

* chore: resolved build errors

* chore: updated workflow

* chore: updated function name and handled the notification mention render
This commit is contained in:
guru_sainath 2024-06-24 17:13:17 +05:30 committed by GitHub
parent 08c4027e77
commit 7c4c777c99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View file

@ -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>
)
) : (

View file

@ -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;