From 4aa790076920e501d2a621dcc279a11590dc658a Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 6 Jun 2017 17:09:13 -0300 Subject: [PATCH] Not connecting comment Component to the Store --- .../coral-embed-stream/src/components/Comment.js | 12 +++--------- .../coral-embed-stream/src/components/Stream.js | 16 ++++++++-------- .../coral-embed-stream/src/containers/Stream.js | 1 + client/coral-framework/helpers/plugins.js | 1 + client/coral-framework/reducers/index.js | 2 +- .../client/components/OffTopicFilter.js | 6 +++--- plugins/coral-plugin-offtopic/client/index.js | 2 ++ plugins/coral-plugin-offtopic/client/reducer.js | 10 ++++++++++ 8 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 plugins/coral-plugin-offtopic/client/reducer.js diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index 76a648ca4..84158e755 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -1,10 +1,8 @@ import React, {PropTypes} from 'react'; -import {connect} from 'react-redux'; import cn from 'classnames'; + import PermalinkButton from 'coral-plugin-permalinks/PermalinkButton'; - import AuthorName from 'coral-plugin-author-name/AuthorName'; - import TagLabel from 'coral-plugin-tag-label/TagLabel'; import Content from 'coral-plugin-commentcontent/CommentContent'; import PubDate from 'coral-plugin-pubdate/PubDate'; @@ -19,8 +17,8 @@ import { } from 'coral-plugin-best/BestButton'; import Slot from 'coral-framework/components/Slot'; import LoadMore from './LoadMore'; -import IgnoredCommentTombstone from './IgnoredCommentTombstone'; import {TopRightMenu} from './TopRightMenu'; +import IgnoredCommentTombstone from './IgnoredCommentTombstone'; import {EditableCommentContent} from './EditableCommentContent'; import {getActionSummary, iPerformedThisAction} from 'coral-framework/utils'; import {getEditableUntilDate} from './util'; @@ -38,7 +36,7 @@ const ActionButton = ({children}) => { ); }; -class Comment extends React.Component { +export default class Comment extends React.Component { constructor(props) { super(props); @@ -449,10 +447,6 @@ class Comment extends React.Component { } } -const mapStateToProps = ({comment}) => ({classNames: comment.classNames}); - -export default connect(mapStateToProps, null)(Comment); - // return whether the comment is editable function commentIsStillEditable (comment) { const editing = comment && comment.editing; diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index 131b56255..ae210013d 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -1,22 +1,20 @@ import React, {PropTypes} from 'react'; import LoadMore from './LoadMore'; import NewCount from './NewCount'; - import Comment from '../containers/Comment'; -import SuspendedAccount from './SuspendedAccount'; -import RestrictedMessageBox - from 'coral-framework/components/RestrictedMessageBox'; import ViewingOptions from './ViewingOptions'; +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'; -import t, {timeago} from 'coral-framework/services/i18n'; - class Stream extends React.Component { setActiveReplyBox = (reactKey) => { if (!this.props.auth.user) { @@ -28,6 +26,7 @@ class Stream extends React.Component { render() { const { + classNames, root: {asset, asset: {comments}, comment, me}, postComment, addNotification, @@ -36,10 +35,10 @@ class Stream extends React.Component { deleteAction, showSignInDialog, addCommentTag, - removeCommentTag, - pluginProps, ignoreUser, auth: {loggedIn, user}, + removeCommentTag, + pluginProps, commentCountCache, editName } = this.props; @@ -159,6 +158,7 @@ class Stream extends React.Component { return commentIsIgnored(comment) ? : ({ assetUrl: state.stream.assetUrl, activeTab: state.embed.activeTab, previousTab: state.embed.previousTab, + classNames: state.comment.classNames }); const mapDispatchToProps = (dispatch) => diff --git a/client/coral-framework/helpers/plugins.js b/client/coral-framework/helpers/plugins.js index 02ee8c3a7..3e54ee5fa 100644 --- a/client/coral-framework/helpers/plugins.js +++ b/client/coral-framework/helpers/plugins.js @@ -8,6 +8,7 @@ import plugins from 'pluginsConfig'; import {getDefinitionName, mergeDocuments} from 'coral-framework/utils'; import {loadTranslations} from 'coral-framework/services/i18n'; +console.log(plugins) export const pluginReducers = merge( ...plugins .filter((o) => o.module.reducer) diff --git a/client/coral-framework/reducers/index.js b/client/coral-framework/reducers/index.js index d5b66bbae..a25daee5c 100644 --- a/client/coral-framework/reducers/index.js +++ b/client/coral-framework/reducers/index.js @@ -3,7 +3,7 @@ import user from './user'; import asset from './asset'; import {reducer as commentBox} from '../../coral-plugin-commentbox'; import {pluginReducers} from '../helpers/plugins'; - +console.log(pluginReducers) export default { auth, user, diff --git a/plugins/coral-plugin-offtopic/client/components/OffTopicFilter.js b/plugins/coral-plugin-offtopic/client/components/OffTopicFilter.js index e91320b4b..f8c588316 100644 --- a/plugins/coral-plugin-offtopic/client/components/OffTopicFilter.js +++ b/plugins/coral-plugin-offtopic/client/components/OffTopicFilter.js @@ -18,14 +18,14 @@ class OffTopicFilter extends React.Component { const idx = this.props.comment.classNames.indexOf(this.cn); this.props.removeClassName(idx); } - props.closeViewingOptions(); + this.props.closeViewingOptions(); } render() { return (
@@ -33,7 +33,7 @@ class OffTopicFilter extends React.Component { } } -const mapStateToProps = ({comment}) => ({comment}); +const mapStateToProps = ({comment, offTopicFilter}) => ({comment, offTopicFilter}); const mapDispatchToProps = (dispatch) => bindActionCreators({addClassName, removeClassName, closeViewingOptions}, dispatch); diff --git a/plugins/coral-plugin-offtopic/client/index.js b/plugins/coral-plugin-offtopic/client/index.js index cd591de28..b6f9a7f5b 100644 --- a/plugins/coral-plugin-offtopic/client/index.js +++ b/plugins/coral-plugin-offtopic/client/index.js @@ -2,9 +2,11 @@ import OffTopicCheckbox from './components/OffTopicCheckbox'; import OffTopicTag from './components/OffTopicTag'; import OffTopicFilter from './components/OffTopicFilter'; import translations from './translations.json'; +import reducer from './reducer'; export default { translations, + reducer, slots: { commentInputDetailArea: [OffTopicCheckbox], streamViewingOptions: [OffTopicFilter], diff --git a/plugins/coral-plugin-offtopic/client/reducer.js b/plugins/coral-plugin-offtopic/client/reducer.js new file mode 100644 index 000000000..f5673b1a9 --- /dev/null +++ b/plugins/coral-plugin-offtopic/client/reducer.js @@ -0,0 +1,10 @@ +const initialState = { + filter: true +}; + +export default function offTopic (state = initialState, action) { + switch (action.type) { + default : + return state; + } +}