2023-09-01 11:40:06 +00:00
|
|
|
import React from "react";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2023-09-01 11:40:06 +00:00
|
|
|
import Link from "next/link";
|
2023-09-01 11:12:30 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
// lib
|
2024-03-19 14:38:35 +00:00
|
|
|
import { Button } from "@plane/ui";
|
|
|
|
import { CommentCard, AddComment } from "@/components/issues/peek-overview";
|
|
|
|
import { Icon } from "@/components/ui";
|
2024-05-07 11:54:45 +00:00
|
|
|
// hooks
|
|
|
|
import { useUser } from "@/hooks/store";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useMobxStore } from "@/lib/mobx/store-provider";
|
2023-09-01 11:12:30 +00:00
|
|
|
// types
|
2024-05-07 11:54:45 +00:00
|
|
|
import { IIssue } from "@/types/issue";
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
issueDetails: IIssue;
|
|
|
|
};
|
|
|
|
|
2023-12-01 07:55:48 +00:00
|
|
|
export const PeekOverviewIssueActivity: React.FC<Props> = observer(() => {
|
|
|
|
// router
|
2023-09-01 11:12:30 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { workspace_slug } = router.query;
|
2023-12-01 07:55:48 +00:00
|
|
|
// store
|
2024-05-07 11:54:45 +00:00
|
|
|
const { issueDetails: issueDetailStore, project: projectStore } = useMobxStore();
|
|
|
|
const { data: currentUser } = useUser();
|
2023-09-01 11:12:30 +00:00
|
|
|
const comments = issueDetailStore.details[issueDetailStore.peekId || ""]?.comments || [];
|
|
|
|
|
|
|
|
return (
|
2023-09-01 11:40:06 +00:00
|
|
|
<div className="pb-10">
|
2023-09-01 11:12:30 +00:00
|
|
|
<h4 className="font-medium">Activity</h4>
|
|
|
|
{workspace_slug && (
|
|
|
|
<div className="mt-4">
|
|
|
|
<div className="space-y-4">
|
|
|
|
{comments.map((comment: any) => (
|
|
|
|
<CommentCard key={comment.id} comment={comment} workspaceSlug={workspace_slug?.toString()} />
|
|
|
|
))}
|
|
|
|
</div>
|
2023-12-01 07:55:48 +00:00
|
|
|
{currentUser ? (
|
2023-09-01 11:40:06 +00:00
|
|
|
<>
|
|
|
|
{projectStore.deploySettings?.comments && (
|
|
|
|
<div className="mt-4">
|
2023-12-01 07:55:48 +00:00
|
|
|
<AddComment disabled={!currentUser} />
|
2023-09-01 11:40:06 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
) : (
|
2023-12-01 07:55:48 +00:00
|
|
|
<div className="mt-4 flex items-center justify-between gap-2 rounded border border-custom-border-300 bg-custom-background-80 px-2 py-2.5">
|
|
|
|
<p className="flex gap-2 overflow-hidden break-words text-sm text-custom-text-200">
|
2023-09-01 11:40:06 +00:00
|
|
|
<Icon iconName="lock" className="!text-sm" />
|
|
|
|
Sign in to add your comment
|
|
|
|
</p>
|
|
|
|
<Link href={`/?next_path=${router.asPath}`}>
|
2023-12-05 10:37:25 +00:00
|
|
|
<Button variant="primary">Sign in</Button>
|
2023-09-01 11:40:06 +00:00
|
|
|
</Link>
|
2023-09-01 11:12:30 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|