diff --git a/web/ee/components/common/activity/actions/helpers/activity-block.tsx b/web/ee/components/common/activity/actions/helpers/activity-block.tsx deleted file mode 100644 index 84f2dc9a47..0000000000 --- a/web/ee/components/common/activity/actions/helpers/activity-block.tsx +++ /dev/null @@ -1,51 +0,0 @@ -"use client"; - -import { FC, ReactNode } from "react"; -import { Network } from "lucide-react"; -// hooks -import { Tooltip } from "@plane/ui"; -import { renderFormattedTime, renderFormattedDate, calculateTimeAgo } from "@/helpers/date-time.helper"; -import { usePlatformOS } from "@/hooks/use-platform-os"; -import { TProjectActivity } from "@/plane-web/types"; -import { User } from "./user"; - -type TActivityBlockComponent = { - icon?: ReactNode; - activity: TProjectActivity; - ends: "top" | "bottom" | undefined; - children: ReactNode; - customUserName?: string; -}; - -export const ActivityBlockComponent: FC = (props) => { - const { icon, activity, ends, children, customUserName } = props; - // hooks - const { isMobile } = usePlatformOS(); - - if (!activity) return <>; - return ( -
-
-
- {icon ? icon : } -
-
- {children} -
- - - {calculateTimeAgo(activity.created_at)} - - -
-
-
- ); -}; diff --git a/web/ee/components/common/activity/actions/helpers/user.tsx b/web/ee/components/common/activity/actions/helpers/user.tsx deleted file mode 100644 index 0229d80e85..0000000000 --- a/web/ee/components/common/activity/actions/helpers/user.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { FC } from "react"; -import Link from "next/link"; -import { TProjectActivity } from "@/plane-web/types"; - -type TUser = { - activity: TProjectActivity; - customUserName?: string; -}; - -export const User: FC = (props) => { - const { activity, customUserName } = props; - - return ( - <> - {customUserName || activity.actor_detail?.display_name.includes("-intake") ? ( - {customUserName || "Plane"} - ) : ( - - {activity.actor_detail?.display_name} - - )} - - ); -}; diff --git a/web/ee/components/project-overview/sidebar/project-activity/activity-comment-root.tsx b/web/ee/components/project-overview/sidebar/project-activity/activity-comment-root.tsx deleted file mode 100644 index a496135bca..0000000000 --- a/web/ee/components/project-overview/sidebar/project-activity/activity-comment-root.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { FC } from "react"; -import { observer } from "mobx-react"; -// components -import useSWR from "swr"; -import { Loader } from "@plane/ui"; -import { ActivityItem } from "@/plane-web/components/common/activity/actions/helpers/activity-item"; -import { ProjectActivityService } from "@/plane-web/services"; -import { iconsMap, messages } from "./helper"; - -const projectActivityService = new ProjectActivityService(); - -type TProjectActivityCommentRoot = { - workspaceSlug: string; - projectId: string; -}; - -export const ProjectActivityCommentRoot: FC = observer((props) => { - const { workspaceSlug, projectId } = props; - - // api calls - const { data: activity, isLoading } = useSWR( - projectId && workspaceSlug ? `PROJECT_ACTIVITY_${projectId}` : null, - projectId && workspaceSlug ? () => projectActivityService.getProjectActivities(workspaceSlug, projectId) : null, - { - revalidateIfStale: false, - revalidateOnFocus: false, - revalidateOnReconnect: false, - } - ); - - return isLoading ? ( - - - - - - ) : ( -
- {activity && - activity.map((activityComment, index) => ( - - ))} -
- ); -}); diff --git a/web/ee/components/project-overview/sidebar/project-activity/helper.tsx b/web/ee/components/project-overview/sidebar/project-activity/helper.tsx deleted file mode 100644 index dda68477dd..0000000000 --- a/web/ee/components/project-overview/sidebar/project-activity/helper.tsx +++ /dev/null @@ -1,279 +0,0 @@ -import { ReactNode } from "react"; -import { - Signal, - RotateCcw, - Network, - Link as LinkIcon, - Calendar, - Tag, - Inbox, - AlignLeft, - Users, - Paperclip, - Type, - Triangle, - FileText, - Globe, - Hash, - Clock, - Bell, - LayoutGrid, - GitBranch, - Timer, - ListTodo, - Layers, -} from "lucide-react"; - -// components -import { ArchiveIcon, DoubleCircleIcon, ContrastIcon, DiceIcon, Intake } from "@plane/ui"; -import { TProjectActivity } from "@/plane-web/types"; - -type ActivityIconMap = { - [key: string]: ReactNode; -}; -export const iconsMap: ActivityIconMap = { - priority: , - archived_at: , - restored: , - link: , - start_date: , - target_date: , - label: , - inbox: , - description: , - assignee: , - attachment: , - name: , - state: , - estimate: , - cycle: , - module: , - page: , - network: , - identifier: , - timezone: , - is_project_updates_enabled: , - is_epic_enabled: , - is_workflow_enabled: , - is_time_tracking_enabled: , - is_issue_type_enabled: , - default: , - module_view: , - cycle_view: , - issue_views_view: , - page_view: , - intake_view: , -}; - -export const messages = (activity: TProjectActivity): { message: string | ReactNode; customUserName?: string } => { - const activityType = activity.field; - const newValue = activity.new_value; - const oldValue = activity.old_value; - const verb = activity.verb; - - const getBooleanActionText = (value: string) => { - if (value === "true") return "enabled"; - if (value === "false") return "disabled"; - return verb; - }; - - switch (activityType) { - case "priority": - return { - message: ( - <> - set the priority to {newValue || "none"} - - ), - }; - case "archived_at": - return { - message: newValue === "restore" ? "restored the project" : "archived the project", - customUserName: newValue === "archive" ? "Plane" : undefined, - }; - case "name": - return { - message: ( - <> - renamed the project to {newValue} - - ), - }; - case "description": - return { - message: newValue ? "updated the project description" : "removed the project description", - }; - case "start_date": - return { - message: ( - <> - {newValue ? ( - <> - set the start date to {newValue} - - ) : ( - "removed the start date" - )} - - ), - }; - case "target_date": - return { - message: ( - <> - {newValue ? ( - <> - set the target date to {newValue} - - ) : ( - "removed the target date" - )} - - ), - }; - case "state": - return { - message: ( - <> - set the state to {newValue || "none"} - - ), - }; - case "estimate": - return { - message: ( - <> - {newValue ? ( - <> - set the estimate point to {newValue} - - ) : ( - <> - removed the estimate point - {oldValue && ( - <> - {" "} - {oldValue} - - )} - - )} - - ), - }; - case "cycles": - return { - message: ( - <> - - {verb} this project {verb === "removed" ? "from" : "to"} the cycle{" "} - - {verb !== "removed" ? ( - - {activity.new_value} - - ) : ( - {activity.old_value || "Unknown cycle"} - )} - - ), - }; - case "modules": - return { - message: ( - <> - - {verb} this project {verb === "removed" ? "from" : "to"} the module{" "} - - - {verb === "removed" ? oldValue : newValue || "Unknown module"} - - - ), - }; - case "labels": - return { - message: ( - <> - {verb} the label{" "} - {newValue || oldValue || "Untitled label"} - - ), - }; - case "inbox": - return { - message: <>{newValue ? "enabled" : "disabled"} inbox, - }; - case "page": - return { - message: ( - <> - {newValue ? "created" : "removed"} the project page{" "} - {newValue || oldValue || "Untitled page"} - - ), - }; - case "network": - return { - message: <>{newValue ? "enabled" : "disabled"} network access, - }; - case "identifier": - return { - message: ( - <> - updated project identifier to {newValue || "none"} - - ), - }; - case "timezone": - return { - message: ( - <> - changed project timezone to{" "} - {newValue || "default"} - - ), - }; - case "module_view": - case "cycle_view": - case "issue_views_view": - case "page_view": - case "intake_view": - return { - message: ( - <> - {getBooleanActionText(newValue)} {activityType.replace(/_view$/, "").replace(/_/g, " ")} view - - ), - }; - case "is_project_updates_enabled": - return { - message: <>{getBooleanActionText(newValue)} project updates, - }; - case "is_epic_enabled": - return { - message: <>{getBooleanActionText(newValue)} epics, - }; - case "is_workflow_enabled": - return { - message: <>{getBooleanActionText(newValue)} custom workflow, - }; - case "is_time_tracking_enabled": - return { - message: <>{getBooleanActionText(newValue)} time tracking, - }; - case "is_issue_type_enabled": - return { - message: <>{getBooleanActionText(newValue)} issue types, - }; - default: - return { - message: `${verb} ${activityType.replace(/_/g, " ")} `, - }; - } -}; diff --git a/web/ee/components/project-overview/sidebar/project-activity/index.ts b/web/ee/components/project-overview/sidebar/project-activity/index.ts index 638add3142..1efe34c51e 100644 --- a/web/ee/components/project-overview/sidebar/project-activity/index.ts +++ b/web/ee/components/project-overview/sidebar/project-activity/index.ts @@ -1,3 +1 @@ export * from "./root"; - -export * from "./activity-comment-root"; diff --git a/web/ee/components/project-overview/sidebar/project-activity/root.tsx b/web/ee/components/project-overview/sidebar/project-activity/root.tsx index ce471e06a2..171124b77c 100644 --- a/web/ee/components/project-overview/sidebar/project-activity/root.tsx +++ b/web/ee/components/project-overview/sidebar/project-activity/root.tsx @@ -1,8 +1,11 @@ "use client"; - import { FC } from "react"; import { observer } from "mobx-react"; -import { ProjectActivityCommentRoot } from "./activity-comment-root"; +// components +import useSWR from "swr"; +import { Loader } from "@plane/ui"; +import { ProjectActivityService } from "@/plane-web/services"; +import { ActivityItem } from "@/components/common"; // components type TProjectActivity = { @@ -10,8 +13,20 @@ type TProjectActivity = { projectId: string; }; +const projectActivityService = new ProjectActivityService(); + export const ProjectActivity: FC = observer((props) => { const { workspaceSlug, projectId } = props; + // api calls + const { data: activity, isLoading } = useSWR( + projectId && workspaceSlug ? `PROJECT_ACTIVITY_${projectId}` : null, + projectId && workspaceSlug ? () => projectActivityService.getProjectActivities(workspaceSlug, projectId) : null, + { + revalidateIfStale: false, + revalidateOnFocus: false, + revalidateOnReconnect: false, + } + ); return (
@@ -19,7 +34,24 @@ export const ProjectActivity: FC = observer((props) => {
- + {isLoading ? ( + + + + + + ) : ( +
+ {activity && + activity.map((activityComment, index) => ( + + ))} +
+ )}