2023-08-30 11:21:13 +00:00
|
|
|
import { useEffect } from "react";
|
|
|
|
import type { GetServerSideProps } from "next";
|
2023-08-30 08:11:25 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-08-30 11:21:13 +00:00
|
|
|
import Head from "next/head";
|
2023-08-11 11:48:33 +00:00
|
|
|
// types
|
2023-08-30 15:03:21 +00:00
|
|
|
import { TIssueBoardKeys } from "types";
|
2023-08-30 08:11:25 +00:00
|
|
|
import ProjectLayout from "layouts/project-layout";
|
2023-08-30 11:21:13 +00:00
|
|
|
import { ProjectDetailsView } from "components/views/project-details";
|
2023-08-11 11:48:33 +00:00
|
|
|
|
2023-08-30 11:21:13 +00:00
|
|
|
const WorkspaceProjectPage = (props: any) => {
|
|
|
|
console.log("props", props);
|
|
|
|
const SITE_TITLE = props?.project_settings?.project_details?.name || "Plane | Deploy";
|
2023-08-11 11:48:33 +00:00
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
2023-08-30 11:21:13 +00:00
|
|
|
// const activeIssueId = store.issue.activePeekOverviewIssueId;
|
2023-08-30 07:19:15 +00:00
|
|
|
|
2023-08-30 08:11:25 +00:00
|
|
|
const { workspace_slug, project_slug, board, states, labels, priorities } = router.query as {
|
|
|
|
workspace_slug: string;
|
|
|
|
project_slug: string;
|
|
|
|
board: TIssueBoardKeys;
|
|
|
|
states: string[];
|
|
|
|
labels: string[];
|
|
|
|
priorities: string[];
|
|
|
|
};
|
2023-08-30 07:19:15 +00:00
|
|
|
|
2023-08-11 11:48:33 +00:00
|
|
|
// updating default board view when we are in the issues page
|
2023-08-30 11:21:13 +00:00
|
|
|
// useEffect(() => {
|
|
|
|
// if (workspace_slug && project_slug && store?.project?.workspaceProjectSettings) {
|
|
|
|
// const workspaceProjectSettingViews = store?.project?.workspaceProjectSettings?.views;
|
|
|
|
// const userAccessViews: TIssueBoardKeys[] = [];
|
|
|
|
|
|
|
|
// Object.keys(workspaceProjectSettingViews).filter((_key) => {
|
|
|
|
// if (_key === "list" && workspaceProjectSettingViews.list === true) userAccessViews.push(_key);
|
|
|
|
// if (_key === "kanban" && workspaceProjectSettingViews.kanban === true) userAccessViews.push(_key);
|
|
|
|
// if (_key === "calendar" && workspaceProjectSettingViews.calendar === true) userAccessViews.push(_key);
|
|
|
|
// if (_key === "spreadsheet" && workspaceProjectSettingViews.spreadsheet === true) userAccessViews.push(_key);
|
|
|
|
// if (_key === "gantt" && workspaceProjectSettingViews.gantt === true) userAccessViews.push(_key);
|
|
|
|
// });
|
|
|
|
|
|
|
|
// let url = `/${workspace_slug}/${project_slug}`;
|
|
|
|
// let _board = board;
|
|
|
|
|
|
|
|
// if (userAccessViews && userAccessViews.length > 0) {
|
|
|
|
// if (!board) {
|
|
|
|
// store.issue.setCurrentIssueBoardView(userAccessViews[0]);
|
|
|
|
// _board = userAccessViews[0];
|
|
|
|
// } else {
|
|
|
|
// if (userAccessViews.includes(board)) {
|
|
|
|
// if (store.issue.currentIssueBoardView === null) store.issue.setCurrentIssueBoardView(board);
|
|
|
|
// else {
|
|
|
|
// if (board === store.issue.currentIssueBoardView) {
|
|
|
|
// _board = board;
|
|
|
|
// } else {
|
|
|
|
// _board = board;
|
|
|
|
// store.issue.setCurrentIssueBoardView(board);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// store.issue.setCurrentIssueBoardView(userAccessViews[0]);
|
|
|
|
// _board = userAccessViews[0];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// _board = _board || "list";
|
|
|
|
// url = `${url}?board=${_board}`;
|
|
|
|
|
|
|
|
// if (states) url = `${url}&states=${states}`;
|
|
|
|
// if (labels) url = `${url}&labels=${labels}`;
|
|
|
|
// if (priorities) url = `${url}&priorities=${priorities}`;
|
|
|
|
|
|
|
|
// url = decodeURIComponent(url);
|
|
|
|
|
|
|
|
// router.replace(url);
|
|
|
|
// }
|
|
|
|
// }, [
|
|
|
|
// workspace_slug,
|
|
|
|
// project_slug,
|
|
|
|
// board,
|
|
|
|
// router,
|
|
|
|
// store?.issue,
|
|
|
|
// store?.project?.workspaceProjectSettings,
|
|
|
|
// states,
|
|
|
|
// labels,
|
|
|
|
// priorities,
|
|
|
|
// ]);
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
|
|
// if (!workspace_slug || !project_slug) return;
|
|
|
|
|
|
|
|
// const params = {
|
|
|
|
// state: states || null,
|
|
|
|
// labels: labels || null,
|
|
|
|
// priority: priorities || null,
|
|
|
|
// };
|
|
|
|
|
|
|
|
// store?.project?.getProjectSettingsAsync(workspace_slug, project_slug);
|
|
|
|
// store?.issue?.getIssuesAsync(workspace_slug, project_slug, params);
|
|
|
|
// }, [workspace_slug, project_slug, store?.project, store?.issue, states, labels, priorities]);
|
2023-08-11 11:48:33 +00:00
|
|
|
|
|
|
|
return (
|
2023-08-30 08:11:25 +00:00
|
|
|
<ProjectLayout>
|
2023-08-30 11:21:13 +00:00
|
|
|
<Head>
|
|
|
|
<title>{SITE_TITLE}</title>
|
|
|
|
</Head>
|
|
|
|
<ProjectDetailsView />
|
2023-08-30 08:11:25 +00:00
|
|
|
</ProjectLayout>
|
2023-08-11 11:48:33 +00:00
|
|
|
);
|
2023-08-30 07:19:15 +00:00
|
|
|
};
|
2023-08-11 11:48:33 +00:00
|
|
|
|
2023-08-30 12:09:11 +00:00
|
|
|
// export const getServerSideProps: GetServerSideProps<any> = async ({ query: { workspace_slug, project_slug } }) => {
|
|
|
|
// const res = await fetch(
|
|
|
|
// `${process.env.NEXT_PUBLIC_API_BASE_URL}/api/public/workspaces/${workspace_slug}/project-boards/${project_slug}/settings/`
|
|
|
|
// );
|
|
|
|
// const project_settings = await res.json();
|
|
|
|
// return { props: { project_settings } };
|
|
|
|
// };
|
2023-08-30 11:21:13 +00:00
|
|
|
|
|
|
|
export default WorkspaceProjectPage;
|