2024-01-23 07:58:58 +00:00
|
|
|
import { FC } from "react";
|
2024-05-08 17:31:20 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-04-16 07:52:27 +00:00
|
|
|
// components
|
|
|
|
import { EmptyState } from "@/components/empty-state";
|
|
|
|
// hooks
|
|
|
|
import { EmptyStateType } from "@/constants/empty-state";
|
2024-01-23 07:58:58 +00:00
|
|
|
// 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>
|
2024-04-16 07:52:27 +00:00
|
|
|
{commentIds.length > 0 ? (
|
|
|
|
commentIds.map((commentId, index) => (
|
|
|
|
<IssueCommentCard
|
|
|
|
projectId={projectId}
|
|
|
|
key={commentId}
|
|
|
|
workspaceSlug={workspaceSlug}
|
|
|
|
commentId={commentId}
|
|
|
|
ends={index === 0 ? "top" : index === commentIds.length - 1 ? "bottom" : undefined}
|
|
|
|
activityOperations={activityOperations}
|
|
|
|
showAccessSpecifier={showAccessSpecifier}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
) : (
|
|
|
|
<div className="flex items-center justify-center py-9">
|
|
|
|
<EmptyState type={EmptyStateType.ISSUE_COMMENT_EMPTY_STATE} layout="screen-simple" />
|
|
|
|
</div>
|
|
|
|
)}
|
2024-01-23 07:58:58 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
});
|