diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js new file mode 100644 index 000000000..d13729f8f --- /dev/null +++ b/client/coral-embed-stream/src/Comment.js @@ -0,0 +1,42 @@ +// this component will +// render its children +// render a like button +// render a permalink button +// render a reply button +// render a flag button +// translate things? + +import React, {PropTypes} from 'react'; +import PermalinkButton from 'coral-plugin-permalinks/PermalinkButton'; + +const Comment = ({comment}) => { + console.log('A Comment', comment); + return ( +
+
+ {comment.body} + +
+ ); +}; + +Comment.propTypes = { + comment: PropTypes.shape({ + depth: PropTypes.number, + actions: PropTypes.array.isRequired, + body: PropTypes.string.isRequired, + id: PropTypes.string.isRequired, + replies: PropTypes.arrayOf( + PropTypes.shape({ + body: PropTypes.string.isRequired, + id: PropTypes.string.isRequired + }) + ), + user: PropTypes.shape({ + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired + }).isRequired + }).isRequired +}; + +export default Comment; diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/Embed.js similarity index 57% rename from client/coral-embed-stream/src/CommentStream.js rename to client/coral-embed-stream/src/Embed.js index d4b0b413e..3d0e81bd5 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/Embed.js @@ -11,6 +11,8 @@ import { authActions } from '../../coral-framework'; +import Comment from './Comment'; + import CommentBox from '../../coral-plugin-commentbox/CommentBox'; import InfoBox from '../../coral-plugin-infobox/InfoBox'; import Content from '../../coral-plugin-commentcontent/CommentContent'; @@ -37,7 +39,7 @@ import SuspendedAccount from '../../coral-framework/components/SuspendedAccount' const {addNotification, clearNotification} = notificationActions; const {logout, showSignInDialog} = authActions; -class CommentStream extends Component { +class Embed extends Component { constructor (props) { super(props); @@ -57,10 +59,11 @@ class CommentStream extends Component { } static propTypes = { - data: PropTypes.object.isRequired + data: PropTypes.object.isRequired, } componentDidMount () { + // stream id, logged in user, settings return; // Set up messaging between embedded Iframe an parent component @@ -151,134 +154,8 @@ class CommentStream extends Component { showSignInDialog={showSignInDialog}/> } { - asset.comments.map((comment) => { - return
-
- - - -
- - -
-
- - -
- - { - comment.replies.map((reply) => { - return
-
- - - -
- - -
-
- - -
- { - - } -
; - }) - } -
; + asset.comments.map(comment => { + return ; }) } { @@ -439,4 +316,4 @@ export default compose( }}), }), connect(mapStateToProps, mapDispatchToProps) -)(CommentStream); +)(Embed); diff --git a/client/coral-embed-stream/src/Stream.js b/client/coral-embed-stream/src/Stream.js new file mode 100644 index 000000000..e69de29bb diff --git a/client/coral-embed-stream/src/index.js b/client/coral-embed-stream/src/index.js index 67b4bad29..f75146f0a 100644 --- a/client/coral-embed-stream/src/index.js +++ b/client/coral-embed-stream/src/index.js @@ -5,11 +5,11 @@ import {ApolloProvider} from 'react-apollo'; import {client} from 'coral-framework/client'; import store from 'coral-framework/store'; -import Stream from './CommentStream'; +import Embed from './Embed'; render( - + , document.querySelector('#coralStream') ); diff --git a/client/coral-plugin-comment-count/CommentCount.js b/client/coral-plugin-comment-count/CommentCount.js index 623274e53..764984634 100644 --- a/client/coral-plugin-comment-count/CommentCount.js +++ b/client/coral-plugin-comment-count/CommentCount.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {PropTypes} from 'react'; import {I18n} from '../coral-framework'; import translations from './translations.json'; const name = 'coral-plugin-comment-count'; @@ -9,6 +9,10 @@ const CommentCount = ({count}) => { ; }; +CommentCount.propTypes = { + count: PropTypes.number.isRequired +}; + export default CommentCount; const lang = new I18n(translations); diff --git a/graph/mutators.js b/graph/mutators.js index 11e727fad..f5c600499 100644 --- a/graph/mutators.js +++ b/graph/mutators.js @@ -118,7 +118,7 @@ const createPublicComment = (context, commentInput) => { // If the comment was flagged as being suspect, we need to add a // flag to it to indicate that it needs to be looked at. // Otherwise just return the new comment. - if (wordlist.suspect) { + if (wordlist != null && wordlist.suspect) { // TODO: this is kind of fragile, we should refactor this to resolve // all these const's that we're using like 'comments', 'flag' to be