fix: profile activity workspace slug (#1752)

This commit is contained in:
Aaryan Khandelwal 2023-08-01 18:38:33 +05:30 committed by GitHub
parent 0e0e09c4fd
commit d22e4b8212
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,7 @@
import React from "react"; import React from "react";
import { useRouter } from "next/router";
import Link from "next/link"; import Link from "next/link";
// icons // icons
@ -99,233 +101,242 @@ const activityDetails: {
}, },
}; };
export const Feeds: React.FC<any> = ({ activities }) => ( export const Feeds: React.FC<any> = ({ activities }) => {
<div> const router = useRouter();
<ul role="list" className="-mb-4"> const { workspaceSlug } = router.query;
{activities.map((activity: any, activityIdx: number) => {
// determines what type of action is performed return (
let action = activityDetails[activity.field as keyof typeof activityDetails]?.message; <div>
if (activity.field === "labels") { <ul role="list" className="-mb-4">
action = activity.new_value !== "" ? "added a new label" : "removed the label"; {activities.map((activity: any, activityIdx: number) => {
} else if (activity.field === "blocking") { // determines what type of action is performed
action = let action = activityDetails[activity.field as keyof typeof activityDetails]?.message;
activity.new_value !== "" if (activity.field === "labels") {
? "marked this issue is blocking" action = activity.new_value !== "" ? "added a new label" : "removed the label";
: "removed the issue from blocking"; } else if (activity.field === "blocking") {
} else if (activity.field === "blocks") { action =
action = activity.new_value !== ""
activity.new_value !== "" ? "marked this issue being blocked by" : "removed blocker"; ? "marked this issue is blocking"
} else if (activity.field === "target_date") { : "removed the issue from blocking";
action = } else if (activity.field === "blocks") {
activity.new_value && activity.new_value !== "" action =
? "set the due date to" activity.new_value !== "" ? "marked this issue being blocked by" : "removed blocker";
: "removed the due date"; } else if (activity.field === "target_date") {
} else if (activity.field === "parent") { action =
action = activity.new_value && activity.new_value !== ""
activity.new_value && activity.new_value !== "" ? "set the due date to"
? "set the parent to" : "removed the due date";
: "removed the parent"; } else if (activity.field === "parent") {
} else if (activity.field === "priority") { action =
action = activity.new_value && activity.new_value !== ""
activity.new_value && activity.new_value !== "" ? "set the parent to"
? "set the priority to" : "removed the parent";
: "removed the priority"; } else if (activity.field === "priority") {
} else if (activity.field === "description") { action =
action = "updated the"; activity.new_value && activity.new_value !== ""
} else if (activity.field === "attachment") { ? "set the priority to"
action = `${activity.verb} the`; : "removed the priority";
} else if (activity.field === "link") { } else if (activity.field === "description") {
action = `${activity.verb} the`; action = "updated the";
} else if (activity.field === "archived_at") { } else if (activity.field === "attachment") {
action = action = `${activity.verb} the`;
activity.new_value && activity.new_value === "restore" } else if (activity.field === "link") {
? "restored the issue" action = `${activity.verb} the`;
: "archived the issue"; } else if (activity.field === "archived_at") {
} action =
// for values that are after the action clause activity.new_value && activity.new_value === "restore"
let value: any = activity.new_value ? activity.new_value : activity.old_value; ? "restored the issue"
if ( : "archived the issue";
activity.verb === "created" && }
activity.field !== "cycles" && // for values that are after the action clause
activity.field !== "modules" && let value: any = activity.new_value ? activity.new_value : activity.old_value;
activity.field !== "attachment" && if (
activity.field !== "link" && activity.verb === "created" &&
activity.field !== "estimate" activity.field !== "cycles" &&
) { activity.field !== "modules" &&
const { workspace_detail, project, issue } = activity; activity.field !== "attachment" &&
value = ( activity.field !== "link" &&
<span className="text-custom-text-200"> activity.field !== "estimate"
created{" "} ) {
<Link href={`/${workspace_detail.slug}/projects/${project}/issues/${issue}`}> const { project, issue } = activity;
<a className="inline-flex items-center hover:underline"> value = (
this issue. <ArrowTopRightOnSquareIcon className="ml-1 h-3.5 w-3.5" /> <span className="text-custom-text-200">
</a> created{" "}
</Link> <Link href={`/${workspaceSlug}/projects/${project}/issues/${issue}`}>
</span> <a className="inline-flex items-center hover:underline">
); this issue. <ArrowTopRightOnSquareIcon className="ml-1 h-3.5 w-3.5" />
} else if (activity.field === "state") { </a>
value = activity.new_value ? addSpaceIfCamelCase(activity.new_value) : "None"; </Link>
} else if (activity.field === "labels") { </span>
let name; );
let id = "#000000"; } else if (activity.field === "state") {
if (activity.new_value !== "") { value = activity.new_value ? addSpaceIfCamelCase(activity.new_value) : "None";
name = activity.new_value; } else if (activity.field === "labels") {
id = activity.new_identifier ? activity.new_identifier : id; let name;
} else { let id = "#000000";
name = activity.old_value; if (activity.new_value !== "") {
id = activity.old_identifier ? activity.old_identifier : id; 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; if (activity.field === "comment") {
} else if (activity.field === "assignees") { return (
value = activity.new_value; <div key={activity.id} className="mt-2">
} else if (activity.field === "target_date") { <div className="relative flex items-start space-x-3">
const date = <div className="relative px-1">
activity.new_value && activity.new_value !== "" {activity.field ? (
? activity.new_value activity.new_value === "restore" ? (
: activity.old_value; <Icon iconName="history" className="text-sm text-custom-text-200" />
value = renderShortDateWithYearFormat(date as string); ) : (
} else if (activity.field === "description") { activityDetails[activity.field as keyof typeof activityDetails]?.icon
value = "description"; )
} else if (activity.field === "attachment") { ) : activity.actor_detail.avatar && activity.actor_detail.avatar !== "" ? (
value = "attachment"; <img
} else if (activity.field === "link") { src={activity.actor_detail.avatar}
value = "link"; alt={activity.actor_detail.first_name}
} else if (activity.field === "estimate_point") { height={30}
value = activity.new_value width={30}
? activity.new_value + ` Point${parseInt(activity.new_value ?? "", 10) > 1 ? "s" : ""}` className="grid h-7 w-7 place-items-center rounded-full border-2 border-white bg-gray-500 text-white"
: "None"; />
}
if (activity.field === "comment") {
return (
<div key={activity.id} className="mt-2">
<div className="relative flex items-start space-x-3">
<div className="relative px-1">
{activity.field ? (
activity.new_value === "restore" ? (
<Icon iconName="history" className="text-sm text-custom-text-200" />
) : ( ) : (
activityDetails[activity.field as keyof typeof activityDetails]?.icon <div
) className={`grid h-7 w-7 place-items-center rounded-full border-2 border-white bg-gray-500 text-white`}
) : activity.actor_detail.avatar && activity.actor_detail.avatar !== "" ? ( >
<img {activity.actor_detail.first_name.charAt(0)}
src={activity.actor_detail.avatar} </div>
alt={activity.actor_detail.first_name} )}
height={30}
width={30}
className="grid h-7 w-7 place-items-center rounded-full border-2 border-white bg-gray-500 text-white"
/>
) : (
<div
className={`grid h-7 w-7 place-items-center rounded-full border-2 border-white bg-gray-500 text-white`}
>
{activity.actor_detail.first_name.charAt(0)}
</div>
)}
<span className="absolute -bottom-0.5 -right-1 rounded-tl bg-custom-background-80 px-0.5 py-px"> <span className="absolute -bottom-0.5 -right-1 rounded-tl bg-custom-background-80 px-0.5 py-px">
<ChatBubbleLeftEllipsisIcon <ChatBubbleLeftEllipsisIcon
className="h-3.5 w-3.5 text-custom-text-200" className="h-3.5 w-3.5 text-custom-text-200"
aria-hidden="true" aria-hidden="true"
/> />
</span> </span>
</div>
<div className="min-w-0 flex-1">
<div>
<div className="text-xs">
{activity.actor_detail.first_name}
{activity.actor_detail.is_bot ? "Bot" : " " + activity.actor_detail.last_name}
</div>
<p className="mt-0.5 text-xs text-custom-text-200">
Commented {timeAgo(activity.created_at)}
</p>
</div> </div>
<div className="issue-comments-section p-0"> <div className="min-w-0 flex-1">
<RemirrorRichTextEditor <div>
value={ <div className="text-xs">
activity.new_value && activity.new_value !== "" {activity.actor_detail.first_name}
? activity.new_value {activity.actor_detail.is_bot
: activity.old_value ? "Bot"
} : " " + activity.actor_detail.last_name}
editable={false} </div>
noBorder <p className="mt-0.5 text-xs text-custom-text-200">
customClassName="text-xs border border-custom-border-200 bg-custom-background-100" Commented {timeAgo(activity.created_at)}
/> </p>
</div>
<div className="issue-comments-section p-0">
<RemirrorRichTextEditor
value={
activity.new_value && activity.new_value !== ""
? activity.new_value
: activity.old_value
}
editable={false}
noBorder
customClassName="text-xs border border-custom-border-200 bg-custom-background-100"
/>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> );
); }
}
if ("field" in activity && activity.field !== "updated_by") { if ("field" in activity && activity.field !== "updated_by") {
return ( return (
<li key={activity.id}> <li key={activity.id}>
<div className="relative pb-1"> <div className="relative pb-1">
{activities.length > 1 && activityIdx !== activities.length - 1 ? ( {activities.length > 1 && activityIdx !== activities.length - 1 ? (
<span <span
className="absolute top-5 left-5 -ml-px h-full w-0.5 bg-custom-background-80" className="absolute top-5 left-5 -ml-px h-full w-0.5 bg-custom-background-80"
aria-hidden="true" aria-hidden="true"
/> />
) : null} ) : null}
<div className="relative flex items-start space-x-2"> <div className="relative flex items-start space-x-2">
<> <>
<div> <div>
<div className="relative px-1.5"> <div className="relative px-1.5">
<div className="mt-1.5"> <div className="mt-1.5">
<div className="ring-6 flex h-7 w-7 items-center justify-center rounded-full bg-custom-background-80 text-custom-text-200 ring-white"> <div className="ring-6 flex h-7 w-7 items-center justify-center rounded-full bg-custom-background-80 text-custom-text-200 ring-white">
{activity.field ? ( {activity.field ? (
activityDetails[activity.field as keyof typeof activityDetails]?.icon activityDetails[activity.field as keyof typeof activityDetails]
) : activity.actor_detail.avatar && ?.icon
activity.actor_detail.avatar !== "" ? ( ) : activity.actor_detail.avatar &&
<img activity.actor_detail.avatar !== "" ? (
src={activity.actor_detail.avatar} <img
alt={activity.actor_detail.first_name} src={activity.actor_detail.avatar}
height={24} alt={activity.actor_detail.first_name}
width={24} height={24}
className="rounded-full" width={24}
/> className="rounded-full"
) : ( />
<div ) : (
className={`grid h-7 w-7 place-items-center rounded-full border-2 border-white bg-gray-700 text-xs text-white`} <div
> className={`grid h-7 w-7 place-items-center rounded-full border-2 border-white bg-gray-700 text-xs text-white`}
{activity.actor_detail.first_name.charAt(0)} >
</div> {activity.actor_detail.first_name.charAt(0)}
)} </div>
)}
</div>
</div> </div>
</div> </div>
</div> </div>
</div> <div className="min-w-0 flex-1 py-3">
<div className="min-w-0 flex-1 py-3"> <div className="text-xs text-custom-text-200">
<div className="text-xs text-custom-text-200"> {activity.field === "archived_at" && activity.new_value !== "restore" ? (
{activity.field === "archived_at" && activity.new_value !== "restore" ? ( <span className="text-gray font-medium">Plane</span>
<span className="text-gray font-medium">Plane</span> ) : (
) : ( <span className="text-gray font-medium">
<span className="text-gray font-medium"> {activity.actor_detail.first_name}
{activity.actor_detail.first_name} {activity.actor_detail.is_bot
{activity.actor_detail.is_bot ? " Bot"
? " Bot" : " " + activity.actor_detail.last_name}
: " " + activity.actor_detail.last_name} </span>
</span> )}
)} <span> {action} </span>
<span> {action} </span> {activity.field !== "archived_at" && (
{activity.field !== "archived_at" && ( <span className="text-xs font-medium text-custom-text-100">
<span className="text-xs font-medium text-custom-text-100"> {" "}
{" "} {value}{" "}
{value}{" "} </span>
</span> )}
)} <span className="whitespace-nowrap">{timeAgo(activity.created_at)}</span>
<span className="whitespace-nowrap">{timeAgo(activity.created_at)}</span> </div>
</div> </div>
</div> </>
</> </div>
</div> </div>
</div> </li>
</li> );
); }
} })}
})} </ul>
</ul> </div>
</div> );
); };