From f203d0154fca93f5839f77b8dd05aa63eb8576f0 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Tue, 1 Aug 2023 17:53:46 +0530 Subject: [PATCH] fix: profile activity workspace slug --- apps/app/components/core/feeds.tsx | 441 +++++++++++++++-------------- 1 file changed, 226 insertions(+), 215 deletions(-) diff --git a/apps/app/components/core/feeds.tsx b/apps/app/components/core/feeds.tsx index 6b6576b3658..2924ec45685 100644 --- a/apps/app/components/core/feeds.tsx +++ b/apps/app/components/core/feeds.tsx @@ -1,5 +1,7 @@ import React from "react"; +import { useRouter } from "next/router"; + import Link from "next/link"; // icons @@ -99,233 +101,242 @@ const activityDetails: { }, }; -export const Feeds: React.FC = ({ activities }) => ( -
-
    - {activities.map((activity: any, activityIdx: number) => { - // determines what type of action is performed - let action = activityDetails[activity.field as keyof typeof activityDetails]?.message; - if (activity.field === "labels") { - action = activity.new_value !== "" ? "added a new label" : "removed the label"; - } else if (activity.field === "blocking") { - action = - activity.new_value !== "" - ? "marked this issue is blocking" - : "removed the issue from blocking"; - } else if (activity.field === "blocks") { - action = - activity.new_value !== "" ? "marked this issue being blocked by" : "removed blocker"; - } else if (activity.field === "target_date") { - action = - activity.new_value && activity.new_value !== "" - ? "set the due date to" - : "removed the due date"; - } else if (activity.field === "parent") { - action = - activity.new_value && activity.new_value !== "" - ? "set the parent to" - : "removed the parent"; - } else if (activity.field === "priority") { - action = - activity.new_value && activity.new_value !== "" - ? "set the priority to" - : "removed the priority"; - } else if (activity.field === "description") { - action = "updated the"; - } else if (activity.field === "attachment") { - action = `${activity.verb} the`; - } else if (activity.field === "link") { - action = `${activity.verb} the`; - } else if (activity.field === "archived_at") { - action = - activity.new_value && activity.new_value === "restore" - ? "restored the issue" - : "archived the issue"; - } - // for values that are after the action clause - let value: any = activity.new_value ? activity.new_value : activity.old_value; - if ( - activity.verb === "created" && - activity.field !== "cycles" && - activity.field !== "modules" && - activity.field !== "attachment" && - activity.field !== "link" && - activity.field !== "estimate" - ) { - const { workspace_detail, project, issue } = activity; - value = ( - - created{" "} - - - this issue. - - - - ); - } else if (activity.field === "state") { - value = activity.new_value ? addSpaceIfCamelCase(activity.new_value) : "None"; - } else if (activity.field === "labels") { - let name; - let id = "#000000"; - if (activity.new_value !== "") { - name = activity.new_value; - id = activity.new_identifier ? activity.new_identifier : id; - } else { - name = activity.old_value; - id = activity.old_identifier ? activity.old_identifier : id; +export const Feeds: React.FC = ({ activities }) => { + const router = useRouter(); + const { workspaceSlug } = router.query; + + return ( +
    +
      + {activities.map((activity: any, activityIdx: number) => { + // determines what type of action is performed + let action = activityDetails[activity.field as keyof typeof activityDetails]?.message; + if (activity.field === "labels") { + action = activity.new_value !== "" ? "added a new label" : "removed the label"; + } else if (activity.field === "blocking") { + action = + activity.new_value !== "" + ? "marked this issue is blocking" + : "removed the issue from blocking"; + } else if (activity.field === "blocks") { + action = + activity.new_value !== "" ? "marked this issue being blocked by" : "removed blocker"; + } else if (activity.field === "target_date") { + action = + activity.new_value && activity.new_value !== "" + ? "set the due date to" + : "removed the due date"; + } else if (activity.field === "parent") { + action = + activity.new_value && activity.new_value !== "" + ? "set the parent to" + : "removed the parent"; + } else if (activity.field === "priority") { + action = + activity.new_value && activity.new_value !== "" + ? "set the priority to" + : "removed the priority"; + } else if (activity.field === "description") { + action = "updated the"; + } else if (activity.field === "attachment") { + action = `${activity.verb} the`; + } else if (activity.field === "link") { + action = `${activity.verb} the`; + } else if (activity.field === "archived_at") { + action = + activity.new_value && activity.new_value === "restore" + ? "restored the issue" + : "archived the issue"; } + // for values that are after the action clause + let value: any = activity.new_value ? activity.new_value : activity.old_value; + if ( + activity.verb === "created" && + activity.field !== "cycles" && + activity.field !== "modules" && + activity.field !== "attachment" && + activity.field !== "link" && + activity.field !== "estimate" + ) { + const { project, issue } = activity; + value = ( + + created{" "} + + + this issue. + + + + ); + } else if (activity.field === "state") { + value = activity.new_value ? addSpaceIfCamelCase(activity.new_value) : "None"; + } else if (activity.field === "labels") { + let name; + let id = "#000000"; + if (activity.new_value !== "") { + name = activity.new_value; + id = activity.new_identifier ? activity.new_identifier : id; + } else { + name = activity.old_value; + id = activity.old_identifier ? activity.old_identifier : id; + } - value = name; - } else if (activity.field === "assignees") { - value = activity.new_value; - } else if (activity.field === "target_date") { - const date = - activity.new_value && activity.new_value !== "" - ? activity.new_value - : activity.old_value; - value = renderShortDateWithYearFormat(date as string); - } else if (activity.field === "description") { - value = "description"; - } else if (activity.field === "attachment") { - value = "attachment"; - } else if (activity.field === "link") { - value = "link"; - } else if (activity.field === "estimate_point") { - value = activity.new_value - ? activity.new_value + ` Point${parseInt(activity.new_value ?? "", 10) > 1 ? "s" : ""}` - : "None"; - } + value = name; + } else if (activity.field === "assignees") { + value = activity.new_value; + } else if (activity.field === "target_date") { + const date = + activity.new_value && activity.new_value !== "" + ? activity.new_value + : activity.old_value; + value = renderShortDateWithYearFormat(date as string); + } else if (activity.field === "description") { + value = "description"; + } else if (activity.field === "attachment") { + value = "attachment"; + } else if (activity.field === "link") { + value = "link"; + } else if (activity.field === "estimate_point") { + value = activity.new_value + ? activity.new_value + + ` Point${parseInt(activity.new_value ?? "", 10) > 1 ? "s" : ""}` + : "None"; + } - if (activity.field === "comment") { - return ( -
      -
      -
      - {activity.field ? ( - activity.new_value === "restore" ? ( - + if (activity.field === "comment") { + return ( +
      +
      +
      + {activity.field ? ( + activity.new_value === "restore" ? ( + + ) : ( + activityDetails[activity.field as keyof typeof activityDetails]?.icon + ) + ) : activity.actor_detail.avatar && activity.actor_detail.avatar !== "" ? ( + {activity.actor_detail.first_name} ) : ( - activityDetails[activity.field as keyof typeof activityDetails]?.icon - ) - ) : activity.actor_detail.avatar && activity.actor_detail.avatar !== "" ? ( - {activity.actor_detail.first_name} - ) : ( -
      - {activity.actor_detail.first_name.charAt(0)} -
      - )} +
      + {activity.actor_detail.first_name.charAt(0)} +
      + )} - - -
      -
      -
      -
      - {activity.actor_detail.first_name} - {activity.actor_detail.is_bot ? "Bot" : " " + activity.actor_detail.last_name} -
      -

      - Commented {timeAgo(activity.created_at)} -

      + +
      -
      - +
      +
      +
      + {activity.actor_detail.first_name} + {activity.actor_detail.is_bot + ? "Bot" + : " " + activity.actor_detail.last_name} +
      +

      + Commented {timeAgo(activity.created_at)} +

      +
      +
      + +
      -
      - ); - } + ); + } - if ("field" in activity && activity.field !== "updated_by") { - return ( -
    • -
      - {activities.length > 1 && activityIdx !== activities.length - 1 ? ( -
    • +
      + {activities.length > 1 && activityIdx !== activities.length - 1 ? ( +
      -
    • - - ); - } - })} -
    -
    -); + + ); + } + })} +
+
+ ); +};