2023-11-23 09:17:04 +00:00
|
|
|
import { List } from "./default";
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
import { ISSUE_PRIORITIES, ISSUE_STATE_GROUPS } from "constants/issue";
|
|
|
|
import { FC } from "react";
|
|
|
|
import { IIssue, IProject } from "types";
|
|
|
|
import { IProjectStore } from "store/project";
|
|
|
|
import { Spinner } from "@plane/ui";
|
|
|
|
import { IQuickActionProps } from "./list-view-types";
|
|
|
|
import {
|
|
|
|
ICycleIssuesFilterStore,
|
|
|
|
ICycleIssuesStore,
|
|
|
|
IModuleIssuesFilterStore,
|
|
|
|
IModuleIssuesStore,
|
2023-11-27 08:45:33 +00:00
|
|
|
IProfileIssuesFilterStore,
|
|
|
|
IProfileIssuesStore,
|
|
|
|
IProjectArchivedIssuesStore,
|
|
|
|
IProjectDraftIssuesStore,
|
2023-11-23 09:17:04 +00:00
|
|
|
IProjectIssuesFilterStore,
|
|
|
|
IProjectIssuesStore,
|
|
|
|
IViewIssuesFilterStore,
|
|
|
|
IViewIssuesStore,
|
|
|
|
} from "store/issues";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
import { IIssueResponse } from "store/issues/types";
|
2023-11-27 08:45:33 +00:00
|
|
|
import { EProjectStore } from "store/command-palette.store";
|
2023-11-29 08:55:57 +00:00
|
|
|
import { IssuePeekOverview } from "components/issues";
|
|
|
|
import { useRouter } from "next/router";
|
2023-12-04 14:33:23 +00:00
|
|
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
2023-11-23 09:17:04 +00:00
|
|
|
|
|
|
|
enum EIssueActions {
|
|
|
|
UPDATE = "update",
|
|
|
|
DELETE = "delete",
|
|
|
|
REMOVE = "remove",
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IBaseListRoot {
|
|
|
|
issueFilterStore:
|
|
|
|
| IProjectIssuesFilterStore
|
|
|
|
| IModuleIssuesFilterStore
|
|
|
|
| ICycleIssuesFilterStore
|
2023-11-27 08:45:33 +00:00
|
|
|
| IViewIssuesFilterStore
|
|
|
|
| IProfileIssuesFilterStore;
|
|
|
|
issueStore:
|
|
|
|
| IProjectIssuesStore
|
|
|
|
| IModuleIssuesStore
|
|
|
|
| ICycleIssuesStore
|
|
|
|
| IViewIssuesStore
|
|
|
|
| IProjectArchivedIssuesStore
|
|
|
|
| IProjectDraftIssuesStore
|
|
|
|
| IProfileIssuesStore;
|
2023-11-23 09:17:04 +00:00
|
|
|
QuickActions: FC<IQuickActionProps>;
|
|
|
|
issueActions: {
|
2023-12-07 12:43:27 +00:00
|
|
|
[EIssueActions.DELETE]: (group_by: string | null, issue: IIssue) => Promise<void>;
|
|
|
|
[EIssueActions.UPDATE]?: (group_by: string | null, issue: IIssue) => Promise<void>;
|
|
|
|
[EIssueActions.REMOVE]?: (group_by: string | null, issue: IIssue) => Promise<void>;
|
2023-11-23 09:17:04 +00:00
|
|
|
};
|
|
|
|
getProjects: (projectStore: IProjectStore) => IProject[] | null;
|
|
|
|
viewId?: string;
|
2023-11-27 08:45:33 +00:00
|
|
|
currentStore: EProjectStore;
|
2023-11-28 09:20:37 +00:00
|
|
|
addIssuesToView?: (issueIds: string[]) => Promise<IIssue>;
|
2023-12-07 14:16:57 +00:00
|
|
|
canEditPropertiesBasedOnProject?: (projectId: string) => boolean;
|
2023-11-23 09:17:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const BaseListRoot = observer((props: IBaseListRoot) => {
|
2023-11-28 09:20:37 +00:00
|
|
|
const {
|
|
|
|
issueFilterStore,
|
|
|
|
issueStore,
|
|
|
|
QuickActions,
|
|
|
|
issueActions,
|
|
|
|
getProjects,
|
|
|
|
viewId,
|
|
|
|
currentStore,
|
|
|
|
addIssuesToView,
|
2023-12-07 14:16:57 +00:00
|
|
|
canEditPropertiesBasedOnProject,
|
2023-11-28 09:20:37 +00:00
|
|
|
} = props;
|
2023-11-29 08:55:57 +00:00
|
|
|
// router
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug, peekIssueId, peekProjectId } = router.query;
|
|
|
|
// mobx store
|
2023-11-23 09:17:04 +00:00
|
|
|
const {
|
|
|
|
project: projectStore,
|
|
|
|
projectMember: { projectMembers },
|
|
|
|
projectState: projectStateStore,
|
|
|
|
projectLabel: { projectLabels },
|
2023-11-29 14:28:27 +00:00
|
|
|
user: userStore,
|
2023-11-23 09:17:04 +00:00
|
|
|
} = useMobxStore();
|
|
|
|
|
2023-11-29 14:28:27 +00:00
|
|
|
const { currentProjectRole } = userStore;
|
2023-12-04 14:33:23 +00:00
|
|
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
2023-11-29 14:28:27 +00:00
|
|
|
|
2023-11-27 08:45:33 +00:00
|
|
|
const issueIds = issueStore?.getIssuesIds || [];
|
|
|
|
const issues = issueStore?.getIssues;
|
|
|
|
|
|
|
|
const { enableInlineEditing, enableQuickAdd, enableIssueCreation } = issueStore?.viewFlags || {};
|
2023-12-07 14:16:57 +00:00
|
|
|
const canEditProperties = (projectId: string | undefined) => {
|
|
|
|
const isEditingAllowedBasedOnProject =
|
|
|
|
canEditPropertiesBasedOnProject && projectId ? canEditPropertiesBasedOnProject(projectId) : isEditingAllowed;
|
|
|
|
|
|
|
|
return enableInlineEditing && isEditingAllowedBasedOnProject;
|
|
|
|
};
|
2023-11-23 09:17:04 +00:00
|
|
|
|
|
|
|
const displayFilters = issueFilterStore?.issueFilters?.displayFilters;
|
|
|
|
const group_by = displayFilters?.group_by || null;
|
|
|
|
const showEmptyGroup = displayFilters?.show_empty_groups ?? false;
|
|
|
|
|
|
|
|
const displayProperties = issueFilterStore?.issueFilters?.displayProperties;
|
|
|
|
|
|
|
|
const states = projectStateStore?.projectStates;
|
|
|
|
const priorities = ISSUE_PRIORITIES;
|
|
|
|
const labels = projectLabels;
|
|
|
|
const stateGroups = ISSUE_STATE_GROUPS;
|
|
|
|
const projects = getProjects(projectStore);
|
|
|
|
const members = projectMembers?.map((m) => m.member) ?? null;
|
|
|
|
const handleIssues = async (issue: IIssue, action: EIssueActions) => {
|
|
|
|
if (issueActions[action]) {
|
2023-12-07 12:43:27 +00:00
|
|
|
await issueActions[action]!(group_by, issue);
|
2023-11-23 09:17:04 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2023-11-27 08:45:33 +00:00
|
|
|
{issueStore?.loader === "init-loader" ? (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="flex h-full w-full items-center justify-center">
|
2023-11-23 09:17:04 +00:00
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
) : (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className={`relative h-full w-full bg-custom-background-90`}>
|
2023-11-23 09:17:04 +00:00
|
|
|
<List
|
|
|
|
issues={issues as unknown as IIssueResponse}
|
|
|
|
group_by={group_by}
|
|
|
|
handleIssues={handleIssues}
|
|
|
|
quickActions={(group_by, issue) => (
|
|
|
|
<QuickActions
|
|
|
|
issue={issue}
|
|
|
|
handleDelete={async () => handleIssues(issue, EIssueActions.DELETE)}
|
|
|
|
handleUpdate={
|
|
|
|
issueActions[EIssueActions.UPDATE]
|
|
|
|
? async (data) => handleIssues(data, EIssueActions.UPDATE)
|
|
|
|
: undefined
|
|
|
|
}
|
|
|
|
handleRemoveFromView={
|
|
|
|
issueActions[EIssueActions.REMOVE] ? async () => handleIssues(issue, EIssueActions.REMOVE) : undefined
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
displayProperties={displayProperties}
|
|
|
|
states={states}
|
|
|
|
stateGroups={stateGroups}
|
|
|
|
priorities={priorities}
|
|
|
|
labels={labels}
|
|
|
|
members={members}
|
|
|
|
projects={projects}
|
|
|
|
issueIds={issueIds}
|
|
|
|
showEmptyGroup={showEmptyGroup}
|
|
|
|
viewId={viewId}
|
2023-11-27 08:45:33 +00:00
|
|
|
quickAddCallback={issueStore?.quickAddIssue}
|
|
|
|
enableIssueQuickAdd={!!enableQuickAdd}
|
2023-12-07 14:16:57 +00:00
|
|
|
canEditProperties={canEditProperties}
|
2023-12-05 08:11:31 +00:00
|
|
|
disableIssueCreation={!enableIssueCreation || !isEditingAllowed}
|
2023-11-27 08:45:33 +00:00
|
|
|
currentStore={currentStore}
|
2023-11-28 09:20:37 +00:00
|
|
|
addIssuesToView={addIssuesToView}
|
2023-11-23 09:17:04 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
2023-11-29 08:55:57 +00:00
|
|
|
|
|
|
|
{workspaceSlug && peekIssueId && peekProjectId && (
|
|
|
|
<IssuePeekOverview
|
|
|
|
workspaceSlug={workspaceSlug.toString()}
|
|
|
|
projectId={peekProjectId.toString()}
|
|
|
|
issueId={peekIssueId.toString()}
|
2023-12-18 06:44:57 +00:00
|
|
|
handleIssue={async (issueToUpdate, action: EIssueActions) =>
|
|
|
|
await handleIssues(issueToUpdate as IIssue, action)
|
|
|
|
}
|
2023-11-29 08:55:57 +00:00
|
|
|
/>
|
|
|
|
)}
|
2023-11-23 09:17:04 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
});
|