From f0f692fc26d91c2002f1740c7c99b1569f572f78 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 20 Jan 2017 16:39:23 -0300 Subject: [PATCH] =?UTF-8?q?=C3=A1dding=20webpack=20loader=20and=20post=20c?= =?UTF-8?q?omment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coral-embed-stream/src/CommentStream.js | 39 ++++++++++++++----- webpack.config.dev.js | 5 +++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 9f08a2259..d4b0b413e 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -33,7 +33,7 @@ import SuspendedAccount from '../../coral-framework/components/SuspendedAccount' // import ConfigureStreamContainer from '../../coral-configure/containers/ConfigureStreamContainer'; -const {addItem, updateItem, postItem, getStream, postAction, deleteAction, appendItemArray} = itemActions; +// const {addItem, updateItem, postItem, getStream, postAction, deleteAction, appendItemArray} = itemActions; const {addNotification, clearNotification} = notificationActions; const {logout, showSignInDialog} = authActions; @@ -61,12 +61,9 @@ class CommentStream extends Component { } componentDidMount () { - return; // Set up messaging between embedded Iframe an parent component - - if (!path) { path = window.location.href.split('#')[0]; } @@ -137,7 +134,7 @@ class CommentStream extends Component { postItem={this.props.postItem} appendItemArray={this.props.appendItemArray} updateItem={this.props.updateItem} - id={asset.settings.rootItemId} + id={asset.id} premod={asset.settings.moderation} reply={false} currentUser={this.props.auth.user} @@ -392,6 +389,22 @@ query AssetQuery($asset_url: String!) { `; const postComment = gql` + fragment commentView on Comment { + id + body + user { + name: displayName + } + actions { + type: action_type + count + current: current_user { + id + created_at + } + } + } + mutation CreateComment ($asset_id: ID!, $parent_id: ID, $body: String!) { createComment(asset_id:$asset_id, parent_id:$parent_id, body:$body) { ...commentView @@ -407,15 +420,23 @@ console.log('pym.parentUrl', url); export default compose( graphql(StreamQuery, { - // pass in the assetURL at componentDidMount options: { variables: { asset_url: url } }, props: props => props, }), graphql(postComment, { - options: { variables: { asset_url: url } }, props: ({ownProps, mutate}) => ({ - postComment: (data) => mutate(data) - }), + postItem: ({asset_id, author_id, body}) => { + mutate({ + variables: { + asset_id, + body, + parent_id: null + } + }).then(({data}) => { + console.log('it workt'); + console.log(data); + }); + }}), }), connect(mapStateToProps, mapDispatchToProps) )(CommentStream); diff --git a/webpack.config.dev.js b/webpack.config.dev.js index 913ee35da..539233bef 100644 --- a/webpack.config.dev.js +++ b/webpack.config.dev.js @@ -70,6 +70,11 @@ module.exports = { { loader: 'url?limit=100000', test: /\.woff$/ + }, + { + test: /\.(graphql|gql)$/, + exclude: /node_modules/, + loader: 'graphql-tag/loader' } ] },