From 07e937cd8ec16fc9ce84a8535ea2f32d1b445af2 Mon Sep 17 00:00:00 2001
From: Vamsi Krishna <46787868+vamsikrishnamathala@users.noreply.github.com>
Date: Mon, 9 Jun 2025 15:33:57 +0530
Subject: [PATCH] [WEB-4094]chore: workspace notifications refactor (#7061)
* chore: workspace notifications refactor
* fix: url params
* fix: added null checks to avoid run time errors
* fix: notifications header color fix
---
packages/types/src/issues/issue.d.ts | 9 +-
.../(projects)/notifications/page.tsx | 97 +--------
.../workspace-notifications/index.ts | 1 +
.../workspace-notifications/list-root.tsx | 8 +
web/ce/hooks/use-notification-preview.tsx | 25 +++
.../issues/issue-detail/subscription.tsx | 13 +-
.../components/issues/peek-overview/root.tsx | 10 +-
.../workspace-notifications/root.tsx | 188 +++++++++---------
.../sidebar/header/root.tsx | 2 +-
.../workspace-notifications/sidebar/index.ts | 2 +
.../workspace-notifications/sidebar/root.tsx | 118 +++++++++++
.../store/issue/issue-details/root.store.ts | 2 +-
.../issue/issue-details/subscription.store.ts | 6 +-
13 files changed, 273 insertions(+), 208 deletions(-)
create mode 100644 web/ce/components/workspace-notifications/list-root.tsx
create mode 100644 web/ce/hooks/use-notification-preview.tsx
create mode 100644 web/core/components/workspace-notifications/sidebar/root.tsx
diff --git a/packages/types/src/issues/issue.d.ts b/packages/types/src/issues/issue.d.ts
index a9d8970f9..01c0b2f3a 100644
--- a/packages/types/src/issues/issue.d.ts
+++ b/packages/types/src/issues/issue.d.ts
@@ -1,4 +1,4 @@
-import { EIssueServiceType } from "@plane/constants";
+import { EIssueServiceType, EIssuesStoreType } from "@plane/constants";
import { TIssuePriorities } from "../issues";
import { TIssueAttachment } from "./issue_attachment";
import { TIssueLink } from "./issue_link";
@@ -181,3 +181,10 @@ export type TPublicIssuesResponse = {
extra_stats: null;
results: TPublicIssueResponseResults;
};
+
+export interface IWorkItemPeekOverview {
+ embedIssue?: boolean;
+ embedRemoveCurrentNotification?: () => void;
+ is_draft?: boolean;
+ storeType?: EIssuesStoreType;
+}
\ No newline at end of file
diff --git a/web/app/(all)/[workspaceSlug]/(projects)/notifications/page.tsx b/web/app/(all)/[workspaceSlug]/(projects)/notifications/page.tsx
index 8afe768d8..415ea8fbf 100644
--- a/web/app/(all)/[workspaceSlug]/(projects)/notifications/page.tsx
+++ b/web/app/(all)/[workspaceSlug]/(projects)/notifications/page.tsx
@@ -1,22 +1,14 @@
"use client";
-import { useCallback, useEffect } from "react";
import { observer } from "mobx-react";
import { useParams } from "next/navigation";
-import useSWR from "swr";
// plane imports
-import { ENotificationLoader, ENotificationQueryParamType } from "@plane/constants";
import { useTranslation } from "@plane/i18n";
// components
-import { LogoSpinner } from "@/components/common";
import { PageHead } from "@/components/core";
-import { SimpleEmptyState } from "@/components/empty-state";
-import { InboxContentRoot } from "@/components/inbox";
-import { IssuePeekOverview } from "@/components/issues";
+import { NotificationsRoot } from "@/components/workspace-notifications";
// hooks
-import { useIssueDetail, useUserPermissions, useWorkspace, useWorkspaceNotifications } from "@/hooks/store";
-import { useResolvedAssetPath } from "@/hooks/use-resolved-asset-path";
-import { useWorkspaceIssueProperties } from "@/hooks/use-workspace-issue-properties";
+import { useWorkspace } from "@/hooks/store";
const WorkspaceDashboardPage = observer(() => {
const { workspaceSlug } = useParams();
@@ -24,98 +16,15 @@ const WorkspaceDashboardPage = observer(() => {
const { t } = useTranslation();
// hooks
const { currentWorkspace } = useWorkspace();
- const {
- currentSelectedNotificationId,
- setCurrentSelectedNotificationId,
- notificationLiteByNotificationId,
- notificationIdsByWorkspaceId,
- getNotifications,
- } = useWorkspaceNotifications();
- const { fetchUserProjectInfo } = useUserPermissions();
- const { setPeekIssue } = useIssueDetail();
// derived values
const pageTitle = currentWorkspace?.name
? t("notification.page_label", { workspace: currentWorkspace?.name })
: undefined;
- const { workspace_slug, project_id, issue_id, is_inbox_issue } =
- notificationLiteByNotificationId(currentSelectedNotificationId);
- const resolvedPath = useResolvedAssetPath({ basePath: "/empty-state/intake/issue-detail" });
-
- // fetching workspace work item properties
- useWorkspaceIssueProperties(workspaceSlug);
-
- // fetch workspace notifications
- const notificationMutation =
- currentWorkspace && notificationIdsByWorkspaceId(currentWorkspace.id)
- ? ENotificationLoader.MUTATION_LOADER
- : ENotificationLoader.INIT_LOADER;
- const notificationLoader =
- currentWorkspace && notificationIdsByWorkspaceId(currentWorkspace.id)
- ? ENotificationQueryParamType.CURRENT
- : ENotificationQueryParamType.INIT;
- useSWR(
- currentWorkspace?.slug ? `WORKSPACE_NOTIFICATION` : null,
- currentWorkspace?.slug
- ? () => getNotifications(currentWorkspace?.slug, notificationMutation, notificationLoader)
- : null
- );
-
- // fetching user project member info
- const { isLoading: projectMemberInfoLoader } = useSWR(
- workspace_slug && project_id && is_inbox_issue
- ? `PROJECT_MEMBER_PERMISSION_INFO_${workspace_slug}_${project_id}`
- : null,
- workspace_slug && project_id && is_inbox_issue ? () => fetchUserProjectInfo(workspace_slug, project_id) : null
- );
-
- const embedRemoveCurrentNotification = useCallback(
- () => setCurrentSelectedNotificationId(undefined),
- [setCurrentSelectedNotificationId]
- );
-
- // clearing up the selected notifications when unmounting the page
- useEffect(
- () => () => {
- setCurrentSelectedNotificationId(undefined);
- setPeekIssue(undefined);
- },
- [setCurrentSelectedNotificationId, setPeekIssue]
- );
return (
<>