mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
added comment events
This commit is contained in:
parent
604b9c7632
commit
6c78b98c9c
@ -1,13 +1,16 @@
|
|||||||
import { FC, useMemo, useState } from "react";
|
import { FC, useMemo, useState } from "react";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { History, LucideIcon, MessageCircle, ListRestart } from "lucide-react";
|
import { History, LucideIcon, MessageCircle, ListRestart } from "lucide-react";
|
||||||
// hooks
|
// hooks
|
||||||
import { useIssueDetail, useProject } from "hooks/store";
|
import { useEventTracker, useIssueDetail, useProject } from "hooks/store";
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
// components
|
// components
|
||||||
import { IssueActivityCommentRoot, IssueActivityRoot, IssueCommentRoot, IssueCommentCreate } from "./";
|
import { IssueActivityCommentRoot, IssueActivityRoot, IssueCommentRoot, IssueCommentCreate } from "./";
|
||||||
// types
|
// types
|
||||||
import { TIssueComment } from "@plane/types";
|
import { TIssueComment } from "@plane/types";
|
||||||
|
// constants
|
||||||
|
import { COMMENT_CREATED, COMMENT_DELETED, COMMENT_UPDATED } from "constants/event-tracker";
|
||||||
|
|
||||||
type TIssueActivity = {
|
type TIssueActivity = {
|
||||||
workspaceSlug: string;
|
workspaceSlug: string;
|
||||||
@ -43,8 +46,13 @@ export type TActivityOperations = {
|
|||||||
|
|
||||||
export const IssueActivity: FC<TIssueActivity> = observer((props) => {
|
export const IssueActivity: FC<TIssueActivity> = observer((props) => {
|
||||||
const { workspaceSlug, projectId, issueId } = props;
|
const { workspaceSlug, projectId, issueId } = props;
|
||||||
|
// router
|
||||||
|
const router = useRouter();
|
||||||
|
const { inboxId } = router.query;
|
||||||
// hooks
|
// hooks
|
||||||
const { createComment, updateComment, removeComment } = useIssueDetail();
|
const { createComment, updateComment, removeComment } = useIssueDetail();
|
||||||
|
const { captureEvent } = useEventTracker();
|
||||||
|
const { peekIssue } = useIssueDetail();
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
const { getProjectById } = useProject();
|
const { getProjectById } = useProject();
|
||||||
// state
|
// state
|
||||||
@ -56,6 +64,11 @@ export const IssueActivity: FC<TIssueActivity> = observer((props) => {
|
|||||||
try {
|
try {
|
||||||
if (!workspaceSlug || !projectId || !issueId) throw new Error("Missing fields");
|
if (!workspaceSlug || !projectId || !issueId) throw new Error("Missing fields");
|
||||||
await createComment(workspaceSlug, projectId, issueId, data);
|
await createComment(workspaceSlug, projectId, issueId, data);
|
||||||
|
captureEvent(COMMENT_CREATED, {
|
||||||
|
issue_id: issueId,
|
||||||
|
is_public: data.access === "EXTERNAL",
|
||||||
|
element: peekIssue ? "Peek issue" : inboxId ? "Inbox issue" : "Issue detail",
|
||||||
|
});
|
||||||
setToastAlert({
|
setToastAlert({
|
||||||
title: "Comment created successfully.",
|
title: "Comment created successfully.",
|
||||||
type: "success",
|
type: "success",
|
||||||
@ -73,6 +86,11 @@ export const IssueActivity: FC<TIssueActivity> = observer((props) => {
|
|||||||
try {
|
try {
|
||||||
if (!workspaceSlug || !projectId || !issueId) throw new Error("Missing fields");
|
if (!workspaceSlug || !projectId || !issueId) throw new Error("Missing fields");
|
||||||
await updateComment(workspaceSlug, projectId, issueId, commentId, data);
|
await updateComment(workspaceSlug, projectId, issueId, commentId, data);
|
||||||
|
captureEvent(COMMENT_UPDATED, {
|
||||||
|
issue_id: issueId,
|
||||||
|
is_public: data.access === "EXTERNAL",
|
||||||
|
element: peekIssue ? "Peek issue" : inboxId ? "Inbox issue" : "Issue detail",
|
||||||
|
});
|
||||||
setToastAlert({
|
setToastAlert({
|
||||||
title: "Comment updated successfully.",
|
title: "Comment updated successfully.",
|
||||||
type: "success",
|
type: "success",
|
||||||
@ -90,6 +108,10 @@ export const IssueActivity: FC<TIssueActivity> = observer((props) => {
|
|||||||
try {
|
try {
|
||||||
if (!workspaceSlug || !projectId || !issueId) throw new Error("Missing fields");
|
if (!workspaceSlug || !projectId || !issueId) throw new Error("Missing fields");
|
||||||
await removeComment(workspaceSlug, projectId, issueId, commentId);
|
await removeComment(workspaceSlug, projectId, issueId, commentId);
|
||||||
|
captureEvent(COMMENT_DELETED, {
|
||||||
|
issue_id: issueId,
|
||||||
|
element: peekIssue ? "Peek issue" : inboxId ? "Inbox issue" : "Issue detail",
|
||||||
|
});
|
||||||
setToastAlert({
|
setToastAlert({
|
||||||
title: "Comment removed successfully.",
|
title: "Comment removed successfully.",
|
||||||
type: "success",
|
type: "success",
|
||||||
|
@ -213,6 +213,10 @@ export const ISSUE_UPDATED = "Issue updated";
|
|||||||
export const ISSUE_DELETED = "Issue deleted";
|
export const ISSUE_DELETED = "Issue deleted";
|
||||||
export const ISSUE_ARCHIVED = "Issue archived";
|
export const ISSUE_ARCHIVED = "Issue archived";
|
||||||
export const ISSUE_RESTORED = "Issue restored";
|
export const ISSUE_RESTORED = "Issue restored";
|
||||||
|
// Comment Events
|
||||||
|
export const COMMENT_CREATED = "Comment created";
|
||||||
|
export const COMMENT_UPDATED = "Comment updated";
|
||||||
|
export const COMMENT_DELETED = "Comment deleted";
|
||||||
// Issue Checkout Events
|
// Issue Checkout Events
|
||||||
export const ISSUES_LIST_OPENED = "Issues list opened";
|
export const ISSUES_LIST_OPENED = "Issues list opened";
|
||||||
export const ISSUE_OPENED = "Issue opened";
|
export const ISSUE_OPENED = "Issue opened";
|
||||||
|
Loading…
Reference in New Issue
Block a user