import React, {Component, PropTypes} from 'react'; import Pym from 'pym.js'; import {graphql, compose} from 'react-apollo'; import {connect} from 'react-redux'; import gql from 'graphql-tag'; import { itemActions, Notification, notificationActions, authActions } from '../../coral-framework'; import CommentBox from '../../coral-plugin-commentbox/CommentBox'; import InfoBox from '../../coral-plugin-infobox/InfoBox'; import Content from '../../coral-plugin-commentcontent/CommentContent'; import PubDate from '../../coral-plugin-pubdate/PubDate'; import Count from '../../coral-plugin-comment-count/CommentCount'; import AuthorName from '../../coral-plugin-author-name/AuthorName'; import {ReplyBox, ReplyButton} from '../../coral-plugin-replies'; import FlagComment from '../../coral-plugin-flags/FlagComment'; import LikeButton from '../../coral-plugin-likes/LikeButton'; import PermalinkButton from '../../coral-plugin-permalinks/PermalinkButton'; import SignInContainer from '../../coral-sign-in/containers/SignInContainer'; import UserBox from '../../coral-sign-in/components/UserBox'; import {TabBar, Tab, TabContent, Spinner} from '../../coral-ui'; // import SettingsContainer from '../../coral-settings/containers/SettingsContainer'; import RestrictedContent from '../../coral-framework/components/RestrictedContent'; import SuspendedAccount from '../../coral-framework/components/SuspendedAccount'; // import ConfigureStreamContainer from '../../coral-configure/containers/ConfigureStreamContainer'; const {addItem, updateItem, postItem, getStream, postAction, deleteAction, appendItemArray} = itemActions; const {addNotification, clearNotification} = notificationActions; const {logout, showSignInDialog} = authActions; class CommentStream extends Component { constructor (props) { super(props); this.state = { activeTab: 0, showSignInDialog: false }; this.changeTab = this.changeTab.bind(this); } changeTab (tab) { this.setState({ activeTab: tab }); } static propTypes = { data: PropTypes.object.isRequired } componentDidMount () { return; // Set up messaging between embedded Iframe an parent component if (!path) { path = window.location.href.split('#')[0]; } // this.props.getStream(path || window.location); this.path = path; this.pym.sendMessage('childReady'); this.pym.onMessage('DOMContentLoaded', hash => { const commentId = hash.replace('#', 'c_'); let count = 0; const interval = setInterval(() => { if (document.getElementById(commentId)) { window.clearInterval(interval); this.pym.scrollParentToChildEl(commentId); } if (++count > 100) { // ~10 seconds // give up waiting for the comments to load. // it would be weird for the page to jump after that long. window.clearInterval(interval); } }, 100); }); } render () { // const rootItemId = this.props.items.assets && Object.keys(this.props.items.assets)[0]; // const rootItem = this.props.items.assets && this.props.items.assets[rootItemId]; // const {actions, users, comments} = this.props.items; const {isAdmin, showSignInDialog} = this.props.auth; const {activeTab} = this.state; // const banned = (this.props.userData.status === 'banned'); const {loading, asset, currentUser, refetch} = this.props.data; // const {status, moderation, closedMessage, charCount, charCountEnable} = asset.settings; const expandForLogin = showSignInDialog ? { minHeight: document.body.scrollHeight + 150 } : {}; return
{asset.settings.closedMessage}
} { !currentUser &&