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();
|
const { project: projectStore }: RootStore = useMobxStore();
|
||||||
// router
|
// router
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspace_slug, project_slug } = router.query;
|
const { workspace_slug, project_slug, board } = router.query;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (workspace_slug && project_slug) {
|
if (workspace_slug && project_slug) {
|
||||||
@ -36,6 +36,16 @@ const IssueNavbar = observer(() => {
|
|||||||
}
|
}
|
||||||
}, [projectStore, workspace_slug, project_slug]);
|
}, [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 (
|
return (
|
||||||
<div className="px-5 relative w-full flex items-center gap-4">
|
<div className="px-5 relative w-full flex items-center gap-4">
|
||||||
{/* project detail */}
|
{/* project detail */}
|
||||||
|
@ -9,25 +9,25 @@ import { useMobxStore } from "lib/mobx/store-provider";
|
|||||||
import { RootStore } from "store/root";
|
import { RootStore } from "store/root";
|
||||||
|
|
||||||
export const NavbarIssueBoardView = observer(() => {
|
export const NavbarIssueBoardView = observer(() => {
|
||||||
const store: RootStore = useMobxStore();
|
const { project: projectStore, issue: issueStore }: RootStore = useMobxStore();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspace_slug, project_slug } = router.query as { workspace_slug: string; project_slug: string };
|
const { workspace_slug, project_slug } = router.query as { workspace_slug: string; project_slug: string };
|
||||||
|
|
||||||
const handleCurrentBoardView = (boardView: TIssueBoardKeys) => {
|
const handleCurrentBoardView = (boardView: string) => {
|
||||||
store?.issue?.setCurrentIssueBoardView(boardView);
|
projectStore.setActiveBoard(boardView);
|
||||||
router.replace(
|
router.replace(
|
||||||
`/${workspace_slug}/${project_slug}?board=${boardView}${
|
`/${workspace_slug}/${project_slug}?board=${boardView}${
|
||||||
store?.issue?.userSelectedLabels && store?.issue?.userSelectedLabels.length > 0
|
issueStore?.userSelectedLabels && issueStore?.userSelectedLabels.length > 0
|
||||||
? `&labels=${store?.issue?.userSelectedLabels.join(",")}`
|
? `&labels=${issueStore?.userSelectedLabels.join(",")}`
|
||||||
: ""
|
: ""
|
||||||
}${
|
}${
|
||||||
store?.issue?.userSelectedPriorities && store?.issue?.userSelectedPriorities.length > 0
|
issueStore?.userSelectedPriorities && issueStore?.userSelectedPriorities.length > 0
|
||||||
? `&priorities=${store?.issue?.userSelectedPriorities.join(",")}`
|
? `&priorities=${issueStore?.userSelectedPriorities.join(",")}`
|
||||||
: ""
|
: ""
|
||||||
}${
|
}${
|
||||||
store?.issue?.userSelectedStates && store?.issue?.userSelectedStates.length > 0
|
issueStore?.userSelectedStates && issueStore?.userSelectedStates.length > 0
|
||||||
? `&states=${store?.issue?.userSelectedStates.join(",")}`
|
? `&states=${issueStore?.userSelectedStates.join(",")}`
|
||||||
: ""
|
: ""
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
@ -35,28 +35,33 @@ export const NavbarIssueBoardView = observer(() => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{store?.project?.workspaceProjectSettings &&
|
{projectStore?.viewOptions &&
|
||||||
issueViews &&
|
Object.keys(projectStore?.viewOptions).map((viewKey: string) => {
|
||||||
issueViews.length > 0 &&
|
console.log("projectStore?.activeBoard", projectStore?.activeBoard);
|
||||||
issueViews.map(
|
console.log("viewKey", viewKey);
|
||||||
(_view) =>
|
if (projectStore?.viewOptions[viewKey]) {
|
||||||
store?.project?.workspaceProjectSettings?.views[_view?.key] && (
|
return (
|
||||||
<div
|
<div
|
||||||
key={_view?.key}
|
key={viewKey}
|
||||||
className={`w-[28px] h-[28px] flex justify-center items-center rounded-sm cursor-pointer ${
|
className={`w-[28px] h-[28px] flex justify-center items-center rounded-sm cursor-pointer ${
|
||||||
_view?.key === store?.issue?.currentIssueBoardView
|
viewKey === projectStore?.activeBoard
|
||||||
? `bg-custom-background-200 text-custom-text-200`
|
? `bg-custom-background-80 text-custom-text-200`
|
||||||
: `hover:bg-custom-background-200 text-custom-text-300`
|
: `hover:bg-custom-background-80 text-custom-text-300`
|
||||||
}`}
|
}`}
|
||||||
onClick={() => handleCurrentBoardView(_view?.key)}
|
onClick={() => handleCurrentBoardView(viewKey)}
|
||||||
title={_view?.title}
|
title={viewKey}
|
||||||
>
|
>
|
||||||
<span className={`material-symbols-rounded text-[18px] ${_view?.className ? _view?.className : ``}`}>
|
<span
|
||||||
{_view?.icon}
|
className={`material-symbols-rounded text-[18px] ${
|
||||||
|
issueViews[viewKey]?.className ? issueViews[viewKey]?.className : ``
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{issueViews[viewKey]?.icon}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
)}
|
}
|
||||||
|
})}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -18,38 +18,18 @@ import {
|
|||||||
} from "components/icons";
|
} from "components/icons";
|
||||||
|
|
||||||
// all issue views
|
// all issue views
|
||||||
export const issueViews: IIssueBoardViews[] = [
|
export const issueViews: any = {
|
||||||
{
|
list: {
|
||||||
key: "list",
|
|
||||||
title: "List View",
|
title: "List View",
|
||||||
icon: "format_list_bulleted",
|
icon: "format_list_bulleted",
|
||||||
className: "",
|
className: "",
|
||||||
},
|
},
|
||||||
{
|
kanban: {
|
||||||
key: "kanban",
|
|
||||||
title: "Board View",
|
title: "Board View",
|
||||||
icon: "grid_view",
|
icon: "grid_view",
|
||||||
className: "",
|
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
|
// issue priority filters
|
||||||
export const issuePriorityFilters: IIssuePriorityFilters[] = [
|
export const issuePriorityFilters: IIssuePriorityFilters[] = [
|
||||||
|
@ -12,7 +12,9 @@ export interface IProjectStore {
|
|||||||
project: IProject | null;
|
project: IProject | null;
|
||||||
projectDeploySettings: IProjectSettings | null;
|
projectDeploySettings: IProjectSettings | null;
|
||||||
viewOptions: any;
|
viewOptions: any;
|
||||||
|
activeBoard: string | null;
|
||||||
fetchProjectSettings: (workspace_slug: string, project_slug: string) => Promise<void>;
|
fetchProjectSettings: (workspace_slug: string, project_slug: string) => Promise<void>;
|
||||||
|
setActiveBoard: (value: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProjectStore implements IProjectStore {
|
class ProjectStore implements IProjectStore {
|
||||||
@ -23,6 +25,7 @@ class ProjectStore implements IProjectStore {
|
|||||||
project: IProject | null = null;
|
project: IProject | null = null;
|
||||||
projectDeploySettings: IProjectSettings | null = null;
|
projectDeploySettings: IProjectSettings | null = null;
|
||||||
viewOptions: any = null;
|
viewOptions: any = null;
|
||||||
|
activeBoard: string | null = null;
|
||||||
// root store
|
// root store
|
||||||
rootStore;
|
rootStore;
|
||||||
// service
|
// service
|
||||||
@ -38,8 +41,10 @@ class ProjectStore implements IProjectStore {
|
|||||||
project: observable.ref,
|
project: observable.ref,
|
||||||
projectDeploySettings: observable.ref,
|
projectDeploySettings: observable.ref,
|
||||||
viewOptions: observable.ref,
|
viewOptions: observable.ref,
|
||||||
|
activeBoard: observable.ref,
|
||||||
// actions
|
// actions
|
||||||
fetchProjectSettings: action,
|
fetchProjectSettings: action,
|
||||||
|
setActiveBoard: action,
|
||||||
// computed
|
// computed
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,6 +77,10 @@ class ProjectStore implements IProjectStore {
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setActiveBoard = (boardValue: string) => {
|
||||||
|
this.activeBoard = boardValue;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ProjectStore;
|
export default ProjectStore;
|
||||||
|
Loading…
Reference in New Issue
Block a user