mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
dev: change layout
This commit is contained in:
parent
ddfd953408
commit
dc436f60fa
@ -1,40 +1,15 @@
|
|||||||
import Image from "next/image";
|
type Props = {
|
||||||
import { notFound } from "next/navigation";
|
|
||||||
// components
|
|
||||||
import IssueNavbar from "@/components/issues/navbar";
|
|
||||||
// assets
|
|
||||||
import planeLogo from "public/plane-logo.svg";
|
|
||||||
|
|
||||||
export default async function ProjectLayout({
|
|
||||||
children,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
params: { workspace_slug: string; project_id: string };
|
params: {
|
||||||
}) {
|
workspace_slug: string;
|
||||||
const { workspace_slug, project_id } = params;
|
project_id: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
if (!workspace_slug || !project_id) notFound();
|
const ProjectIssuesLayout = async (props: Props) => {
|
||||||
|
const { children } = props;
|
||||||
|
|
||||||
return (
|
return <>{children}</>;
|
||||||
<div className="relative flex h-screen min-h-[500px] w-screen flex-col overflow-hidden">
|
};
|
||||||
<div className="relative flex h-[60px] flex-shrink-0 select-none items-center border-b border-custom-border-300 bg-custom-sidebar-background-100">
|
|
||||||
<IssueNavbar workspaceSlug={workspace_slug} projectId={project_id} />
|
export default ProjectIssuesLayout;
|
||||||
</div>
|
|
||||||
<div className="relative h-full w-full overflow-hidden bg-custom-background-90">{children}</div>
|
|
||||||
<a
|
|
||||||
href="https://plane.so"
|
|
||||||
className="fixed bottom-2.5 right-5 !z-[999999] flex items-center gap-1 rounded border border-custom-border-200 bg-custom-background-100 px-2 py-1 shadow-custom-shadow-2xs"
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer noopener"
|
|
||||||
>
|
|
||||||
<div className="relative grid h-6 w-6 place-items-center">
|
|
||||||
<Image src={planeLogo} alt="Plane logo" className="h-6 w-6" height="24" width="24" />
|
|
||||||
</div>
|
|
||||||
<div className="text-xs">
|
|
||||||
Powered by <span className="font-semibold">Plane Deploy</span>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
@ -1,16 +1,50 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useSearchParams } from "next/navigation";
|
import { useEffect, useState } from "react";
|
||||||
|
import { notFound, useSearchParams } from "next/navigation";
|
||||||
// components
|
// components
|
||||||
import { ProjectDetailsView } from "@/components/views";
|
import { LogoSpinner } from "@/components/common";
|
||||||
|
// helpers
|
||||||
|
import { navigate } from "@/helpers/actions";
|
||||||
|
// services
|
||||||
|
import PublishService from "@/services/publish.service";
|
||||||
|
const publishService = new PublishService();
|
||||||
|
|
||||||
export default function WorkspaceProjectPage({ params }: { params: { workspace_slug: any; project_id: any } }) {
|
type Props = {
|
||||||
|
params: {
|
||||||
|
workspace_slug: string;
|
||||||
|
project_id: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const ProjectIssuesPage = (props: Props) => {
|
||||||
|
const { params } = props;
|
||||||
const { workspace_slug, project_id } = params;
|
const { workspace_slug, project_id } = params;
|
||||||
|
// states
|
||||||
|
const [error, setError] = useState(false);
|
||||||
|
// params
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
|
const board = searchParams.get("board") || undefined;
|
||||||
const peekId = searchParams.get("peekId") || undefined;
|
const peekId = searchParams.get("peekId") || undefined;
|
||||||
|
|
||||||
if (!workspace_slug || !project_id) return <></>;
|
useEffect(() => {
|
||||||
|
if (!workspace_slug || !project_id) return;
|
||||||
|
publishService
|
||||||
|
.fetchAnchorFromOldDetails(workspace_slug, project_id)
|
||||||
|
.then((res) => {
|
||||||
|
let url = `/${res.anchor}`;
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (board) params.append("board", board);
|
||||||
|
if (peekId) params.append("peekId", peekId);
|
||||||
|
if (params.toString()) url += `?${params.toString()}`;
|
||||||
|
navigate(url);
|
||||||
|
})
|
||||||
|
.catch(() => setError(true));
|
||||||
|
}, [board, peekId, project_id, workspace_slug]);
|
||||||
|
|
||||||
return <ProjectDetailsView workspaceSlug={workspace_slug} projectId={project_id} peekId={peekId} />;
|
if (error) notFound();
|
||||||
}
|
|
||||||
|
return <LogoSpinner />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProjectIssuesPage;
|
||||||
|
@ -21,7 +21,7 @@ export default function InstanceError() {
|
|||||||
<div className="w-auto max-w-2xl relative space-y-8 py-10">
|
<div className="w-auto max-w-2xl relative space-y-8 py-10">
|
||||||
<div className="relative flex flex-col justify-center items-center space-y-4">
|
<div className="relative flex flex-col justify-center items-center space-y-4">
|
||||||
<Image src={instanceImage} alt="Plane instance failure image" />
|
<Image src={instanceImage} alt="Plane instance failure image" />
|
||||||
<h3 className="font-medium text-2xl text-white ">Unable to fetch instance details.</h3>
|
<h3 className="font-medium text-2xl text-white">Unable to fetch instance details.</h3>
|
||||||
<p className="font-medium text-base text-center">
|
<p className="font-medium text-base text-center">
|
||||||
We were unable to fetch the details of the instance. <br />
|
We were unable to fetch the details of the instance. <br />
|
||||||
Fret not, it might just be a connectivity issue.
|
Fret not, it might just be a connectivity issue.
|
||||||
|
@ -4,20 +4,18 @@ import Image from "next/image";
|
|||||||
// assets
|
// assets
|
||||||
import UserLoggedInImage from "public/user-logged-in.svg";
|
import UserLoggedInImage from "public/user-logged-in.svg";
|
||||||
|
|
||||||
export default function NotFound() {
|
const NotFound = () => (
|
||||||
return (
|
<div className="h-screen w-screen grid place-items-center">
|
||||||
<div className="flex h-screen w-screen flex-col">
|
<div className="text-center">
|
||||||
<div className="grid h-full w-full place-items-center p-6">
|
<div className="mx-auto size-52 grid place-items-center rounded-full bg-custom-background-80">
|
||||||
<div className="text-center">
|
<div className="size-32">
|
||||||
<div className="mx-auto grid h-52 w-52 place-items-center rounded-full bg-custom-background-80">
|
<Image src={UserLoggedInImage} alt="User already logged in" />
|
||||||
<div className="h-32 w-32">
|
|
||||||
<Image src={UserLoggedInImage} alt="User already logged in" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h1 className="mt-12 text-3xl font-semibold">Not Found</h1>
|
|
||||||
<p className="mt-4">Please enter the appropriate project URL to view the issue board.</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<h1 className="mt-12 text-3xl font-semibold">Not Found</h1>
|
||||||
|
<p className="mt-4">Please enter the appropriate project URL to view the issue board.</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
</div>
|
||||||
}
|
);
|
||||||
|
|
||||||
|
export default NotFound;
|
||||||
|
48
space/app/page/layout.tsx
Normal file
48
space/app/page/layout.tsx
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import Image from "next/image";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
|
import useSWR from "swr";
|
||||||
|
// components
|
||||||
|
import IssueNavbar from "@/components/issues/navbar";
|
||||||
|
// hooks
|
||||||
|
import { usePublish, usePublishList } from "@/hooks/store";
|
||||||
|
// assets
|
||||||
|
import planeLogo from "@/public/plane-logo.svg";
|
||||||
|
|
||||||
|
type Props = { children: React.ReactNode; params: { anchor: string } };
|
||||||
|
|
||||||
|
const PageDetailsLayout = (props: Props) => {
|
||||||
|
const { children, params } = props;
|
||||||
|
// params
|
||||||
|
const { anchor } = params;
|
||||||
|
// store hooks
|
||||||
|
const { fetchPublishSettings } = usePublishList();
|
||||||
|
const { id, workspace_detail, project } = usePublish(anchor);
|
||||||
|
|
||||||
|
useSWR(anchor ? `PUBLISH_SETTINGS_${anchor}` : null, anchor ? () => fetchPublishSettings(anchor) : null);
|
||||||
|
|
||||||
|
if (!workspace_detail || !project || !id) notFound();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="relative flex h-screen min-h-[500px] w-screen flex-col overflow-hidden">
|
||||||
|
<div className="relative flex h-[60px] flex-shrink-0 select-none items-center border-b border-custom-border-300 bg-custom-sidebar-background-100">
|
||||||
|
<IssueNavbar workspaceSlug={workspace_detail.slug} projectId={project} />
|
||||||
|
</div>
|
||||||
|
<div className="relative h-full w-full overflow-hidden bg-custom-background-90">{children}</div>
|
||||||
|
<a
|
||||||
|
href="https://plane.so"
|
||||||
|
className="fixed bottom-2.5 right-5 !z-[999999] flex items-center gap-1 rounded border border-custom-border-200 bg-custom-background-100 px-2 py-1 shadow-custom-shadow-2xs"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer noopener"
|
||||||
|
>
|
||||||
|
<div className="relative grid h-6 w-6 place-items-center">
|
||||||
|
<Image src={planeLogo} alt="Plane logo" className="h-6 w-6" height="24" width="24" />
|
||||||
|
</div>
|
||||||
|
<div className="text-xs">
|
||||||
|
Powered by <span className="font-semibold">Plane Deploy</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PageDetailsLayout;
|
0
space/app/page/page.tsx
Normal file
0
space/app/page/page.tsx
Normal file
46
space/app/project-issues/[anchor]/layout.tsx
Normal file
46
space/app/project-issues/[anchor]/layout.tsx
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { observer } from "mobx-react";
|
||||||
|
import Image from "next/image";
|
||||||
|
import { notFound } from "next/navigation";
|
||||||
|
// components
|
||||||
|
import IssueNavbar from "@/components/issues/navbar";
|
||||||
|
// hooks
|
||||||
|
import { usePublish } from "@/hooks/store";
|
||||||
|
// assets
|
||||||
|
import planeLogo from "@/public/plane-logo.svg";
|
||||||
|
|
||||||
|
type Props = { children: React.ReactNode; params: { anchor: string } };
|
||||||
|
|
||||||
|
const ProjectIssuesLayout = (props: Props) => {
|
||||||
|
const { children, params } = props;
|
||||||
|
// params
|
||||||
|
const { anchor } = params;
|
||||||
|
// store hooks
|
||||||
|
const publishSettings = usePublish(anchor);
|
||||||
|
const { id, workspace_detail, project } = publishSettings;
|
||||||
|
|
||||||
|
if (!workspace_detail || !project || !id) notFound();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="relative flex h-screen min-h-[500px] w-screen flex-col overflow-hidden">
|
||||||
|
<div className="relative flex h-[60px] flex-shrink-0 select-none items-center border-b border-custom-border-300 bg-custom-sidebar-background-100">
|
||||||
|
<IssueNavbar publishSettings={publishSettings} />
|
||||||
|
</div>
|
||||||
|
<div className="relative h-full w-full overflow-hidden bg-custom-background-90">{children}</div>
|
||||||
|
<a
|
||||||
|
href="https://plane.so"
|
||||||
|
className="fixed bottom-2.5 right-5 !z-[999999] flex items-center gap-1 rounded border border-custom-border-200 bg-custom-background-100 px-2 py-1 shadow-custom-shadow-2xs"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer noopener"
|
||||||
|
>
|
||||||
|
<div className="relative grid h-6 w-6 place-items-center">
|
||||||
|
<Image src={planeLogo} alt="Plane logo" className="h-6 w-6" height="24" width="24" />
|
||||||
|
</div>
|
||||||
|
<div className="text-xs">
|
||||||
|
Powered by <span className="font-semibold">Plane Deploy</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProjectIssuesLayout;
|
33
space/app/project-issues/[anchor]/page.tsx
Normal file
33
space/app/project-issues/[anchor]/page.tsx
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useSearchParams } from "next/navigation";
|
||||||
|
import useSWR from "swr";
|
||||||
|
// components
|
||||||
|
import { ProjectDetailsView } from "@/components/views";
|
||||||
|
// hooks
|
||||||
|
import { usePublish, usePublishList } from "@/hooks/store";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
params: {
|
||||||
|
anchor: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const ProjectIssuesPage = (props: Props) => {
|
||||||
|
const { params } = props;
|
||||||
|
const { anchor } = params;
|
||||||
|
// params
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const peekId = searchParams.get("peekId") || undefined;
|
||||||
|
// store hooks
|
||||||
|
const { fetchPublishSettings } = usePublishList();
|
||||||
|
const publishSettings = usePublish(anchor);
|
||||||
|
|
||||||
|
useSWR(anchor ? `PUBLISH_SETTINGS_${anchor}` : null, anchor ? () => fetchPublishSettings(anchor) : null);
|
||||||
|
|
||||||
|
if (!publishSettings) return null;
|
||||||
|
|
||||||
|
return <ProjectDetailsView peekId={peekId} publishSettings={publishSettings} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProjectIssuesPage;
|
@ -1,36 +1,44 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
import { useTheme } from "next-themes";
|
||||||
// components
|
// components
|
||||||
import { UserAvatar } from "@/components/issues/navbar/user-avatar";
|
import { UserAvatar } from "@/components/issues/navbar/user-avatar";
|
||||||
// hooks
|
// hooks
|
||||||
import { useUser } from "@/hooks/store";
|
import { useUser } from "@/hooks/store";
|
||||||
// assets
|
// assets
|
||||||
import PlaneLogo from "@/public/plane-logos/black-horizontal-with-blue-logo.png";
|
import PlaneBlackLogo from "@/public/plane-logos/black-horizontal-with-blue-logo.png";
|
||||||
|
import PlaneWhiteLogo from "@/public/plane-logos/white-horizontal-with-blue-logo.png";
|
||||||
import UserLoggedInImage from "@/public/user-logged-in.svg";
|
import UserLoggedInImage from "@/public/user-logged-in.svg";
|
||||||
|
|
||||||
export const UserLoggedIn = () => {
|
export const UserLoggedIn = observer(() => {
|
||||||
|
// store hooks
|
||||||
const { data: user } = useUser();
|
const { data: user } = useUser();
|
||||||
|
// next-themes
|
||||||
|
const { resolvedTheme } = useTheme();
|
||||||
|
|
||||||
|
const logo = resolvedTheme === "dark" ? PlaneWhiteLogo : PlaneBlackLogo;
|
||||||
|
|
||||||
if (!user) return null;
|
if (!user) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen w-screen flex-col">
|
<div className="flex flex-col h-screen w-screen">
|
||||||
<div className="relative flex w-full items-center justify-between gap-4 border-b border-custom-border-200 px-6 py-5">
|
<div className="relative flex w-full items-center justify-between gap-4 border-b border-custom-border-200 px-6 py-5">
|
||||||
<div>
|
<div>
|
||||||
<Image src={PlaneLogo} alt="User already logged in" />
|
<Image src={logo} alt="Plane logo" />
|
||||||
</div>
|
</div>
|
||||||
<UserAvatar />
|
<UserAvatar />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid h-full w-full place-items-center p-6">
|
<div className="size-full grid place-items-center p-6">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<div className="mx-auto grid h-52 w-52 place-items-center rounded-full bg-custom-background-80">
|
<div className="mx-auto size-52 grid place-items-center rounded-full bg-custom-background-80">
|
||||||
<div className="h-32 w-32">
|
<div className="size-32">
|
||||||
<Image src={UserLoggedInImage} alt="User already logged in" />
|
<Image src={UserLoggedInImage} alt="User already logged in" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h1 className="mt-12 text-3xl font-semibold">Logged in Successfully!</h1>
|
<h1 className="mt-12 text-3xl font-semibold">Logged in successfully!</h1>
|
||||||
<p className="mt-4">
|
<p className="mt-4">
|
||||||
You{"'"}ve successfully logged in. Please enter the appropriate project URL to view the issue board.
|
You{"'"}ve successfully logged in. Please enter the appropriate project URL to view the issue board.
|
||||||
</p>
|
</p>
|
||||||
@ -38,4 +46,4 @@ export const UserLoggedIn = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
@ -11,19 +11,20 @@ import { UserAvatar } from "@/components/issues/navbar/user-avatar";
|
|||||||
// helpers
|
// helpers
|
||||||
import { queryParamGenerator } from "@/helpers/query-param-generator";
|
import { queryParamGenerator } from "@/helpers/query-param-generator";
|
||||||
// hooks
|
// hooks
|
||||||
import { useProject, useIssueFilter, useIssueDetails } from "@/hooks/store";
|
import { useIssueFilter, useIssueDetails } from "@/hooks/store";
|
||||||
import useIsInIframe from "@/hooks/use-is-in-iframe";
|
import useIsInIframe from "@/hooks/use-is-in-iframe";
|
||||||
|
// store
|
||||||
|
import { PublishStore } from "@/store/publish/publish.store";
|
||||||
// types
|
// types
|
||||||
import { TIssueLayout } from "@/types/issue";
|
import { TIssueLayout } from "@/types/issue";
|
||||||
|
|
||||||
export type NavbarControlsProps = {
|
export type NavbarControlsProps = {
|
||||||
workspaceSlug: string;
|
publishSettings: PublishStore;
|
||||||
projectId: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NavbarControls: FC<NavbarControlsProps> = observer((props) => {
|
export const NavbarControls: FC<NavbarControlsProps> = observer((props) => {
|
||||||
// props
|
// props
|
||||||
const { workspaceSlug, projectId } = props;
|
const { publishSettings } = props;
|
||||||
// router
|
// router
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
@ -35,23 +36,23 @@ export const NavbarControls: FC<NavbarControlsProps> = observer((props) => {
|
|||||||
const peekId = searchParams.get("peekId") || undefined;
|
const peekId = searchParams.get("peekId") || undefined;
|
||||||
// hooks
|
// hooks
|
||||||
const { issueFilters, isIssueFiltersUpdated, initIssueFilters } = useIssueFilter();
|
const { issueFilters, isIssueFiltersUpdated, initIssueFilters } = useIssueFilter();
|
||||||
const { settings } = useProject();
|
|
||||||
const { setPeekId } = useIssueDetails();
|
const { setPeekId } = useIssueDetails();
|
||||||
// derived values
|
// derived values
|
||||||
const activeLayout = issueFilters?.display_filters?.layout || undefined;
|
const activeLayout = issueFilters?.display_filters?.layout || undefined;
|
||||||
|
const { project, views, workspace_detail } = publishSettings;
|
||||||
|
|
||||||
const isInIframe = useIsInIframe();
|
const isInIframe = useIsInIframe();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (workspaceSlug && projectId && settings) {
|
if (project && workspace_detail) {
|
||||||
const viewsAcceptable: string[] = [];
|
const viewsAcceptable: string[] = [];
|
||||||
let currentBoard: TIssueLayout | null = null;
|
let currentBoard: TIssueLayout | null = null;
|
||||||
|
|
||||||
if (settings?.views?.list) viewsAcceptable.push("list");
|
if (views?.list) viewsAcceptable.push("list");
|
||||||
if (settings?.views?.kanban) viewsAcceptable.push("kanban");
|
if (views?.kanban) viewsAcceptable.push("kanban");
|
||||||
if (settings?.views?.calendar) viewsAcceptable.push("calendar");
|
if (views?.calendar) viewsAcceptable.push("calendar");
|
||||||
if (settings?.views?.gantt) viewsAcceptable.push("gantt");
|
if (views?.gantt) viewsAcceptable.push("gantt");
|
||||||
if (settings?.views?.spreadsheet) viewsAcceptable.push("spreadsheet");
|
if (views?.spreadsheet) viewsAcceptable.push("spreadsheet");
|
||||||
|
|
||||||
if (board) {
|
if (board) {
|
||||||
if (viewsAcceptable.includes(board.toString())) currentBoard = board.toString() as TIssueLayout;
|
if (viewsAcceptable.includes(board.toString())) currentBoard = board.toString() as TIssueLayout;
|
||||||
@ -75,38 +76,40 @@ export const NavbarControls: FC<NavbarControlsProps> = observer((props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!isIssueFiltersUpdated(params)) {
|
if (!isIssueFiltersUpdated(params)) {
|
||||||
initIssueFilters(projectId, params);
|
initIssueFilters(project, params);
|
||||||
router.push(`/${workspaceSlug}/${projectId}?${queryParam}`);
|
router.push(`/${workspace_detail.slug}/${project}?${queryParam}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
workspaceSlug,
|
|
||||||
projectId,
|
|
||||||
board,
|
board,
|
||||||
labels,
|
labels,
|
||||||
state,
|
state,
|
||||||
priority,
|
priority,
|
||||||
peekId,
|
peekId,
|
||||||
settings,
|
|
||||||
activeLayout,
|
activeLayout,
|
||||||
router,
|
router,
|
||||||
initIssueFilters,
|
initIssueFilters,
|
||||||
setPeekId,
|
setPeekId,
|
||||||
isIssueFiltersUpdated,
|
isIssueFiltersUpdated,
|
||||||
|
views,
|
||||||
|
project,
|
||||||
|
workspace_detail,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (!workspace_detail || !project) return;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* issue views */}
|
{/* issue views */}
|
||||||
<div className="relative flex flex-shrink-0 items-center gap-1 transition-all delay-150 ease-in-out">
|
<div className="relative flex flex-shrink-0 items-center gap-1 transition-all delay-150 ease-in-out">
|
||||||
<NavbarIssueBoardView workspaceSlug={workspaceSlug} projectId={projectId} />
|
<NavbarIssueBoardView workspaceSlug={workspace_detail.slug} projectId={project} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* issue filters */}
|
{/* issue filters */}
|
||||||
<div className="relative flex flex-shrink-0 items-center gap-1 transition-all delay-150 ease-in-out">
|
<div className="relative flex flex-shrink-0 items-center gap-1 transition-all delay-150 ease-in-out">
|
||||||
<IssueFiltersDropdown workspaceSlug={workspaceSlug} projectId={projectId} />
|
<IssueFiltersDropdown workspaceSlug={workspace_detail.slug} projectId={project} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* theming */}
|
{/* theming */}
|
||||||
|
@ -5,37 +5,38 @@ import { Briefcase } from "lucide-react";
|
|||||||
// components
|
// components
|
||||||
import { ProjectLogo } from "@/components/common";
|
import { ProjectLogo } from "@/components/common";
|
||||||
import { NavbarControls } from "@/components/issues/navbar/controls";
|
import { NavbarControls } from "@/components/issues/navbar/controls";
|
||||||
// hooks
|
// store
|
||||||
import { useProject } from "@/hooks/store";
|
import { PublishStore } from "@/store/publish/publish.store";
|
||||||
|
|
||||||
type IssueNavbarProps = {
|
type IssueNavbarProps = {
|
||||||
workspaceSlug: string;
|
publishSettings: PublishStore;
|
||||||
projectId: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const IssueNavbar: FC<IssueNavbarProps> = observer((props) => {
|
const IssueNavbar: FC<IssueNavbarProps> = observer((props) => {
|
||||||
const { workspaceSlug, projectId } = props;
|
const { publishSettings } = props;
|
||||||
// hooks
|
// hooks
|
||||||
const { project } = useProject();
|
const { project_details } = publishSettings;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative flex justify-between w-full gap-4 px-5">
|
<div className="relative flex justify-between w-full gap-4 px-5">
|
||||||
{/* project detail */}
|
{/* project detail */}
|
||||||
<div className="flex flex-shrink-0 items-center gap-2">
|
<div className="flex flex-shrink-0 items-center gap-2">
|
||||||
{project ? (
|
{project_details ? (
|
||||||
<span className="h-7 w-7 flex-shrink-0 grid place-items-center">
|
<span className="h-7 w-7 flex-shrink-0 grid place-items-center">
|
||||||
<ProjectLogo logo={project.logo_props} className="text-lg" />
|
<ProjectLogo logo={project_details.logo_props} className="text-lg" />
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded uppercase">
|
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded uppercase">
|
||||||
<Briefcase className="h-4 w-4" />
|
<Briefcase className="h-4 w-4" />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<div className="line-clamp-1 max-w-[300px] overflow-hidden text-lg font-medium">{project?.name || `...`}</div>
|
<div className="line-clamp-1 max-w-[300px] overflow-hidden text-lg font-medium">
|
||||||
|
{project_details?.name || `...`}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-shrink-0 items-center gap-2">
|
<div className="flex flex-shrink-0 items-center gap-2">
|
||||||
<NavbarControls workspaceSlug={workspaceSlug} projectId={projectId} />
|
<NavbarControls publishSettings={publishSettings} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { useEffect } from "react";
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||||
// lib
|
// lib
|
||||||
@ -29,7 +28,7 @@ export const IssueEmojiReactions: React.FC<IssueEmojiReactionsProps> = observer(
|
|||||||
const { workspaceSlug, projectId } = props;
|
const { workspaceSlug, projectId } = props;
|
||||||
// store
|
// store
|
||||||
const issueDetailsStore = useIssueDetails();
|
const issueDetailsStore = useIssueDetails();
|
||||||
const { data: user, fetchCurrentUser } = useUser();
|
const { data: user } = useUser();
|
||||||
|
|
||||||
const issueId = issueDetailsStore.peekId;
|
const issueId = issueDetailsStore.peekId;
|
||||||
const reactions = issueId ? issueDetailsStore.details[issueId]?.reactions || [] : [];
|
const reactions = issueId ? issueDetailsStore.details[issueId]?.reactions || [] : [];
|
||||||
@ -53,11 +52,6 @@ export const IssueEmojiReactions: React.FC<IssueEmojiReactionsProps> = observer(
|
|||||||
else handleAddReaction(reactionHex);
|
else handleAddReaction(reactionHex);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (user) return;
|
|
||||||
fetchCurrentUser();
|
|
||||||
}, [user, fetchCurrentUser]);
|
|
||||||
|
|
||||||
// derived values
|
// derived values
|
||||||
const { queryParam } = queryParamGenerator({ peekId, board, state, priority, labels });
|
const { queryParam } = queryParamGenerator({ peekId, board, state, priority, labels });
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState } from "react";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||||
import { Tooltip } from "@plane/ui";
|
import { Tooltip } from "@plane/ui";
|
||||||
@ -32,7 +32,7 @@ export const IssueVotes: React.FC<TIssueVotes> = observer((props) => {
|
|||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
const issueDetailsStore = useIssueDetails();
|
const issueDetailsStore = useIssueDetails();
|
||||||
const { data: user, fetchCurrentUser } = useUser();
|
const { data: user } = useUser();
|
||||||
|
|
||||||
const isInIframe = useIsInIframe();
|
const isInIframe = useIsInIframe();
|
||||||
|
|
||||||
@ -63,12 +63,6 @@ export const IssueVotes: React.FC<TIssueVotes> = observer((props) => {
|
|||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (user) return;
|
|
||||||
|
|
||||||
fetchCurrentUser();
|
|
||||||
}, [user, fetchCurrentUser]);
|
|
||||||
|
|
||||||
const VOTES_LIMIT = 1000;
|
const VOTES_LIMIT = 1000;
|
||||||
|
|
||||||
// derived values
|
// derived values
|
||||||
|
@ -13,62 +13,52 @@ import { IssueListView } from "@/components/issues/board-views/list";
|
|||||||
import { IssueSpreadsheetView } from "@/components/issues/board-views/spreadsheet";
|
import { IssueSpreadsheetView } from "@/components/issues/board-views/spreadsheet";
|
||||||
import { IssueAppliedFilters } from "@/components/issues/filters/applied-filters/root";
|
import { IssueAppliedFilters } from "@/components/issues/filters/applied-filters/root";
|
||||||
import { IssuePeekOverview } from "@/components/issues/peek-overview";
|
import { IssuePeekOverview } from "@/components/issues/peek-overview";
|
||||||
// mobx store
|
// hooks
|
||||||
import { useIssue, useUser, useIssueDetails, useIssueFilter, useProject } from "@/hooks/store";
|
import { useIssue, useIssueDetails, useIssueFilter } from "@/hooks/store";
|
||||||
|
// store
|
||||||
|
import { PublishStore } from "@/store/publish/publish.store";
|
||||||
// assets
|
// assets
|
||||||
import SomethingWentWrongImage from "public/something-went-wrong.svg";
|
import SomethingWentWrongImage from "public/something-went-wrong.svg";
|
||||||
|
|
||||||
type ProjectDetailsViewProps = {
|
type ProjectDetailsViewProps = {
|
||||||
workspaceSlug: string;
|
|
||||||
projectId: string;
|
|
||||||
peekId: string | undefined;
|
peekId: string | undefined;
|
||||||
|
publishSettings: PublishStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ProjectDetailsView: FC<ProjectDetailsViewProps> = observer((props) => {
|
export const ProjectDetailsView: FC<ProjectDetailsViewProps> = observer((props) => {
|
||||||
// router
|
const { peekId, publishSettings } = props;
|
||||||
const searchParams = useSearchParams();
|
|
||||||
// query params
|
// query params
|
||||||
|
const searchParams = useSearchParams();
|
||||||
const states = searchParams.get("states") || undefined;
|
const states = searchParams.get("states") || undefined;
|
||||||
const priority = searchParams.get("priority") || undefined;
|
const priority = searchParams.get("priority") || undefined;
|
||||||
const labels = searchParams.get("labels") || undefined;
|
const labels = searchParams.get("labels") || undefined;
|
||||||
|
// store hooks
|
||||||
const { workspaceSlug, projectId, peekId } = props;
|
|
||||||
// hooks
|
|
||||||
const { fetchProjectSettings } = useProject();
|
|
||||||
const { issueFilters } = useIssueFilter();
|
const { issueFilters } = useIssueFilter();
|
||||||
const { loader, issues, error, fetchPublicIssues } = useIssue();
|
const { loader, issues, error, fetchPublicIssues } = useIssue();
|
||||||
const issueDetailStore = useIssueDetails();
|
const issueDetailStore = useIssueDetails();
|
||||||
const { data: currentUser, fetchCurrentUser } = useUser();
|
// derived values
|
||||||
|
const { workspace_detail, project } = publishSettings;
|
||||||
|
const workspaceSlug = workspace_detail?.slug;
|
||||||
|
|
||||||
useSWR(
|
useSWR(
|
||||||
workspaceSlug && projectId ? "WORKSPACE_PROJECT_SETTINGS" : null,
|
workspaceSlug && project ? `WORKSPACE_PROJECT_PUBLIC_ISSUES_${workspaceSlug}_${project}` : null,
|
||||||
workspaceSlug && projectId ? () => fetchProjectSettings(workspaceSlug, projectId) : null
|
workspaceSlug && project ? () => fetchPublicIssues(workspaceSlug, project, { states, priority, labels }) : null
|
||||||
);
|
|
||||||
useSWR(
|
|
||||||
(workspaceSlug && projectId) || states || priority || labels ? "WORKSPACE_PROJECT_PUBLIC_ISSUES" : null,
|
|
||||||
(workspaceSlug && projectId) || states || priority || labels
|
|
||||||
? () => fetchPublicIssues(workspaceSlug, projectId, { states, priority, labels })
|
|
||||||
: null
|
|
||||||
);
|
|
||||||
useSWR(
|
|
||||||
workspaceSlug && projectId && !currentUser ? "WORKSPACE_PROJECT_CURRENT_USER" : null,
|
|
||||||
workspaceSlug && projectId && !currentUser ? () => fetchCurrentUser() : null
|
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (peekId && workspaceSlug && projectId) {
|
if (peekId) {
|
||||||
issueDetailStore.setPeekId(peekId.toString());
|
issueDetailStore.setPeekId(peekId.toString());
|
||||||
}
|
}
|
||||||
}, [peekId, issueDetailStore, projectId, workspaceSlug]);
|
}, [peekId, issueDetailStore]);
|
||||||
|
|
||||||
// derived values
|
// derived values
|
||||||
const activeLayout = issueFilters?.display_filters?.layout || undefined;
|
const activeLayout = issueFilters?.display_filters?.layout || undefined;
|
||||||
|
|
||||||
|
if (!workspaceSlug || !project) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative h-full w-full overflow-hidden">
|
<div className="relative h-full w-full overflow-hidden">
|
||||||
{workspaceSlug && projectId && peekId && (
|
{peekId && <IssuePeekOverview workspaceSlug={workspaceSlug} projectId={project} peekId={peekId} />}
|
||||||
<IssuePeekOverview workspaceSlug={workspaceSlug} projectId={projectId} peekId={peekId} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{loader && !issues ? (
|
{loader && !issues ? (
|
||||||
<div className="py-10 text-center text-sm text-custom-text-100">Loading...</div>
|
<div className="py-10 text-center text-sm text-custom-text-100">Loading...</div>
|
||||||
@ -90,16 +80,16 @@ export const ProjectDetailsView: FC<ProjectDetailsViewProps> = observer((props)
|
|||||||
activeLayout && (
|
activeLayout && (
|
||||||
<div className="relative flex h-full w-full flex-col overflow-hidden">
|
<div className="relative flex h-full w-full flex-col overflow-hidden">
|
||||||
{/* applied filters */}
|
{/* applied filters */}
|
||||||
<IssueAppliedFilters workspaceSlug={workspaceSlug} projectId={projectId} />
|
<IssueAppliedFilters workspaceSlug={workspaceSlug} projectId={project} />
|
||||||
|
|
||||||
{activeLayout === "list" && (
|
{activeLayout === "list" && (
|
||||||
<div className="relative h-full w-full overflow-y-auto">
|
<div className="relative h-full w-full overflow-y-auto">
|
||||||
<IssueListView workspaceSlug={workspaceSlug} projectId={projectId} />
|
<IssueListView workspaceSlug={workspaceSlug} projectId={project} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{activeLayout === "kanban" && (
|
{activeLayout === "kanban" && (
|
||||||
<div className="relative mx-auto h-full w-full p-5">
|
<div className="relative mx-auto h-full w-full p-5">
|
||||||
<IssueKanbanView workspaceSlug={workspaceSlug} projectId={projectId} />
|
<IssueKanbanView workspaceSlug={workspaceSlug} projectId={project} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{activeLayout === "calendar" && <IssueCalendarView />}
|
{activeLayout === "calendar" && <IssueCalendarView />}
|
||||||
|
5
space/helpers/actions.ts
Normal file
5
space/helpers/actions.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
"use server";
|
||||||
|
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const navigate = async (path: string) => redirect(path);
|
@ -1,5 +1,5 @@
|
|||||||
|
export * from "./publish";
|
||||||
export * from "./use-instance";
|
export * from "./use-instance";
|
||||||
export * from "./use-project";
|
|
||||||
export * from "./use-issue";
|
export * from "./use-issue";
|
||||||
export * from "./use-user";
|
export * from "./use-user";
|
||||||
export * from "./use-user-profile";
|
export * from "./use-user-profile";
|
||||||
|
2
space/hooks/store/publish/index.ts
Normal file
2
space/hooks/store/publish/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from "./use-publish-list";
|
||||||
|
export * from "./use-publish";
|
11
space/hooks/store/publish/use-publish-list.ts
Normal file
11
space/hooks/store/publish/use-publish-list.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { useContext } from "react";
|
||||||
|
// lib
|
||||||
|
import { StoreContext } from "@/lib/store-provider";
|
||||||
|
// store
|
||||||
|
import { IPublishListStore } from "@/store/publish/publish_list.store";
|
||||||
|
|
||||||
|
export const usePublishList = (): IPublishListStore => {
|
||||||
|
const context = useContext(StoreContext);
|
||||||
|
if (context === undefined) throw new Error("usePublishList must be used within StoreProvider");
|
||||||
|
return context.publishList;
|
||||||
|
};
|
11
space/hooks/store/publish/use-publish.ts
Normal file
11
space/hooks/store/publish/use-publish.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { useContext } from "react";
|
||||||
|
// lib
|
||||||
|
import { StoreContext } from "@/lib/store-provider";
|
||||||
|
// store
|
||||||
|
import { PublishStore } from "@/store/publish/publish.store";
|
||||||
|
|
||||||
|
export const usePublish = (anchor: string): PublishStore => {
|
||||||
|
const context = useContext(StoreContext);
|
||||||
|
if (context === undefined) throw new Error("usePublish must be used within StoreProvider");
|
||||||
|
return context.publishList.publishMap?.[anchor] ?? {};
|
||||||
|
};
|
@ -1,12 +0,0 @@
|
|||||||
import { ReactNode } from "react";
|
|
||||||
import { observer } from "mobx-react-lite";
|
|
||||||
import useSWR from "swr";
|
|
||||||
import { useUser } from "@/hooks/store";
|
|
||||||
|
|
||||||
export const UserProvider = observer(({ children }: { children: ReactNode }) => {
|
|
||||||
const { fetchCurrentUser } = useUser();
|
|
||||||
|
|
||||||
useSWR("CURRENT_USER", () => fetchCurrentUser());
|
|
||||||
|
|
||||||
return <>{children}</>;
|
|
||||||
});
|
|
@ -1,19 +0,0 @@
|
|||||||
import { API_BASE_URL } from "@/helpers/common.helper";
|
|
||||||
// services
|
|
||||||
import { APIService } from "@/services/api.service";
|
|
||||||
|
|
||||||
class ProjectService extends APIService {
|
|
||||||
constructor() {
|
|
||||||
super(API_BASE_URL);
|
|
||||||
}
|
|
||||||
|
|
||||||
async getProjectSettings(workspace_slug: string, project_slug: string): Promise<any> {
|
|
||||||
return this.get(`/api/public/workspaces/${workspace_slug}/project-boards/${project_slug}/settings/`)
|
|
||||||
.then((response) => response?.data)
|
|
||||||
.catch((error) => {
|
|
||||||
throw error?.response;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ProjectService;
|
|
37
space/services/publish.service.ts
Normal file
37
space/services/publish.service.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
||||||
|
// services
|
||||||
|
import { APIService } from "@/services/api.service";
|
||||||
|
// types
|
||||||
|
import { TPublishSettings } from "@/types/publish";
|
||||||
|
|
||||||
|
class PublishService extends APIService {
|
||||||
|
constructor() {
|
||||||
|
super(API_BASE_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchPublishSettings(anchor: string): Promise<TPublishSettings> {
|
||||||
|
return this.get(`/api/public/publish-settings/${anchor}/`)
|
||||||
|
.then((response) => response?.data)
|
||||||
|
.catch((error) => {
|
||||||
|
throw error?.response;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchAnchorFromOldDetails(
|
||||||
|
workspaceSlug: string,
|
||||||
|
projectID: string
|
||||||
|
): Promise<{
|
||||||
|
anchor: string;
|
||||||
|
}> {
|
||||||
|
return this.post(`/api/public/publish-anchor/`, {
|
||||||
|
workspaceSlug,
|
||||||
|
projectID,
|
||||||
|
})
|
||||||
|
.then((response) => response?.data)
|
||||||
|
.catch((error) => {
|
||||||
|
throw error?.response;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PublishService;
|
@ -13,7 +13,7 @@ export interface IProjectStore {
|
|||||||
error: any | undefined;
|
error: any | undefined;
|
||||||
settings: TProjectSettings | undefined;
|
settings: TProjectSettings | undefined;
|
||||||
workspace: TWorkspaceDetails | undefined;
|
workspace: TWorkspaceDetails | undefined;
|
||||||
project: TProjectDetails | undefined;
|
projectMap: Record<string, TProjectDetails>; // { [projectID]: TProjectDetails }
|
||||||
canReact: boolean;
|
canReact: boolean;
|
||||||
canComment: boolean;
|
canComment: boolean;
|
||||||
canVote: boolean;
|
canVote: boolean;
|
||||||
@ -28,7 +28,7 @@ export class ProjectStore implements IProjectStore {
|
|||||||
error: any | undefined = undefined;
|
error: any | undefined = undefined;
|
||||||
settings: TProjectSettings | undefined = undefined;
|
settings: TProjectSettings | undefined = undefined;
|
||||||
workspace: TWorkspaceDetails | undefined = undefined;
|
workspace: TWorkspaceDetails | undefined = undefined;
|
||||||
project: TProjectDetails | undefined = undefined;
|
projectMap: Record<string, TProjectDetails> = {};
|
||||||
// service
|
// service
|
||||||
projectService;
|
projectService;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ export class ProjectStore implements IProjectStore {
|
|||||||
error: observable.ref,
|
error: observable.ref,
|
||||||
// observable
|
// observable
|
||||||
workspace: observable,
|
workspace: observable,
|
||||||
project: observable,
|
projectMap: observable,
|
||||||
settings: observable,
|
settings: observable,
|
||||||
// computed
|
// computed
|
||||||
canReact: computed,
|
canReact: computed,
|
||||||
|
67
space/store/publish/publish.store.ts
Normal file
67
space/store/publish/publish.store.ts
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import { observable, makeObservable } from "mobx";
|
||||||
|
// store types
|
||||||
|
import { RootStore } from "@/store/root.store";
|
||||||
|
// types
|
||||||
|
import { TProjectDetails, TViewDetails, TWorkspaceDetails } from "@/types/project";
|
||||||
|
import { TPublishSettings } from "@/types/publish";
|
||||||
|
|
||||||
|
export interface IPublishStore extends TPublishSettings {}
|
||||||
|
|
||||||
|
export class PublishStore implements IPublishStore {
|
||||||
|
// observables
|
||||||
|
anchor: string | undefined;
|
||||||
|
comments: boolean;
|
||||||
|
created_at: string | undefined;
|
||||||
|
created_by: string | undefined;
|
||||||
|
id: string | undefined;
|
||||||
|
inbox: unknown;
|
||||||
|
project: string | undefined;
|
||||||
|
project_details: TProjectDetails | undefined;
|
||||||
|
reactions: boolean;
|
||||||
|
updated_at: string | undefined;
|
||||||
|
updated_by: string | undefined;
|
||||||
|
views: TViewDetails | undefined;
|
||||||
|
votes: boolean;
|
||||||
|
workspace: string | undefined;
|
||||||
|
workspace_detail: TWorkspaceDetails | undefined;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private store: RootStore,
|
||||||
|
publishSettings: TPublishSettings
|
||||||
|
) {
|
||||||
|
this.anchor = publishSettings.anchor;
|
||||||
|
this.comments = publishSettings.comments;
|
||||||
|
this.created_at = publishSettings.created_at;
|
||||||
|
this.created_by = publishSettings.created_by;
|
||||||
|
this.id = publishSettings.id;
|
||||||
|
this.inbox = publishSettings.inbox;
|
||||||
|
this.project = publishSettings.project;
|
||||||
|
this.project_details = publishSettings.project_details;
|
||||||
|
this.reactions = publishSettings.reactions;
|
||||||
|
this.updated_at = publishSettings.updated_at;
|
||||||
|
this.updated_by = publishSettings.updated_by;
|
||||||
|
this.views = publishSettings.views;
|
||||||
|
this.votes = publishSettings.votes;
|
||||||
|
this.workspace = publishSettings.workspace;
|
||||||
|
this.workspace_detail = publishSettings.workspace_detail;
|
||||||
|
|
||||||
|
makeObservable(this, {
|
||||||
|
// observables
|
||||||
|
anchor: observable.ref,
|
||||||
|
comments: observable.ref,
|
||||||
|
created_at: observable.ref,
|
||||||
|
created_by: observable.ref,
|
||||||
|
id: observable.ref,
|
||||||
|
inbox: observable,
|
||||||
|
project: observable.ref,
|
||||||
|
project_details: observable,
|
||||||
|
reactions: observable.ref,
|
||||||
|
updated_at: observable.ref,
|
||||||
|
updated_by: observable.ref,
|
||||||
|
views: observable,
|
||||||
|
votes: observable.ref,
|
||||||
|
workspace: observable.ref,
|
||||||
|
workspace_detail: observable,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
52
space/store/publish/publish_list.store.ts
Normal file
52
space/store/publish/publish_list.store.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import set from "lodash/set";
|
||||||
|
import { makeObservable, observable, runInAction, action } from "mobx";
|
||||||
|
// services
|
||||||
|
import PublishService from "@/services/publish.service";
|
||||||
|
// store
|
||||||
|
import { PublishStore } from "@/store/publish/publish.store";
|
||||||
|
// store
|
||||||
|
import { TPublishSettings } from "@/types/publish";
|
||||||
|
import { RootStore } from "../root.store";
|
||||||
|
|
||||||
|
export interface IPublishListStore {
|
||||||
|
// observables
|
||||||
|
publishMap: Record<string, PublishStore>; // anchor => PublishStore
|
||||||
|
// actions
|
||||||
|
fetchPublishSettings: (pageId: string) => Promise<TPublishSettings>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PublishListStore implements IPublishListStore {
|
||||||
|
// observables
|
||||||
|
publishMap: Record<string, PublishStore> = {}; // anchor => PublishStore
|
||||||
|
// service
|
||||||
|
publishService;
|
||||||
|
|
||||||
|
constructor(private store: RootStore) {
|
||||||
|
makeObservable(this, {
|
||||||
|
// observables
|
||||||
|
publishMap: observable,
|
||||||
|
// actions
|
||||||
|
fetchPublishSettings: action,
|
||||||
|
});
|
||||||
|
// services
|
||||||
|
this.publishService = new PublishService();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description fetch publish settings
|
||||||
|
* @param {string} anchor
|
||||||
|
*/
|
||||||
|
fetchPublishSettings = async (anchor: string) => {
|
||||||
|
try {
|
||||||
|
const publishSettings = await this.publishService.fetchPublishSettings(anchor);
|
||||||
|
runInAction(() => {
|
||||||
|
if (publishSettings.anchor)
|
||||||
|
set(this.publishMap, [publishSettings.anchor], new PublishStore(this.store, publishSettings));
|
||||||
|
});
|
||||||
|
|
||||||
|
return publishSettings;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -3,30 +3,30 @@ import { enableStaticRendering } from "mobx-react-lite";
|
|||||||
import { IInstanceStore, InstanceStore } from "@/store/instance.store";
|
import { IInstanceStore, InstanceStore } from "@/store/instance.store";
|
||||||
import { IssueDetailStore, IIssueDetailStore } from "@/store/issue-detail.store";
|
import { IssueDetailStore, IIssueDetailStore } from "@/store/issue-detail.store";
|
||||||
import { IssueStore, IIssueStore } from "@/store/issue.store";
|
import { IssueStore, IIssueStore } from "@/store/issue.store";
|
||||||
import { IProjectStore, ProjectStore } from "@/store/project.store";
|
|
||||||
import { IUserStore, UserStore } from "@/store/user.store";
|
import { IUserStore, UserStore } from "@/store/user.store";
|
||||||
import { IssueFilterStore, IIssueFilterStore } from "./issue-filters.store";
|
import { IssueFilterStore, IIssueFilterStore } from "./issue-filters.store";
|
||||||
import { IMentionsStore, MentionsStore } from "./mentions.store";
|
import { IMentionsStore, MentionsStore } from "./mentions.store";
|
||||||
|
import { IPublishListStore, PublishListStore } from "./publish/publish_list.store";
|
||||||
|
|
||||||
enableStaticRendering(typeof window === "undefined");
|
enableStaticRendering(typeof window === "undefined");
|
||||||
|
|
||||||
export class RootStore {
|
export class RootStore {
|
||||||
instance: IInstanceStore;
|
instance: IInstanceStore;
|
||||||
user: IUserStore;
|
user: IUserStore;
|
||||||
project: IProjectStore;
|
|
||||||
issue: IIssueStore;
|
issue: IIssueStore;
|
||||||
issueDetail: IIssueDetailStore;
|
issueDetail: IIssueDetailStore;
|
||||||
mentionStore: IMentionsStore;
|
mentionStore: IMentionsStore;
|
||||||
issueFilter: IIssueFilterStore;
|
issueFilter: IIssueFilterStore;
|
||||||
|
publishList: IPublishListStore;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.instance = new InstanceStore(this);
|
this.instance = new InstanceStore(this);
|
||||||
this.user = new UserStore(this);
|
this.user = new UserStore(this);
|
||||||
this.project = new ProjectStore(this);
|
|
||||||
this.issue = new IssueStore(this);
|
this.issue = new IssueStore(this);
|
||||||
this.issueDetail = new IssueDetailStore(this);
|
this.issueDetail = new IssueDetailStore(this);
|
||||||
this.mentionStore = new MentionsStore(this);
|
this.mentionStore = new MentionsStore(this);
|
||||||
this.issueFilter = new IssueFilterStore(this);
|
this.issueFilter = new IssueFilterStore(this);
|
||||||
|
this.publishList = new PublishListStore(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
@ -40,10 +40,10 @@ export class RootStore {
|
|||||||
localStorage.setItem("theme", "system");
|
localStorage.setItem("theme", "system");
|
||||||
this.instance = new InstanceStore(this);
|
this.instance = new InstanceStore(this);
|
||||||
this.user = new UserStore(this);
|
this.user = new UserStore(this);
|
||||||
this.project = new ProjectStore(this);
|
|
||||||
this.issue = new IssueStore(this);
|
this.issue = new IssueStore(this);
|
||||||
this.issueDetail = new IssueDetailStore(this);
|
this.issueDetail = new IssueDetailStore(this);
|
||||||
this.mentionStore = new MentionsStore(this);
|
this.mentionStore = new MentionsStore(this);
|
||||||
this.issueFilter = new IssueFilterStore(this);
|
this.issueFilter = new IssueFilterStore(this);
|
||||||
|
this.publishList = new PublishListStore(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
19
space/types/publish.d.ts
vendored
Normal file
19
space/types/publish.d.ts
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { TProjectDetails, TViewDetails, TWorkspaceDetails } from "./project";
|
||||||
|
|
||||||
|
export type TPublishSettings = {
|
||||||
|
anchor: string | undefined;
|
||||||
|
comments: boolean;
|
||||||
|
created_at: string | undefined;
|
||||||
|
created_by: string | undefined;
|
||||||
|
id: string | undefined;
|
||||||
|
inbox: unknown;
|
||||||
|
project: string | undefined;
|
||||||
|
project_details: TProjectDetails | undefined;
|
||||||
|
reactions: boolean;
|
||||||
|
updated_at: string | undefined;
|
||||||
|
updated_by: string | undefined;
|
||||||
|
views: TViewDetails | undefined;
|
||||||
|
votes: boolean;
|
||||||
|
workspace: string | undefined;
|
||||||
|
workspace_detail: TWorkspaceDetails | undefined;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user