diff options
Diffstat (limited to 'src/components/organisms/comments-list/comments-list.tsx')
| -rw-r--r-- | src/components/organisms/comments-list/comments-list.tsx | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/components/organisms/comments-list/comments-list.tsx b/src/components/organisms/comments-list/comments-list.tsx index 0470f99..657c558 100644 --- a/src/components/organisms/comments-list/comments-list.tsx +++ b/src/components/organisms/comments-list/comments-list.tsx @@ -36,6 +36,12 @@ export type CommentsListProps = Omit< > & Pick<ReplyCommentFormProps, 'onSubmit'> & { /** + * Should we forbid replies on comments when depth is not exceed? + * + * @default false + */ + areRepliesForbidden?: boolean; + /** * The comments. */ comments: CommentData[]; @@ -50,7 +56,10 @@ export type CommentsListProps = Omit< const CommentsListWithRef: ForwardRefRenderFunction< HTMLOListElement, CommentsListProps -> = ({ comments, depth = 0, onSubmit, ...props }, ref) => { +> = ( + { areRepliesForbidden = false, comments, depth = 0, onSubmit, ...props }, + ref +) => { const [replyingTo, setReplyingTo] = useState<Nullable<number>>(null); const intl = useIntl(); @@ -93,8 +102,14 @@ const CommentsListWithRef: ForwardRefRenderFunction< <> <ApprovedComment {...comment} - onReply={toggleReply} - replyBtn={isLastLevel ? undefined : replyBtnLabel} + onReply={ + isLastLevel || areRepliesForbidden ? undefined : toggleReply + } + replyBtn={ + isLastLevel || areRepliesForbidden + ? undefined + : replyBtnLabel + } /> {replyingTo === comment.id ? ( <ReplyCommentForm @@ -122,7 +137,7 @@ const CommentsListWithRef: ForwardRefRenderFunction< ); }); }, - [depth, intl, onSubmit, replyingTo, toggleReply] + [areRepliesForbidden, depth, intl, onSubmit, replyingTo, toggleReply] ); return ( |
