mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
78fee22fec
* fix: event tracker changes * fix: App provider implementation using wrappers * fix: updating packages * fix: handling warning * fix: wrapper fixes and minor optimization changes * fix: chore app-provider clearnup * fix: cleanup * fix: removing jitsu tracking * fix: minor updates * fix: adding event to posthog event tracker (#2802) * dev: posthog event tracker update intitiate * fix: adding events for posthog integration * fix: event payload --------- Co-authored-by: Ramesh Kumar Chandra <31303617+rameshkumarchandra@users.noreply.github.com>
89 lines
2.8 KiB
TypeScript
89 lines
2.8 KiB
TypeScript
import useSWR, { mutate } from "swr";
|
|
// services
|
|
import { IssueCommentService, IssueService } from "services/issue";
|
|
// hooks
|
|
import useToast from "hooks/use-toast";
|
|
import useProjectDetails from "hooks/use-project-details";
|
|
// components
|
|
import { AddComment, IssueActivitySection } from "components/issues";
|
|
// types
|
|
import { IIssue, IIssueComment } from "types";
|
|
// fetch-keys
|
|
import { PROJECT_ISSUES_ACTIVITY } from "constants/fetch-keys";
|
|
|
|
type Props = {
|
|
workspaceSlug: string;
|
|
issue: IIssue;
|
|
readOnly: boolean;
|
|
};
|
|
|
|
const issueCommentService = new IssueCommentService();
|
|
const issueService = new IssueService();
|
|
|
|
export const PeekOverviewIssueActivity: React.FC<Props> = (props) => {
|
|
const { workspaceSlug, issue } = props;
|
|
// toast
|
|
const { setToastAlert } = useToast();
|
|
|
|
const { projectDetails } = useProjectDetails();
|
|
|
|
const { data: issueActivity, mutate: mutateIssueActivity } = useSWR(
|
|
workspaceSlug && issue ? PROJECT_ISSUES_ACTIVITY(issue.id) : null,
|
|
workspaceSlug && issue
|
|
? () => issueService.getIssueActivities(workspaceSlug.toString(), issue?.project, issue?.id)
|
|
: null
|
|
);
|
|
|
|
const handleCommentUpdate = async (commentId: string, data: Partial<IIssueComment>) => {
|
|
if (!workspaceSlug || !issue) return;
|
|
|
|
await issueCommentService
|
|
.patchIssueComment(workspaceSlug as string, issue.project, issue.id, commentId, data)
|
|
.then(() => mutateIssueActivity());
|
|
};
|
|
|
|
const handleCommentDelete = async (commentId: string) => {
|
|
if (!workspaceSlug || !issue) return;
|
|
|
|
mutateIssueActivity((prevData: any) => prevData?.filter((p: any) => p.id !== commentId), false);
|
|
|
|
await issueCommentService
|
|
.deleteIssueComment(workspaceSlug as string, issue.project, issue.id, commentId)
|
|
.then(() => mutateIssueActivity());
|
|
};
|
|
|
|
const handleAddComment = async (formData: IIssueComment) => {
|
|
if (!workspaceSlug || !issue) return;
|
|
|
|
await issueCommentService
|
|
.createIssueComment(workspaceSlug.toString(), issue.project, issue.id, formData)
|
|
.then(() => {
|
|
mutate(PROJECT_ISSUES_ACTIVITY(issue.id));
|
|
})
|
|
.catch(() =>
|
|
setToastAlert({
|
|
type: "error",
|
|
title: "Error!",
|
|
message: "Comment could not be posted. Please try again.",
|
|
})
|
|
);
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
<h4 className="font-medium">Activity</h4>
|
|
<div className="mt-4">
|
|
<IssueActivitySection
|
|
activity={issueActivity}
|
|
handleCommentUpdate={handleCommentUpdate}
|
|
handleCommentDelete={handleCommentDelete}
|
|
showAccessSpecifier={projectDetails && projectDetails.is_deployed}
|
|
/>
|
|
<div className="mt-4">
|
|
<AddComment onSubmit={handleAddComment} showAccessSpecifier={projectDetails && projectDetails.is_deployed} />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|