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";
|
2024-05-14 08:56:54 +00:00
|
|
|
import { usePathname } from "next/navigation";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { Button } from "@plane/ui";
|
2024-05-08 17:31:20 +00:00
|
|
|
// components
|
2024-03-19 14:38:35 +00:00
|
|
|
import { CommentCard, AddComment } from "@/components/issues/peek-overview";
|
|
|
|
import { Icon } from "@/components/ui";
|
2024-05-08 17:31:20 +00:00
|
|
|
// hooks
|
2024-05-14 08:56:54 +00:00
|
|
|
import { useIssueDetails, useProject, useUser } from "@/hooks/store";
|
2024-05-22 07:09:34 +00:00
|
|
|
import useIsInIframe from "@/hooks/use-is-in-iframe";
|
2023-09-01 11:12:30 +00:00
|
|
|
// types
|
2024-05-08 17:31:20 +00:00
|
|
|
import { IIssue } from "@/types/issue";
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
issueDetails: IIssue;
|
2024-05-14 08:56:54 +00:00
|
|
|
workspaceSlug: string;
|
|
|
|
projectId: string;
|
2023-09-01 11:12:30 +00:00
|
|
|
};
|
|
|
|
|
2024-05-14 08:56:54 +00:00
|
|
|
export const PeekOverviewIssueActivity: React.FC<Props> = observer((props) => {
|
|
|
|
const { workspaceSlug, projectId } = props;
|
2023-12-01 07:55:48 +00:00
|
|
|
// router
|
2024-05-14 08:56:54 +00:00
|
|
|
const pathname = usePathname();
|
2023-12-01 07:55:48 +00:00
|
|
|
// store
|
2024-05-14 08:56:54 +00:00
|
|
|
const { canComment } = useProject();
|
|
|
|
const { details, peekId } = useIssueDetails();
|
2024-05-08 17:31:20 +00:00
|
|
|
const { data: currentUser } = useUser();
|
2024-05-22 07:09:34 +00:00
|
|
|
const isInIframe = useIsInIframe();
|
2024-05-14 08:56:54 +00:00
|
|
|
|
|
|
|
const comments = details[peekId || ""]?.comments || [];
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
return (
|
2023-09-01 11:40:06 +00:00
|
|
|
<div className="pb-10">
|
2024-05-20 10:13:48 +00:00
|
|
|
<h4 className="font-medium">Comments</h4>
|
2024-05-14 08:56:54 +00:00
|
|
|
{workspaceSlug && (
|
2023-09-01 11:12:30 +00:00
|
|
|
<div className="mt-4">
|
|
|
|
<div className="space-y-4">
|
|
|
|
{comments.map((comment: any) => (
|
2024-05-14 08:56:54 +00:00
|
|
|
<CommentCard key={comment.id} comment={comment} workspaceSlug={workspaceSlug?.toString()} />
|
2023-09-01 11:12:30 +00:00
|
|
|
))}
|
|
|
|
</div>
|
2024-05-22 07:09:34 +00:00
|
|
|
{!isInIframe &&
|
|
|
|
(currentUser ? (
|
|
|
|
<>
|
|
|
|
{canComment && (
|
|
|
|
<div className="mt-4">
|
|
|
|
<AddComment disabled={!currentUser} workspaceSlug={workspaceSlug} projectId={projectId} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<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">
|
|
|
|
<Icon iconName="lock" className="!text-sm" />
|
|
|
|
Sign in to add your comment
|
|
|
|
</p>
|
|
|
|
<Link href={`/?next_path=${pathname}`}>
|
|
|
|
<Button variant="primary">Sign in</Button>
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
))}
|
2023-09-01 11:12:30 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|