chore: issue activity user redirection added (#1805)

* feat: issue activity user redirection added

* feat: analytics page user redirection
This commit is contained in:
Anmol Singh Bhatia 2023-08-11 15:48:52 +05:30 committed by GitHub
parent def10af1e2
commit 289e81d6eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 7 deletions

View File

@ -5,18 +5,23 @@ type Props = {
firstName: string;
lastName: string;
count: number;
id: string;
}[];
title: string;
workspaceSlug: string;
};
export const AnalyticsLeaderboard: React.FC<Props> = ({ users, title }) => (
export const AnalyticsLeaderboard: React.FC<Props> = ({ users, title, workspaceSlug }) => (
<div className="p-3 border border-custom-border-200 rounded-[10px]">
<h6 className="text-base font-medium">{title}</h6>
{users.length > 0 ? (
<div className="mt-3 space-y-3">
{users.map((user) => (
<div
<a
key={user.display_name ?? "None"}
href={`/${workspaceSlug}/profile/${user.id}`}
target="_blank"
rel="noopener noreferrer"
className="flex items-start justify-between gap-4 text-xs"
>
<div className="flex items-center gap-2">
@ -38,7 +43,7 @@ export const AnalyticsLeaderboard: React.FC<Props> = ({ users, title }) => (
</span>
</div>
<span className="flex-shrink-0">{user.count}</span>
</div>
</a>
))}
</div>
) : (

View File

@ -60,8 +60,10 @@ export const ScopeAndDemand: React.FC<Props> = ({ fullScreen = true }) => {
lastName: user?.created_by__last_name,
display_name: user?.created_by__display_name,
count: user?.count,
id: user?.created_by__id,
}))}
title="Most issues created"
workspaceSlug={workspaceSlug?.toString() ?? ""}
/>
<AnalyticsLeaderboard
users={defaultAnalytics.most_issue_closed_user?.map((user) => ({
@ -70,8 +72,10 @@ export const ScopeAndDemand: React.FC<Props> = ({ fullScreen = true }) => {
lastName: user?.assignees__last_name,
display_name: user?.assignees__display_name,
count: user?.count,
id: user?.assignees__id,
}))}
title="Most issues closed"
workspaceSlug={workspaceSlug?.toString() ?? ""}
/>
<div className={fullScreen ? "md:col-span-2" : ""}>
<AnalyticsYearWiseIssues defaultAnalytics={defaultAnalytics} />

View File

@ -35,6 +35,22 @@ const IssueLink = ({ activity }: { activity: IIssueActivity }) => {
);
};
const UserLink = ({ activity }: { activity: IIssueActivity }) => {
const router = useRouter();
const { workspaceSlug } = router.query;
return (
<a
href={`/${workspaceSlug}/profile/${activity.new_identifier ?? activity.old_identifier}`}
target="_blank"
rel="noopener noreferrer"
className="font-medium text-custom-text-100 inline-flex items-center hover:underline"
>
{activity.new_value && activity.new_value !== "" ? activity.new_value : activity.old_value}
</a>
);
};
const activityDetails: {
[key: string]: {
message: (activity: IIssueActivity, showIssue: boolean) => React.ReactNode;
@ -46,8 +62,7 @@ const activityDetails: {
if (activity.old_value === "")
return (
<>
added a new assignee{" "}
<span className="font-medium text-custom-text-100">{activity.new_value}</span>
added a new assignee <UserLink activity={activity} />
{showIssue && (
<>
{" "}
@ -60,8 +75,7 @@ const activityDetails: {
else
return (
<>
removed the assignee{" "}
<span className="font-medium text-custom-text-100">{activity.old_value}</span>
removed the assignee <UserLink activity={activity} />
{showIssue && (
<>
{" "}

View File

@ -69,6 +69,7 @@ export interface IDefaultAnalyticsUser {
assignees__first_name: string;
assignees__last_name: string;
assignees__display_name: string;
assignees__id: string;
count: number;
}
@ -80,6 +81,7 @@ export interface IDefaultAnalyticsResponse {
created_by__first_name: string;
created_by__last_name: string;
created_by__display_name: string;
created_by__id: string;
count: number;
}[];
open_estimate_sum: number;