2023-10-20 11:37:46 +00:00
|
|
|
import { useRouter } from "next/router";
|
2023-10-17 10:53:54 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2023-10-20 11:37:46 +00:00
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-10-17 10:53:54 +00:00
|
|
|
// components
|
2023-10-20 11:37:46 +00:00
|
|
|
import { ProjectIssueQuickActions } from "components/issues";
|
|
|
|
// types
|
|
|
|
import { IIssue } from "types";
|
2023-11-27 08:45:33 +00:00
|
|
|
// constants
|
2023-11-23 09:17:04 +00:00
|
|
|
import { EIssueActions } from "../../types";
|
2023-11-27 08:45:33 +00:00
|
|
|
import { BaseKanBanRoot } from "../base-kanban-root";
|
|
|
|
import { EProjectStore } from "store/command-palette.store";
|
2023-12-07 14:16:57 +00:00
|
|
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
2023-10-17 10:53:54 +00:00
|
|
|
|
2023-11-27 08:45:33 +00:00
|
|
|
export const ProfileIssuesKanBanLayout: React.FC = observer(() => {
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, userId } = router.query as { workspaceSlug: string; userId: string };
|
2023-10-17 10:53:54 +00:00
|
|
|
|
|
|
|
const {
|
2023-11-27 08:45:33 +00:00
|
|
|
workspaceProfileIssues: profileIssuesStore,
|
|
|
|
workspaceProfileIssuesFilter: profileIssueFiltersStore,
|
2023-12-07 14:16:57 +00:00
|
|
|
workspaceMember: { currentWorkspaceUserProjectsRole },
|
2023-10-17 10:53:54 +00:00
|
|
|
issueKanBanView: issueKanBanViewStore,
|
2023-10-20 11:37:46 +00:00
|
|
|
} = useMobxStore();
|
|
|
|
|
2023-11-27 08:45:33 +00:00
|
|
|
const issueActions = {
|
|
|
|
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !userId) return;
|
2023-10-17 10:53:54 +00:00
|
|
|
|
2023-11-27 08:45:33 +00:00
|
|
|
await profileIssuesStore.updateIssue(workspaceSlug, userId, issue.id, issue);
|
2023-10-20 11:37:46 +00:00
|
|
|
},
|
2023-11-27 08:45:33 +00:00
|
|
|
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
|
|
|
if (!workspaceSlug || !userId) return;
|
2023-10-17 10:53:54 +00:00
|
|
|
|
2023-11-29 14:28:27 +00:00
|
|
|
await profileIssuesStore.removeIssue(workspaceSlug, issue.project, issue.id, userId);
|
2023-11-27 08:45:33 +00:00
|
|
|
},
|
2023-10-17 10:53:54 +00:00
|
|
|
};
|
|
|
|
|
2023-12-07 14:16:57 +00:00
|
|
|
const canEditPropertiesBasedOnProject = (projectId: string) => {
|
|
|
|
const currentProjectRole = currentWorkspaceUserProjectsRole && currentWorkspaceUserProjectsRole[projectId];
|
|
|
|
|
|
|
|
return !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
|
|
|
};
|
|
|
|
|
2023-10-17 10:53:54 +00:00
|
|
|
return (
|
2023-11-27 08:45:33 +00:00
|
|
|
<BaseKanBanRoot
|
|
|
|
issueActions={issueActions}
|
|
|
|
issuesFilterStore={profileIssueFiltersStore}
|
|
|
|
issueStore={profileIssuesStore}
|
|
|
|
kanbanViewStore={issueKanBanViewStore}
|
|
|
|
showLoader={true}
|
|
|
|
QuickActions={ProjectIssueQuickActions}
|
|
|
|
currentStore={EProjectStore.PROFILE}
|
2023-12-07 14:16:57 +00:00
|
|
|
canEditPropertiesBasedOnProject={canEditPropertiesBasedOnProject}
|
2023-11-27 08:45:33 +00:00
|
|
|
/>
|
2023-10-17 10:53:54 +00:00
|
|
|
);
|
|
|
|
});
|