Initial commit: Plane
Some checks failed
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Admin Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Codespell / Check for spelling errors (push) Has been cancelled
Sync Repositories / sync_changes (push) Has been cancelled
Some checks failed
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Admin Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Codespell / Check for spelling errors (push) Has been cancelled
Sync Repositories / sync_changes (push) Has been cancelled
Synced from upstream: 8853637e981ed7d8a6cff32bd98e7afe20f54362
This commit is contained in:
83
apps/web/core/components/comments/comments.tsx
Normal file
83
apps/web/core/components/comments/comments.tsx
Normal file
@@ -0,0 +1,83 @@
|
||||
"use client";
|
||||
|
||||
import type { FC } from "react";
|
||||
import React, { useMemo } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { useParams } from "next/navigation";
|
||||
// plane imports
|
||||
import type { E_SORT_ORDER } from "@plane/constants";
|
||||
import type { TCommentsOperations, TIssueComment } from "@plane/types";
|
||||
// local components
|
||||
import { CommentCard } from "./card/root";
|
||||
import { CommentCreate } from "./comment-create";
|
||||
|
||||
type TCommentsWrapper = {
|
||||
projectId?: string;
|
||||
entityId: string;
|
||||
isEditingAllowed?: boolean;
|
||||
activityOperations: TCommentsOperations;
|
||||
comments: TIssueComment[] | string[];
|
||||
sortOrder?: E_SORT_ORDER;
|
||||
getCommentById?: (activityId: string) => TIssueComment | undefined;
|
||||
showAccessSpecifier?: boolean;
|
||||
showCopyLinkOption?: boolean;
|
||||
};
|
||||
|
||||
export const CommentsWrapper: FC<TCommentsWrapper> = observer((props) => {
|
||||
const {
|
||||
entityId,
|
||||
activityOperations,
|
||||
comments,
|
||||
getCommentById,
|
||||
isEditingAllowed = true,
|
||||
projectId,
|
||||
showAccessSpecifier = false,
|
||||
showCopyLinkOption = false,
|
||||
} = props;
|
||||
// router
|
||||
const { workspaceSlug: routerWorkspaceSlug } = useParams();
|
||||
const workspaceSlug = routerWorkspaceSlug?.toString();
|
||||
const renderCommentCreate = useMemo(
|
||||
() =>
|
||||
isEditingAllowed && (
|
||||
<CommentCreate
|
||||
workspaceSlug={workspaceSlug}
|
||||
entityId={entityId}
|
||||
activityOperations={activityOperations}
|
||||
projectId={projectId}
|
||||
/>
|
||||
),
|
||||
[isEditingAllowed, workspaceSlug, entityId, activityOperations, projectId]
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="relative flex flex-col gap-y-2 h-full overflow-hidden">
|
||||
{renderCommentCreate}
|
||||
<div className="flex-grow py-4 overflow-y-auto">
|
||||
{comments?.map((data, index) => {
|
||||
let comment;
|
||||
if (typeof data === "string") {
|
||||
comment = getCommentById?.(data);
|
||||
} else {
|
||||
comment = data;
|
||||
}
|
||||
|
||||
if (!comment) return null;
|
||||
return (
|
||||
<CommentCard
|
||||
key={comment.id}
|
||||
workspaceSlug={workspaceSlug}
|
||||
comment={comment as TIssueComment}
|
||||
activityOperations={activityOperations}
|
||||
disabled={!isEditingAllowed}
|
||||
ends={index === 0 ? "top" : index === comments.length - 1 ? "bottom" : undefined}
|
||||
projectId={projectId}
|
||||
showAccessSpecifier={showAccessSpecifier}
|
||||
showCopyLinkOption={showCopyLinkOption}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user