diff --git a/client/coral-framework/reducers/index.js b/client/coral-framework/reducers/index.js index fae7e60d5..d5b66bbae 100644 --- a/client/coral-framework/reducers/index.js +++ b/client/coral-framework/reducers/index.js @@ -1,11 +1,13 @@ import auth from './auth'; import user from './user'; import asset from './asset'; +import {reducer as commentBox} from '../../coral-plugin-commentbox'; import {pluginReducers} from '../helpers/plugins'; export default { auth, user, asset, + commentBox, ...pluginReducers }; diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index c506da0cc..37bb58f67 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -3,6 +3,8 @@ import {I18n} from '../coral-framework'; import translations from './translations.json'; import {Button} from 'coral-ui'; import {Slot} from 'coral-framework'; +import {connect} from 'react-redux'; +import {bindActionCreators} from 'redux'; const name = 'coral-plugin-commentbox'; @@ -13,10 +15,7 @@ class CommentBox extends Component { this.state = { username: '', - comment: { - body: '', - tags: [] - }, + body: '', hooks: { preSubmit: [], postSubmit: [] @@ -35,13 +34,14 @@ class CommentBox extends Component { countCache, addNotification, updateCountCache, - commentPostedHandler, + commentPostedHandler } = this.props; let comment = { asset_id: assetId, parent_id: parentId, - ...this.state.comment + body: this.state.body, + ...this.props.commentBox }; !isReply && updateCountCache(assetId, countCache + 1); @@ -70,12 +70,7 @@ class CommentBox extends Component { }) .catch((err) => console.error(err)); - this.setState({ - comment: { - ...this.state.comment, - body: '' - } - }); + this.setState({body: ''}); } registerHook = (hookType = '', hook = () => {}) => { @@ -126,20 +121,13 @@ class CommentBox extends Component { }); } - handleChange = e => { - this.setState({ - comment: { - ...this.state.comment, - body: e.target.value - } - }); - } + handleChange = e => this.setState({body: e.target.value}); render () { const {styles, isReply, authorId, charCount} = this.props; let {cancelButtonClicked} = this.props; - const length = this.state.comment.body.length; + const length = this.state.body.length; const enablePostComment = !length || (charCount && length > charCount); if (isReply && typeof cancelButtonClicked !== 'function') { @@ -159,7 +147,7 @@ class CommentBox extends Component {