{ !showEditor && isLoggedIn && (
)}
{ showEditor && isLoggedIn && (
)}
);
}
render() {
const topLevelComments = [];
const allReplies = [];
const layoutType = this.props.appContainer.getConfig().layoutType;
const isBaloonStyle = layoutType.match(/crowi-plus|growi|kibela/);
let comments = this.props.commentContainer.state.comments;
if (isBaloonStyle) {
// replace with asc order array
comments = comments.slice().reverse(); // non-destructive reverse
}
comments.forEach((comment) => {
if (comment.replyTo === undefined) {
// comment is not a reply
topLevelComments.push(comment);
}
else {
// comment is a reply
allReplies.push(comment);
}
});
return (
{ topLevelComments.map((topLevelComment) => {
// get related replies
const replies = this.getRepliesFor(topLevelComment, allReplies);
return this.renderThread(topLevelComment, replies);
}) }
);
}
}
/**
* Wrapper component for using unstated
*/
const PageCommentsWrapper = (props) => {
return createSubscribedElement(PageComments, props, [AppContainer, PageContainer, CommentContainer]);
};
PageComments.propTypes = {
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
commentContainer: PropTypes.instanceOf(CommentContainer).isRequired,
};
export default withTranslation()(PageCommentsWrapper);