2023-10-18 14:28:05 +00:00
|
|
|
import { FC, ReactNode } from "react";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
// components
|
|
|
|
import { IssueView } from "./view";
|
|
|
|
// hooks
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
// types
|
|
|
|
import { IIssue } from "types";
|
|
|
|
|
|
|
|
interface IIssuePeekOverview {
|
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
|
|
|
issueId: string;
|
|
|
|
handleIssue: (issue: Partial<IIssue>) => void;
|
2023-11-03 11:50:14 +00:00
|
|
|
children?: ReactNode;
|
2023-10-18 14:28:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
|
|
|
|
const { workspaceSlug, projectId, issueId, handleIssue, children } = props;
|
|
|
|
|
2023-11-03 13:43:10 +00:00
|
|
|
const { issueDetail: issueDetailStore, project: projectStore, user: userStore } = useMobxStore();
|
2023-10-18 14:28:05 +00:00
|
|
|
|
|
|
|
const issueUpdate = (_data: Partial<IIssue>) => {
|
2023-11-02 10:32:34 +00:00
|
|
|
handleIssue(_data);
|
2023-10-18 14:28:05 +00:00
|
|
|
};
|
|
|
|
|
2023-10-20 12:25:20 +00:00
|
|
|
const issueReactionCreate = (reaction: string) =>
|
|
|
|
issueDetailStore.createIssueReaction(workspaceSlug, projectId, issueId, reaction);
|
2023-10-20 07:03:39 +00:00
|
|
|
|
2023-10-20 12:25:20 +00:00
|
|
|
const issueReactionRemove = (reaction: string) =>
|
|
|
|
issueDetailStore.removeIssueReaction(workspaceSlug, projectId, issueId, reaction);
|
|
|
|
|
|
|
|
const issueCommentCreate = (comment: any) =>
|
|
|
|
issueDetailStore.createIssueComment(workspaceSlug, projectId, issueId, comment);
|
|
|
|
|
|
|
|
const issueCommentUpdate = (comment: any) =>
|
|
|
|
issueDetailStore.updateIssueComment(workspaceSlug, projectId, issueId, comment?.id, comment);
|
|
|
|
|
|
|
|
const issueCommentRemove = (commentId: string) =>
|
|
|
|
issueDetailStore.removeIssueComment(workspaceSlug, projectId, issueId, commentId);
|
|
|
|
|
|
|
|
const issueCommentReactionCreate = (commentId: string, reaction: string) =>
|
2023-10-25 13:54:14 +00:00
|
|
|
issueDetailStore.creationIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
|
2023-10-20 12:25:20 +00:00
|
|
|
|
|
|
|
const issueCommentReactionRemove = (commentId: string, reaction: string) =>
|
2023-10-25 13:54:14 +00:00
|
|
|
issueDetailStore.removeIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
|
2023-10-20 07:03:39 +00:00
|
|
|
|
2023-11-01 08:52:29 +00:00
|
|
|
const issueSubscriptionCreate = () => issueDetailStore.createIssueSubscription(workspaceSlug, projectId, issueId);
|
|
|
|
|
|
|
|
const issueSubscriptionRemove = () => issueDetailStore.removeIssueSubscription(workspaceSlug, projectId, issueId);
|
|
|
|
|
|
|
|
const handleDeleteIssue = () => issueDetailStore.deleteIssue(workspaceSlug, projectId, issueId);
|
|
|
|
|
2023-11-03 13:43:10 +00:00
|
|
|
const userRole = userStore.currentProjectRole ?? 5;
|
|
|
|
|
2023-10-18 14:28:05 +00:00
|
|
|
return (
|
|
|
|
<IssueView
|
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
projectId={projectId}
|
|
|
|
issueId={issueId}
|
|
|
|
issueUpdate={issueUpdate}
|
2023-10-20 07:03:39 +00:00
|
|
|
issueReactionCreate={issueReactionCreate}
|
|
|
|
issueReactionRemove={issueReactionRemove}
|
2023-10-20 12:25:20 +00:00
|
|
|
issueCommentCreate={issueCommentCreate}
|
|
|
|
issueCommentUpdate={issueCommentUpdate}
|
|
|
|
issueCommentRemove={issueCommentRemove}
|
|
|
|
issueCommentReactionCreate={issueCommentReactionCreate}
|
|
|
|
issueCommentReactionRemove={issueCommentReactionRemove}
|
2023-11-01 08:52:29 +00:00
|
|
|
issueSubscriptionCreate={issueSubscriptionCreate}
|
|
|
|
issueSubscriptionRemove={issueSubscriptionRemove}
|
|
|
|
handleDeleteIssue={handleDeleteIssue}
|
2023-11-03 13:43:10 +00:00
|
|
|
disableUserActions={[5, 10].includes(userRole)}
|
|
|
|
showCommentAccessSpecifier={projectStore.currentProjectDetails?.is_deployed}
|
2023-10-18 14:28:05 +00:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</IssueView>
|
|
|
|
);
|
|
|
|
});
|