diff --git a/space/app/[workspace_slug]/[project_id]/error.tsx b/space/app/[workspace_slug]/[project_id]/error.tsx deleted file mode 100644 index b666762d1..000000000 --- a/space/app/[workspace_slug]/[project_id]/error.tsx +++ /dev/null @@ -1,5 +0,0 @@ -"use client"; - -export default function ProjectError() { - return <>Project Error; -} diff --git a/space/app/[workspace_slug]/[project_id]/layout.tsx b/space/app/[workspace_slug]/[project_id]/layout.tsx index 37fc7c544..ad713db18 100644 --- a/space/app/[workspace_slug]/[project_id]/layout.tsx +++ b/space/app/[workspace_slug]/[project_id]/layout.tsx @@ -1,4 +1,5 @@ import Image from "next/image"; +import { notFound } from "next/navigation"; // components import IssueNavbar from "@/components/issues/navbar"; // services @@ -10,7 +11,11 @@ const projectService = new ProjectService(); export default async function ProjectLayout({ children, params }: { children: React.ReactNode; params: any }) { const { workspace_slug, project_id } = params; - const projectSettings = await projectService.getProjectSettings(workspace_slug, project_id); + const projectSettings = await projectService.getProjectSettings(workspace_slug, project_id).catch(() => null); + + if (!projectSettings) { + notFound(); + } return (
diff --git a/space/app/[workspace_slug]/[project_id]/not-found.tsx b/space/app/[workspace_slug]/[project_id]/not-found.tsx deleted file mode 100644 index 9da31ad5e..000000000 --- a/space/app/[workspace_slug]/[project_id]/not-found.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function ProjectSettingsNotFound() { - return <>Project Settings not found; -} diff --git a/space/app/[workspace_slug]/[project_id]/page.tsx b/space/app/[workspace_slug]/[project_id]/page.tsx index 25893ed86..e8491c917 100644 --- a/space/app/[workspace_slug]/[project_id]/page.tsx +++ b/space/app/[workspace_slug]/[project_id]/page.tsx @@ -1,7 +1,8 @@ +"use client"; // components import { ProjectDetailsView } from "@/components/views"; -export default async function WorkspaceProjectPage({ params }: { params: any }) { +export default function WorkspaceProjectPage({ params }: { params: any }) { const { workspace_slug, project_id, peekId } = params; return ; diff --git a/space/app/layout.tsx b/space/app/layout.tsx index 78b4a698b..cc9a94b15 100644 --- a/space/app/layout.tsx +++ b/space/app/layout.tsx @@ -1,8 +1,16 @@ import { Metadata } from "next"; // styles import "@/styles/globals.css"; +// components +import { InstanceNotReady, InstanceFailureView } from "@/components/instance"; // helpers import { ASSET_PREFIX } from "@/helpers/common.helper"; +// lib +import { AppProvider } from "@/lib/app-providers"; +// services +import { InstanceService } from "@/services/instance.service"; + +const instanceService = new InstanceService(); export const metadata: Metadata = { title: "Plane Deploy | Make your Plane boards public with one-click", @@ -20,6 +28,8 @@ export const metadata: Metadata = { }; export default async function RootLayout({ children }: { children: React.ReactNode }) { + const instanceDetails = await instanceService.getInstanceInfo().catch(() => undefined); + return ( @@ -29,7 +39,17 @@ export default async function RootLayout({ children }: { children: React.ReactNo - {children} + + + {!instanceDetails ? ( + + ) : ( + <>{instanceDetails.instance.is_setup_done ? <>{children} : } + )} + + {children} + + ); } diff --git a/space/app/not-found.tsx b/space/app/not-found.tsx index 98c4f95ca..2dd51630f 100644 --- a/space/app/not-found.tsx +++ b/space/app/not-found.tsx @@ -1,36 +1,21 @@ "use client"; import Image from "next/image"; -import { useTheme } from "next-themes"; -import { Button } from "@plane/ui"; // assets -import InstanceFailureDarkImage from "@/public/instance/instance-failure-dark.svg"; -import InstanceFailureImage from "@/public/instance/instance-failure.svg"; +import UserLoggedInImage from "public/user-logged-in.svg"; export default function InstanceNotFound() { - const { resolvedTheme } = useTheme(); - - const instanceImage = resolvedTheme === "dark" ? InstanceFailureDarkImage : InstanceFailureImage; - - const handleRetry = () => { - window.location.reload(); - }; - return (
-
-
-
- Plane Logo -

