|
|
import { some } from 'lodash'; |
|
|
import PropTypes from 'prop-types'; |
|
|
import PostCommentForm from './form'; |
|
|
|
|
|
const noop = () => {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const PostCommentFormRoot = ( { |
|
|
post, |
|
|
commentText, |
|
|
activeReplyCommentId, |
|
|
commentsTree, |
|
|
onUpdateCommentText = noop, |
|
|
isInlineComment, |
|
|
} ) => { |
|
|
|
|
|
if ( |
|
|
activeReplyCommentId || |
|
|
some( commentsTree, ( comment ) => { |
|
|
return comment.data && comment.data.isPlaceholder && ! comment.data.parent; |
|
|
} ) |
|
|
) { |
|
|
return null; |
|
|
} |
|
|
|
|
|
return ( |
|
|
<PostCommentForm |
|
|
post={ post } |
|
|
parentCommentId={ null } |
|
|
commentText={ commentText } |
|
|
onUpdateCommentText={ onUpdateCommentText } |
|
|
isInlineComment={ isInlineComment } |
|
|
/> |
|
|
); |
|
|
}; |
|
|
|
|
|
PostCommentFormRoot.propTypes = { |
|
|
post: PropTypes.object.isRequired, |
|
|
commentText: PropTypes.string, |
|
|
activeReplyCommentId: PropTypes.number, |
|
|
commentsTree: PropTypes.object, |
|
|
onUpdateCommentText: PropTypes.func, |
|
|
isInlineComment: PropTypes.bool, |
|
|
}; |
|
|
|
|
|
export default PostCommentFormRoot; |
|
|
|