import React, {PropTypes} from 'react'; import LoadMore from './LoadMore'; import NewCount from './NewCount'; import Comment from '../containers/Comment'; import SuspendedAccount from './SuspendedAccount'; import Slot from 'coral-framework/components/Slot'; import InfoBox from 'coral-plugin-infobox/InfoBox'; import {can} from 'coral-framework/services/perms'; import {ModerationLink} from 'coral-plugin-moderation'; import RestrictedMessageBox from 'coral-framework/components/RestrictedMessageBox'; import t, {timeago} from 'coral-framework/services/i18n'; import CommentBox from 'coral-plugin-commentbox/CommentBox'; import QuestionBox from 'coral-plugin-questionbox/QuestionBox'; import IgnoredCommentTombstone from './IgnoredCommentTombstone'; class Stream extends React.Component { setActiveReplyBox = (reactKey) => { if (!this.props.auth.user) { this.props.showSignInDialog(); } else { this.props.setActiveReplyBox(reactKey); } }; render() { const { classNames, root: {asset, asset: {comments}, comment, me}, postComment, addNotification, postFlag, postDontAgree, deleteAction, showSignInDialog, addCommentTag, ignoreUser, auth: {loggedIn, user}, removeCommentTag, pluginProps, commentCountCache, editName } = this.props; const open = asset.closedAt === null; // even though the permalinked comment is the highlighted one, we're displaying its parent + replies const highlightedComment = comment && comment.parent ? comment.parent : comment; const banned = user && user.status === 'BANNED'; const temporarilySuspended = user && user.suspension.until && new Date(user.suspension.until) > new Date(); const commentIsIgnored = (comment) => { return ( me && me.ignoredUsers && me.ignoredUsers.find((u) => u.id === comment.user.id) ); }; return (
{open ?
{!banned && temporarilySuspended && {t( 'stream.temporarily_suspended', this.props.root.settings.organizationName, timeago(user.suspension.until) )} } {banned && } {loggedIn && !banned && !temporarilySuspended && !highlightedComment && }
:

{asset.settings.closedMessage}

} {loggedIn && ( )}
{/* the highlightedComment is isolated after the user followed a permalink */} {highlightedComment ? :
{comments && comments.nodes.map((comment) => { return commentIsIgnored(comment) ? : ; })}
}
); } } Stream.propTypes = { addNotification: PropTypes.func.isRequired, postComment: PropTypes.func.isRequired, // dispatch action to add a tag to a comment addCommentTag: PropTypes.func, // dispatch action to remove a tag from a comment removeCommentTag: PropTypes.func, // dispatch action to ignore another user ignoreUser: React.PropTypes.func, // edit a comment, passed (id, asset_id, { body }) editComment: React.PropTypes.func }; export default Stream;