diff --git a/apps/space/components/issues/navbar/index.tsx b/apps/space/components/issues/navbar/index.tsx
index d17827cea..39c33c2fd 100644
--- a/apps/space/components/issues/navbar/index.tsx
+++ b/apps/space/components/issues/navbar/index.tsx
@@ -28,7 +28,7 @@ const IssueNavbar = observer(() => {
const { project: projectStore }: RootStore = useMobxStore();
// router
const router = useRouter();
- const { workspace_slug, project_slug } = router.query;
+ const { workspace_slug, project_slug, board } = router.query;
useEffect(() => {
if (workspace_slug && project_slug) {
@@ -36,6 +36,16 @@ const IssueNavbar = observer(() => {
}
}, [projectStore, workspace_slug, project_slug]);
+ useEffect(() => {
+ if (workspace_slug && projectStore) {
+ if (board) {
+ projectStore.setActiveBoard(board.toString());
+ } else {
+ router.push(`/${workspace_slug}/${project_slug}?board=list`);
+ }
+ }
+ }, [board, router, projectStore, workspace_slug, project_slug]);
+
return (
{/* project detail */}
diff --git a/apps/space/components/issues/navbar/issue-board-view.tsx b/apps/space/components/issues/navbar/issue-board-view.tsx
index 0f4dc4b40..28d3a95e8 100644
--- a/apps/space/components/issues/navbar/issue-board-view.tsx
+++ b/apps/space/components/issues/navbar/issue-board-view.tsx
@@ -9,25 +9,25 @@ import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root";
export const NavbarIssueBoardView = observer(() => {
- const store: RootStore = useMobxStore();
+ const { project: projectStore, issue: issueStore }: RootStore = useMobxStore();
const router = useRouter();
const { workspace_slug, project_slug } = router.query as { workspace_slug: string; project_slug: string };
- const handleCurrentBoardView = (boardView: TIssueBoardKeys) => {
- store?.issue?.setCurrentIssueBoardView(boardView);
+ const handleCurrentBoardView = (boardView: string) => {
+ projectStore.setActiveBoard(boardView);
router.replace(
`/${workspace_slug}/${project_slug}?board=${boardView}${
- store?.issue?.userSelectedLabels && store?.issue?.userSelectedLabels.length > 0
- ? `&labels=${store?.issue?.userSelectedLabels.join(",")}`
+ issueStore?.userSelectedLabels && issueStore?.userSelectedLabels.length > 0
+ ? `&labels=${issueStore?.userSelectedLabels.join(",")}`
: ""
}${
- store?.issue?.userSelectedPriorities && store?.issue?.userSelectedPriorities.length > 0
- ? `&priorities=${store?.issue?.userSelectedPriorities.join(",")}`
+ issueStore?.userSelectedPriorities && issueStore?.userSelectedPriorities.length > 0
+ ? `&priorities=${issueStore?.userSelectedPriorities.join(",")}`
: ""
}${
- store?.issue?.userSelectedStates && store?.issue?.userSelectedStates.length > 0
- ? `&states=${store?.issue?.userSelectedStates.join(",")}`
+ issueStore?.userSelectedStates && issueStore?.userSelectedStates.length > 0
+ ? `&states=${issueStore?.userSelectedStates.join(",")}`
: ""
}`
);
@@ -35,28 +35,33 @@ export const NavbarIssueBoardView = observer(() => {
return (
<>
- {store?.project?.workspaceProjectSettings &&
- issueViews &&
- issueViews.length > 0 &&
- issueViews.map(
- (_view) =>
- store?.project?.workspaceProjectSettings?.views[_view?.key] && (
+ {projectStore?.viewOptions &&
+ Object.keys(projectStore?.viewOptions).map((viewKey: string) => {
+ console.log("projectStore?.activeBoard", projectStore?.activeBoard);
+ console.log("viewKey", viewKey);
+ if (projectStore?.viewOptions[viewKey]) {
+ return (
handleCurrentBoardView(_view?.key)}
- title={_view?.title}
+ onClick={() => handleCurrentBoardView(viewKey)}
+ title={viewKey}
>
-
- {_view?.icon}
+
+ {issueViews[viewKey]?.icon}
- )
- )}
+ );
+ }
+ })}
>
);
});
diff --git a/apps/space/constants/data.ts b/apps/space/constants/data.ts
index e6e51da49..3018a93a7 100644
--- a/apps/space/constants/data.ts
+++ b/apps/space/constants/data.ts
@@ -18,38 +18,18 @@ import {
} from "components/icons";
// all issue views
-export const issueViews: IIssueBoardViews[] = [
- {
- key: "list",
+export const issueViews: any = {
+ list: {
title: "List View",
icon: "format_list_bulleted",
className: "",
},
- {
- key: "kanban",
+ kanban: {
title: "Board View",
icon: "grid_view",
className: "",
},
- // {
- // key: "calendar",
- // title: "Calendar View",
- // icon: "calendar_month",
- // className: "",
- // },
- // {
- // key: "spreadsheet",
- // title: "Spreadsheet View",
- // icon: "table_chart",
- // className: "",
- // },
- // {
- // key: "gantt",
- // title: "Gantt Chart View",
- // icon: "waterfall_chart",
- // className: "rotate-90",
- // },
-];
+};
// issue priority filters
export const issuePriorityFilters: IIssuePriorityFilters[] = [
diff --git a/apps/space/store/project.ts b/apps/space/store/project.ts
index 04babefe0..c0e943189 100644
--- a/apps/space/store/project.ts
+++ b/apps/space/store/project.ts
@@ -12,7 +12,9 @@ export interface IProjectStore {
project: IProject | null;
projectDeploySettings: IProjectSettings | null;
viewOptions: any;
+ activeBoard: string | null;
fetchProjectSettings: (workspace_slug: string, project_slug: string) => Promise
;
+ setActiveBoard: (value: string) => void;
}
class ProjectStore implements IProjectStore {
@@ -23,6 +25,7 @@ class ProjectStore implements IProjectStore {
project: IProject | null = null;
projectDeploySettings: IProjectSettings | null = null;
viewOptions: any = null;
+ activeBoard: string | null = null;
// root store
rootStore;
// service
@@ -38,8 +41,10 @@ class ProjectStore implements IProjectStore {
project: observable.ref,
projectDeploySettings: observable.ref,
viewOptions: observable.ref,
+ activeBoard: observable.ref,
// actions
fetchProjectSettings: action,
+ setActiveBoard: action,
// computed
});
@@ -72,6 +77,10 @@ class ProjectStore implements IProjectStore {
return error;
}
};
+
+ setActiveBoard = (boardValue: string) => {
+ this.activeBoard = boardValue;
+ };
}
export default ProjectStore;