mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: repeatative api calls removed
This commit is contained in:
parent
d7c27b75fa
commit
0deed77f1d
@ -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 (
|
||||
<div className="px-5 relative w-full flex items-center gap-4">
|
||||
{/* project detail */}
|
||||
|
@ -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 (
|
||||
<div
|
||||
key={_view?.key}
|
||||
key={viewKey}
|
||||
className={`w-[28px] h-[28px] flex justify-center items-center rounded-sm cursor-pointer ${
|
||||
_view?.key === store?.issue?.currentIssueBoardView
|
||||
? `bg-custom-background-200 text-custom-text-200`
|
||||
: `hover:bg-custom-background-200 text-custom-text-300`
|
||||
viewKey === projectStore?.activeBoard
|
||||
? `bg-custom-background-80 text-custom-text-200`
|
||||
: `hover:bg-custom-background-80 text-custom-text-300`
|
||||
}`}
|
||||
onClick={() => handleCurrentBoardView(_view?.key)}
|
||||
title={_view?.title}
|
||||
onClick={() => handleCurrentBoardView(viewKey)}
|
||||
title={viewKey}
|
||||
>
|
||||
<span className={`material-symbols-rounded text-[18px] ${_view?.className ? _view?.className : ``}`}>
|
||||
{_view?.icon}
|
||||
<span
|
||||
className={`material-symbols-rounded text-[18px] ${
|
||||
issueViews[viewKey]?.className ? issueViews[viewKey]?.className : ``
|
||||
}`}
|
||||
>
|
||||
{issueViews[viewKey]?.icon}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
);
|
||||
}
|
||||
})}
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
@ -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[] = [
|
||||
|
@ -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<void>;
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user