Unable to fetch instance details.

-

- We were unable to fetch the details of the instance.
- Fret not, it might just be a connectivity issue. -

-
-
- +
+
+
+
+
+ User already logged in +
+
+

Not Found

+

Please enter the appropriate project URL to view the issue board.

diff --git a/space/app/page.tsx b/space/app/page.tsx index b2c032287..5ac59d7e1 100644 --- a/space/app/page.tsx +++ b/space/app/page.tsx @@ -1,43 +1,20 @@ // components import { UserLoggedIn } from "@/components/accounts"; -import { InstanceNotReady, InstanceFailureView } from "@/components/instance"; import { AuthView } from "@/components/views"; -// helpers -// import { EPageTypes } from "@/helpers/authentication.helper"; -// import { useInstance, useUser } from "@/hooks/store"; -// wrapper -// import { AuthWrapper } from "@/lib/wrappers"; -// lib -import { AppProvider } from "@/lib/app-providers"; // services -import { InstanceService } from "@/services/instance.service"; import { UserService } from "@/services/user.service"; const userServices = new UserService(); -const instanceService = new InstanceService(); export default async function HomePage() { - const instanceDetails = await instanceService.getInstanceInfo().catch(() => undefined); const user = await userServices .currentUser() .then((user) => ({ ...user, isAuthenticated: true })) .catch(() => ({ isAuthenticated: false })); - if (!instanceDetails) { - return ; - } - - if (!instanceDetails?.instance?.is_setup_done) { - ; - } - if (user.isAuthenticated) { return ; } - return ( - - - - ); + return ; } diff --git a/space/components/issues/board-views/kanban/header.tsx b/space/components/issues/board-views/kanban/header.tsx index 5a4d9a226..9e88b6322 100644 --- a/space/components/issues/board-views/kanban/header.tsx +++ b/space/components/issues/board-views/kanban/header.tsx @@ -1,3 +1,4 @@ +"use client"; // mobx react lite import { observer } from "mobx-react-lite"; // ui @@ -5,12 +6,12 @@ import { StateGroupIcon } from "@plane/ui"; // constants import { issueGroupFilter } from "@/constants/data"; // mobx hook -import { useIssue } from "@/hooks/store"; +// import { useIssue } from "@/hooks/store"; // interfaces import { IIssueState } from "@/types/issue"; export const IssueKanBanHeader = observer(({ state }: { state: IIssueState }) => { - const { getCountOfIssuesByState } = useIssue(); + // const { getCountOfIssuesByState } = useIssue(); const stateGroup = issueGroupFilter(state.group); if (stateGroup === null) return <>; @@ -21,7 +22,7 @@ export const IssueKanBanHeader = observer(({ state }: { state: IIssueState }) =>
{state?.name}
- {getCountOfIssuesByState(state.id)} + {/* {getCountOfIssuesByState(state.id)} */}
); }); diff --git a/space/components/issues/board-views/list/block.tsx b/space/components/issues/board-views/list/block.tsx index e05ebcb2d..2bc9e8133 100644 --- a/space/components/issues/board-views/list/block.tsx +++ b/space/components/issues/board-views/list/block.tsx @@ -1,3 +1,4 @@ +"use client"; import { FC } from "react"; import { observer } from "mobx-react-lite"; import { useParams, useRouter, useSearchParams } from "next/navigation"; diff --git a/space/components/issues/board-views/list/header.tsx b/space/components/issues/board-views/list/header.tsx index 22a902474..f13a17f5a 100644 --- a/space/components/issues/board-views/list/header.tsx +++ b/space/components/issues/board-views/list/header.tsx @@ -1,16 +1,18 @@ +"use client"; import { observer } from "mobx-react-lite"; // ui import { StateGroupIcon } from "@plane/ui"; // constants import { issueGroupFilter } from "@/constants/data"; // mobx hook -import { useIssue } from "@/hooks/store"; +// import { useIssue } from "@/hooks/store"; // types import { IIssueState } from "@/types/issue"; export const IssueListHeader = observer(({ state }: { state: IIssueState }) => { - const { getCountOfIssuesByState } = useIssue(); + // const { getCountOfIssuesByState } = useIssue(); const stateGroup = issueGroupFilter(state.group); + // const count = getCountOfIssuesByState(state.id); if (stateGroup === null) return <>; @@ -20,7 +22,7 @@ export const IssueListHeader = observer(({ state }: { state: IIssueState }) => {
{state?.name}
-
{getCountOfIssuesByState(state.id)}
+ {/*
{count}
*/}
); }); diff --git a/space/components/issues/board-views/list/index.tsx b/space/components/issues/board-views/list/index.tsx index 7740bfd58..2a2b958be 100644 --- a/space/components/issues/board-views/list/index.tsx +++ b/space/components/issues/board-views/list/index.tsx @@ -1,3 +1,4 @@ +"use client"; import { FC } from "react"; import { observer } from "mobx-react-lite"; // components diff --git a/space/components/issues/navbar/controls.tsx b/space/components/issues/navbar/controls.tsx new file mode 100644 index 000000000..f344ef622 --- /dev/null +++ b/space/components/issues/navbar/controls.tsx @@ -0,0 +1,129 @@ +"use client"; + +import { useEffect, FC } from "react"; +import Link from "next/link"; +import { useRouter, useParams, useSearchParams, usePathname } from "next/navigation"; +// ui +import { Avatar, Button } from "@plane/ui"; +// components +import { IssueFiltersDropdown } from "@/components/issues/filters"; +// hooks +import { useProject, useUser, useIssueFilter } from "@/hooks/store"; +// types +import { TIssueBoardKeys } from "@/types/issue"; +// components +import { NavbarIssueBoardView } from "./issue-board-view"; +import { NavbarTheme } from "./theme"; + +export type NavbarControlsProps = { + workspaceSlug: string; + projectId: string; + projectSettings: any; +}; + +export const NavbarControls: FC = (props) => { + const { workspaceSlug, projectId, projectSettings } = props; + const { views } = projectSettings; + // router + const router = useRouter(); + const { board, labels, states, priorities, peekId } = useParams(); + const searchParams = useSearchParams(); + const pathName = usePathname(); + // store + const { updateFilters } = useIssueFilter(); + const { settings, activeLayout, hydrate, setActiveLayout } = useProject(); + hydrate(projectSettings); + + const { data: user } = useUser(); + + useEffect(() => { + if (workspaceSlug && projectId && settings) { + const viewsAcceptable: string[] = []; + const currentBoard: TIssueBoardKeys | null = null; + + if (settings?.views?.list) viewsAcceptable.push("list"); + if (settings?.views?.kanban) viewsAcceptable.push("kanban"); + if (settings?.views?.calendar) viewsAcceptable.push("calendar"); + if (settings?.views?.gantt) viewsAcceptable.push("gantt"); + if (settings?.views?.spreadsheet) viewsAcceptable.push("spreadsheet"); + + // if (board) { + // if (viewsAcceptable.includes(board.toString())) { + // currentBoard = board.toString() as TIssueBoardKeys; + // } else { + // if (viewsAcceptable && viewsAcceptable.length > 0) { + // currentBoard = viewsAcceptable[0] as TIssueBoardKeys; + // } + // } + // } else { + // if (viewsAcceptable && viewsAcceptable.length > 0) { + // currentBoard = viewsAcceptable[0] as TIssueBoardKeys; + // } + // } + + if (currentBoard) { + if (activeLayout === null || activeLayout !== currentBoard) { + let params: any = { board: currentBoard }; + if (peekId && peekId.length > 0) params = { ...params, peekId: peekId }; + if (priorities && priorities.length > 0) params = { ...params, priorities: priorities }; + if (states && states.length > 0) params = { ...params, states: states }; + if (labels && labels.length > 0) params = { ...params, labels: labels }; + console.log("params", params); + let storeParams: any = {}; + if (priorities && priorities.length > 0) storeParams = { ...storeParams, priority: priorities.split(",") }; + if (states && states.length > 0) storeParams = { ...storeParams, state: states.split(",") }; + if (labels && labels.length > 0) storeParams = { ...storeParams, labels: labels.split(",") }; + + if (storeParams) updateFilters(projectId, storeParams); + setActiveLayout(currentBoard); + router.push(`/${workspaceSlug}/${projectId}?${searchParams}`); + } + } + } + }, [ + board, + workspaceSlug, + projectId, + router, + updateFilters, + labels, + states, + priorities, + peekId, + settings, + activeLayout, + setActiveLayout, + searchParams, + ]); + return ( + <> + {/* issue views */} +
+ +
+ + {/* issue filters */} +
+ +
+ + {/* theming */} +
+ +
+ + {user?.id ? ( +
+ +
{user.display_name}
+
+ ) : ( +
+ + + +
+ )} + + ); +}; diff --git a/space/components/issues/navbar/index.tsx b/space/components/issues/navbar/index.tsx index 0139ae9ad..4ce2d2691 100644 --- a/space/components/issues/navbar/index.tsx +++ b/space/components/issues/navbar/index.tsx @@ -1,21 +1,11 @@ "use client"; -import { useEffect, FC } from "react"; +import { FC } from "react"; import { observer } from "mobx-react-lite"; -import Link from "next/link"; -import { useRouter, useParams, useSearchParams, usePathname } from "next/navigation"; import { Briefcase } from "lucide-react"; -import { Avatar, Button } from "@plane/ui"; // components import { ProjectLogo } from "@/components/common"; -import { IssueFiltersDropdown } from "@/components/issues/filters"; -// hooks -import { useProject, useUser, useIssueFilter } from "@/hooks/store"; -// types -import { TIssueBoardKeys } from "@/types/issue"; -// components -import { NavbarIssueBoardView } from "./issue-board-view"; -import { NavbarTheme } from "./theme"; +import { NavbarControls } from "./controls"; type IssueNavbarProps = { projectSettings: any; @@ -25,80 +15,10 @@ type IssueNavbarProps = { const IssueNavbar: FC = observer((props) => { const { projectSettings, workspaceSlug, projectId } = props; - const { project_details, views } = projectSettings; - const { board, labels, states, priorities, peekId } = useParams(); - const searchParams = useSearchParams(); - const pathName = usePathname(); - // hooks - const router = useRouter(); - // store - const { settings, activeLayout, hydrate, setActiveLayout } = useProject(); - const { data: user } = useUser(); - const { updateFilters } = useIssueFilter(); - hydrate(projectSettings); - - useEffect(() => { - if (workspaceSlug && projectId && settings) { - const viewsAcceptable: string[] = []; - const currentBoard: TIssueBoardKeys | null = null; - - if (settings?.views?.list) viewsAcceptable.push("list"); - if (settings?.views?.kanban) viewsAcceptable.push("kanban"); - if (settings?.views?.calendar) viewsAcceptable.push("calendar"); - if (settings?.views?.gantt) viewsAcceptable.push("gantt"); - if (settings?.views?.spreadsheet) viewsAcceptable.push("spreadsheet"); - - // if (board) { - // if (viewsAcceptable.includes(board.toString())) { - // currentBoard = board.toString() as TIssueBoardKeys; - // } else { - // if (viewsAcceptable && viewsAcceptable.length > 0) { - // currentBoard = viewsAcceptable[0] as TIssueBoardKeys; - // } - // } - // } else { - // if (viewsAcceptable && viewsAcceptable.length > 0) { - // currentBoard = viewsAcceptable[0] as TIssueBoardKeys; - // } - // } - - if (currentBoard) { - if (activeLayout === null || activeLayout !== currentBoard) { - let params: any = { board: currentBoard }; - if (peekId && peekId.length > 0) params = { ...params, peekId: peekId }; - if (priorities && priorities.length > 0) params = { ...params, priorities: priorities }; - if (states && states.length > 0) params = { ...params, states: states }; - if (labels && labels.length > 0) params = { ...params, labels: labels }; - console.log("params", params); - let storeParams: any = {}; - if (priorities && priorities.length > 0) storeParams = { ...storeParams, priority: priorities.split(",") }; - if (states && states.length > 0) storeParams = { ...storeParams, state: states.split(",") }; - if (labels && labels.length > 0) storeParams = { ...storeParams, labels: labels.split(",") }; - - if (storeParams) updateFilters(projectId, storeParams); - setActiveLayout(currentBoard); - router.push(`/${workspaceSlug}/${projectId}?${searchParams}`); - } - } - } - }, [ - board, - workspaceSlug, - projectId, - router, - updateFilters, - labels, - states, - priorities, - peekId, - settings, - activeLayout, - setActiveLayout, - searchParams, - ]); + const { project_details } = projectSettings; return ( -
+
{/* project detail */}
{project_details ? ( @@ -115,33 +35,9 @@ const IssueNavbar: FC = observer((props) => {
- {/* issue views */} -
- +
+
- - {/* issue filters */} -
- -
- - {/* theming */} -
- -
- - {user?.id ? ( -
- -
{user.display_name}
-
- ) : ( -
- - - -
- )}
); });