2024-01-23 07:58:58 +00:00
|
|
|
import { FC } from "react";
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
// hooks
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useIssueDetail } from "@/hooks/store";
|
2024-01-23 07:58:58 +00:00
|
|
|
// components
|
2024-03-06 13:09:14 +00:00
|
|
|
import { TActivityOperations } from "../root";
|
2024-01-23 07:58:58 +00:00
|
|
|
import { IssueCommentCard } from "./comment-card";
|
|
|
|
// types
|
|
|
|
|
|
|
|
type TIssueCommentRoot = {
|
2024-04-11 15:58:59 +00:00
|
|
|
projectId: string;
|
2024-01-23 07:58:58 +00:00
|
|
|
workspaceSlug: string;
|
|
|
|
issueId: string;
|
|
|
|
activityOperations: TActivityOperations;
|
|
|
|
showAccessSpecifier?: boolean;
|
2024-04-03 12:32:07 +00:00
|
|
|
disabled?: boolean;
|
2024-01-23 07:58:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const IssueCommentRoot: FC<TIssueCommentRoot> = observer((props) => {
|
2024-04-11 15:58:59 +00:00
|
|
|
const { workspaceSlug, projectId, issueId, activityOperations, showAccessSpecifier, disabled } = props;
|
2024-01-23 07:58:58 +00:00
|
|
|
// hooks
|
|
|
|
const {
|
|
|
|
comment: { getCommentsByIssueId },
|
|
|
|
} = useIssueDetail();
|
|
|
|
|
|
|
|
const commentIds = getCommentsByIssueId(issueId);
|
|
|
|
if (!commentIds) return <></>;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{commentIds.map((commentId, index) => (
|
|
|
|
<IssueCommentCard
|
2024-04-11 15:58:59 +00:00
|
|
|
projectId={projectId}
|
2024-03-06 13:09:14 +00:00
|
|
|
key={commentId}
|
2024-01-23 07:58:58 +00:00
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
commentId={commentId}
|
|
|
|
ends={index === 0 ? "top" : index === commentIds.length - 1 ? "bottom" : undefined}
|
|
|
|
activityOperations={activityOperations}
|
|
|
|
showAccessSpecifier={showAccessSpecifier}
|
2024-04-03 12:32:07 +00:00
|
|
|
disabled={disabled}
|
2024-01-23 07:58:58 +00:00
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|