fix: handled default view on plane deploy (#1893)

* fix: handled default view on plane deploy

* fix: handled default view on refresh
This commit is contained in:
guru_sainath 2023-08-17 14:24:33 +05:30 committed by GitHub
parent 0afd72db95
commit abb8782c44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 12 deletions

View File

@ -29,15 +29,41 @@ const WorkspaceProjectPage = observer(() => {
// updating default board view when we are in the issues page // updating default board view when we are in the issues page
useEffect(() => { useEffect(() => {
if (workspace_slug && project_slug) { if (workspace_slug && project_slug && store?.project?.workspaceProjectSettings) {
if (!board) { const workspacePRojectSettingViews = store?.project?.workspaceProjectSettings?.views;
store.issue.setCurrentIssueBoardView("list"); const userAccessViews: TIssueBoardKeys[] = [];
router.replace(`/${workspace_slug}/${project_slug}?board=${store?.issue?.currentIssueBoardView}`);
} else { Object.keys(workspacePRojectSettingViews).filter((_key) => {
if (board != store?.issue?.currentIssueBoardView) store.issue.setCurrentIssueBoardView(board); 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);
});
if (userAccessViews && userAccessViews.length > 0) {
if (!board) {
store.issue.setCurrentIssueBoardView(userAccessViews[0]);
router.replace(`/${workspace_slug}/${project_slug}?board=${userAccessViews[0]}`);
} else {
if (userAccessViews.includes(board)) {
if (store.issue.currentIssueBoardView === null) store.issue.setCurrentIssueBoardView(board);
else {
if (board === store.issue.currentIssueBoardView)
router.replace(`/${workspace_slug}/${project_slug}?board=${board}`);
else {
store.issue.setCurrentIssueBoardView(board);
router.replace(`/${workspace_slug}/${project_slug}?board=${board}`);
}
}
} else {
store.issue.setCurrentIssueBoardView(userAccessViews[0]);
router.replace(`/${workspace_slug}/${project_slug}?board=${userAccessViews[0]}`);
}
}
} }
} }
}, [workspace_slug, project_slug, board, router, store?.issue]); }, [workspace_slug, project_slug, board, router, store?.issue, store?.project?.workspaceProjectSettings]);
useEffect(() => { useEffect(() => {
if (workspace_slug && project_slug) { if (workspace_slug && project_slug) {

View File

@ -24,11 +24,6 @@ const MobxStoreInit = () => {
else localStorage.setItem("app_theme", _theme && _theme != "light" ? "dark" : "light"); else localStorage.setItem("app_theme", _theme && _theme != "light" ? "dark" : "light");
}, [store?.theme]); }, [store?.theme]);
// updating default board view when we are in the issues page
useEffect(() => {
if (board && board != store?.issue?.currentIssueBoardView) store.issue.setCurrentIssueBoardView(board);
}, [board, store?.issue]);
return <></>; return <></>;
}; };