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`}>
<h4 className="text-sm">Issues assigned to you</h4> <div>
<h5 className="mt-2 text-2xl font-semibold"> <h4 className="text-sm">Issues assigned to you</h4>
{data ? ( <h5 className="mt-2 text-2xl font-semibold">
<div <div className="cursor-pointer">{data?.assigned_issues_count}</div>
className="cursor-pointer" </h5>
onClick={() => router.push(`/${workspaceSlug}/workspace-views/assigned`)} </div>
> </Link>
{data.assigned_issues_count} <Link
</div> className="basis-1/2 border-l border-custom-border-200 p-4"
) : ( href={`/${workspaceSlug}/workspace-views/all-issues`}
<Loader> >
<Loader.Item height="25px" width="50%" /> <div>
</Loader> <h4 className="text-sm">Pending issues</h4>
)} <h5 className="mt-2 text-2xl font-semibold">{data?.pending_issues_count}</h5>
</h5> </div>
</div> </Link>
<div className="basis-1/2 border-l border-custom-border-200 p-4">
<h4 className="text-sm">Pending issues</h4>
<h5 className="mt-2 text-2xl font-semibold">
{data ? (
data.pending_issues_count
) : (
<Loader>
<Loader.Item height="25px" width="50%" />
</Loader>
)}
</h5>
</div>
</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`}>
<h4 className="text-sm">Completed issues</h4> <div>
<h5 className="mt-2 text-2xl font-semibold"> <h4 className="text-sm">Completed issues</h4>
{data ? ( <h5 className="mt-2 text-2xl font-semibold">{data?.completed_issues_count}</h5>
data.completed_issues_count </div>
) : ( </Link>
<Loader> <Link
<Loader.Item height="25px" width="50%" /> className="basis-1/2 border-l border-custom-border-200 p-4"
</Loader> href={`/${workspaceSlug}/workspace-views/all-issues`}
)} >
</h5> <div>
</div> <h4 className="text-sm">Issues due by this week</h4>
<div className="basis-1/2 border-l border-custom-border-200 p-4"> <h5 className="mt-2 text-2xl font-semibold">{data?.issues_due_week_count}</h5>
<h4 className="text-sm">Issues due by this week</h4> </div>
<h5 className="mt-2 text-2xl font-semibold"> </Link>
{data ? (
data.issues_due_week_count
) : (
<Loader>
<Loader.Item height="25px" width="50%" />
</Loader>
)}
</h5>
</div>
</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
onClick={() => { href="/create-workspace"
setTrackElement("APP_SIEDEBAR_WORKSPACE_DROPDOWN"); 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"
router.push("/create-workspace"); onClick={() => {
}} setTrackElement("APP_SIEDEBAR_WORKSPACE_DROPDOWN");
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"
}} href={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" >
> {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