fix: replacing onclick redirections with link tag. (#3263)

* fix: adding links to dashboard summary items

* fix: adding links to workspace sidebar dropdown

* fix: adding links to the sidebar
This commit is contained in:
sriram veeraghanta 2023-12-28 14:29:20 +05:30 committed by GitHub
parent ff8008cbed
commit 685e62a72f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 102 deletions

View File

@ -253,32 +253,31 @@ export const ProjectSidebarListItem: React.FC<Props> = observer((props) => {
)} )}
{project.archive_in > 0 && ( {project.archive_in > 0 && (
<CustomMenu.MenuItem <CustomMenu.MenuItem>
onClick={() => router.push(`/${workspaceSlug}/projects/${project?.id}/archived-issues/`)} <Link href={`/${workspaceSlug}/projects/${project?.id}/archived-issues/`}>
>
<div className="flex items-center justify-start gap-2"> <div className="flex items-center justify-start gap-2">
<ArchiveIcon className="h-3.5 w-3.5 stroke-[1.5]" /> <ArchiveIcon className="h-3.5 w-3.5 stroke-[1.5]" />
<span>Archived Issues</span> <span>Archived Issues</span>
</div> </div>
</Link>
</CustomMenu.MenuItem> </CustomMenu.MenuItem>
)} )}
<CustomMenu.MenuItem <CustomMenu.MenuItem>
onClick={() => router.push(`/${workspaceSlug}/projects/${project?.id}/draft-issues`)} <Link href={`/${workspaceSlug}/projects/${project?.id}/draft-issues/`}>
>
<div className="flex items-center justify-start gap-2"> <div className="flex items-center justify-start gap-2">
<PenSquare className="h-3.5 w-3.5 stroke-[1.5] text-custom-text-300" /> <PenSquare className="h-3.5 w-3.5 stroke-[1.5] text-custom-text-300" />
<span>Draft Issues</span> <span>Draft Issues</span>
</div> </div>
</Link>
</CustomMenu.MenuItem> </CustomMenu.MenuItem>
<CustomMenu.MenuItem <CustomMenu.MenuItem>
onClick={() => router.push(`/${workspaceSlug}/projects/${project?.id}/settings`)} <Link href={`/${workspaceSlug}/projects/${project?.id}/settings`}>
>
<div className="flex items-center justify-start gap-2"> <div className="flex items-center justify-start gap-2">
<Settings className="h-3.5 w-3.5 stroke-[1.5]" /> <Settings className="h-3.5 w-3.5 stroke-[1.5]" />
<span>Settings</span> <span>Settings</span>
</div> </div>
</Link>
</CustomMenu.MenuItem> </CustomMenu.MenuItem>
{/* leave project */} {/* leave project */}
{isViewerOrGuest && ( {isViewerOrGuest && (
<CustomMenu.MenuItem onClick={handleLeaveProject}> <CustomMenu.MenuItem onClick={handleLeaveProject}>

View File

@ -7,6 +7,7 @@ import { Info } from "lucide-react";
// types // types
import { IUserWorkspaceDashboard } from "types"; import { IUserWorkspaceDashboard } from "types";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import Link from "next/link";
type Props = { type Props = {
data: IUserWorkspaceDashboard | undefined; data: IUserWorkspaceDashboard | undefined;
@ -19,61 +20,40 @@ export const IssuesStats: React.FC<Props> = ({ data }) => {
<div className="grid grid-cols-1 rounded-[10px] border border-custom-border-200 bg-custom-background-100 lg:grid-cols-3"> <div className="grid grid-cols-1 rounded-[10px] border border-custom-border-200 bg-custom-background-100 lg:grid-cols-3">
<div className="grid grid-cols-1 divide-y divide-custom-border-200 border-b border-custom-border-200 lg:border-b-0 lg:border-r"> <div className="grid grid-cols-1 divide-y divide-custom-border-200 border-b border-custom-border-200 lg:border-b-0 lg:border-r">
<div className="flex"> <div className="flex">
<div className="basis-1/2 p-4"> <Link className="basis-1/2 p-4" href={`/${workspaceSlug}/workspace-views/assigned`}>
<div>
<h4 className="text-sm">Issues assigned to you</h4> <h4 className="text-sm">Issues assigned to you</h4>
<h5 className="mt-2 text-2xl font-semibold"> <h5 className="mt-2 text-2xl font-semibold">
{data ? ( <div className="cursor-pointer">{data?.assigned_issues_count}</div>
<div </h5>
className="cursor-pointer" </div>
onClick={() => router.push(`/${workspaceSlug}/workspace-views/assigned`)} </Link>
<Link
className="basis-1/2 border-l border-custom-border-200 p-4"
href={`/${workspaceSlug}/workspace-views/all-issues`}
> >
{data.assigned_issues_count} <div>
</div>
) : (
<Loader>
<Loader.Item height="25px" width="50%" />
</Loader>
)}
</h5>
</div>
<div className="basis-1/2 border-l border-custom-border-200 p-4">
<h4 className="text-sm">Pending issues</h4> <h4 className="text-sm">Pending issues</h4>
<h5 className="mt-2 text-2xl font-semibold"> <h5 className="mt-2 text-2xl font-semibold">{data?.pending_issues_count}</h5>
{data ? (
data.pending_issues_count
) : (
<Loader>
<Loader.Item height="25px" width="50%" />
</Loader>
)}
</h5>
</div> </div>
</Link>
</div> </div>
<div className="flex"> <div className="flex">
<div className="basis-1/2 p-4"> <Link className="basis-1/2 p-4" href={`/${workspaceSlug}/workspace-views/all-issues`}>
<div>
<h4 className="text-sm">Completed issues</h4> <h4 className="text-sm">Completed issues</h4>
<h5 className="mt-2 text-2xl font-semibold"> <h5 className="mt-2 text-2xl font-semibold">{data?.completed_issues_count}</h5>
{data ? (
data.completed_issues_count
) : (
<Loader>
<Loader.Item height="25px" width="50%" />
</Loader>
)}
</h5>
</div> </div>
<div className="basis-1/2 border-l border-custom-border-200 p-4"> </Link>
<Link
className="basis-1/2 border-l border-custom-border-200 p-4"
href={`/${workspaceSlug}/workspace-views/all-issues`}
>
<div>
<h4 className="text-sm">Issues due by this week</h4> <h4 className="text-sm">Issues due by this week</h4>
<h5 className="mt-2 text-2xl font-semibold"> <h5 className="mt-2 text-2xl font-semibold">{data?.issues_due_week_count}</h5>
{data ? (
data.issues_due_week_count
) : (
<Loader>
<Loader.Item height="25px" width="50%" />
</Loader>
)}
</h5>
</div> </div>
</Link>
</div> </div>
</div> </div>
<div className="p-4 lg:col-span-2"> <div className="p-4 lg:col-span-2">

View File

@ -16,7 +16,7 @@ import { Avatar, Loader } from "@plane/ui";
import { IWorkspace } from "types"; import { IWorkspace } from "types";
// Static Data // Static Data
const userLinks = (workspaceSlug: string, userId: string) => [ const WORKSPACE_DROPDOWN_ITEMS = (workspaceSlug: string, userId: string) => [
{ {
name: "Workspace Settings", name: "Workspace Settings",
href: `/${workspaceSlug}/settings`, href: `/${workspaceSlug}/settings`,
@ -155,8 +155,8 @@ export const WorkspaceSidebarDropdown = observer(() => {
workspaces.map((workspace: IWorkspace) => ( workspaces.map((workspace: IWorkspace) => (
<Menu.Item key={workspace.id}> <Menu.Item key={workspace.id}>
{() => ( {() => (
<button <Link
type="button" href={`/${workspace.slug}`}
onClick={() => handleWorkspaceNavigation(workspace)} onClick={() => handleWorkspaceNavigation(workspace)}
className="flex w-full items-center justify-between gap-1 rounded-md p-1 text-sm text-custom-sidebar-text-100 hover:bg-custom-sidebar-background-80" className="flex w-full items-center justify-between gap-1 rounded-md p-1 text-sm text-custom-sidebar-text-100 hover:bg-custom-sidebar-background-80"
> >
@ -190,7 +190,7 @@ export const WorkspaceSidebarDropdown = observer(() => {
<Check className="h-3 w-3.5 text-custom-sidebar-text-100" /> <Check className="h-3 w-3.5 text-custom-sidebar-text-100" />
</span> </span>
)} )}
</button> </Link>
)} )}
</Menu.Item> </Menu.Item>
)) ))
@ -198,17 +198,19 @@ export const WorkspaceSidebarDropdown = observer(() => {
<p>No workspace found!</p> <p>No workspace found!</p>
)} )}
<div className="sticky bottom-0 z-10 h-full w-full bg-custom-background-100"> <div className="sticky bottom-0 z-10 h-full w-full bg-custom-background-100">
<Menu.Item <Menu.Item>
as="button" {() => (
type="button" <Link
href="/create-workspace"
className="flex w-full items-center gap-2 px-2 py-1 text-sm text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80"
onClick={() => { onClick={() => {
setTrackElement("APP_SIEDEBAR_WORKSPACE_DROPDOWN"); setTrackElement("APP_SIEDEBAR_WORKSPACE_DROPDOWN");
router.push("/create-workspace");
}} }}
className="flex w-full items-center gap-2 px-2 py-1 text-sm text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80"
> >
<Plus className="h-4 w-4" /> <Plus className="h-4 w-4" />
Create Workspace Create Workspace
</Link>
)}
</Menu.Item> </Menu.Item>
</div> </div>
</div> </div>
@ -222,18 +224,20 @@ export const WorkspaceSidebarDropdown = observer(() => {
)} )}
</div> </div>
<div className="flex w-full flex-col items-start justify-start gap-2 border-t border-custom-sidebar-border-200 px-3 py-2 text-sm"> <div className="flex w-full flex-col items-start justify-start gap-2 border-t border-custom-sidebar-border-200 px-3 py-2 text-sm">
{userLinks(workspaceSlug?.toString() ?? "", currentUser?.id ?? "").map((link, index) => ( {WORKSPACE_DROPDOWN_ITEMS(workspaceSlug?.toString() ?? "", currentUser?.id ?? "").map(
<Menu.Item (link, index) => (
key={index} <Menu.Item key={index} as="div" className="flex w-full">
as="div" {() => (
onClick={() => { <Link
router.push(link.href);
}}
className="flex w-full cursor-pointer items-center justify-start rounded px-2 py-1 text-sm text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80" className="flex w-full cursor-pointer items-center justify-start rounded px-2 py-1 text-sm text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80"
href={link.href}
> >
{link.name} {link.name}
</Link>
)}
</Menu.Item> </Menu.Item>
))} )
)}
</div> </div>
<div className="w-full border-t border-t-custom-sidebar-border-100 px-3 py-2"> <div className="w-full border-t border-t-custom-sidebar-border-100 px-3 py-2">
<Menu.Item <Menu.Item