From d1fc5668fb1ee8818017409554d0cf8b15f20743 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 8 Aug 2017 19:50:59 +0700 Subject: [PATCH 1/3] Pass config to plugins --- client/coral-framework/helpers/plugins.js | 4 ++-- plugin-api/beta/client/hocs/withReaction.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/coral-framework/helpers/plugins.js b/client/coral-framework/helpers/plugins.js index 1af2a9a59..5e5a8c0c0 100644 --- a/client/coral-framework/helpers/plugins.js +++ b/client/coral-framework/helpers/plugins.js @@ -10,7 +10,7 @@ import camelize from './camelize'; import plugins from 'pluginsConfig'; export function getSlotComponents(slot, reduxState, props = {}) { - const pluginConfig = reduxState.config.pluginConfig || {}; + const pluginConfig = reduxState.config.plugin_config || {}; return flatten(plugins // Filter out components that have slots and have been disabled in `plugin_config` @@ -39,7 +39,7 @@ export function isSlotEmpty(slot, reduxState, props) { * Returns React Elements for given slot. */ export function getSlotElements(slot, reduxState, props = {}) { - const pluginConfig = reduxState.config.pluginConfig || {}; + const pluginConfig = reduxState.config.plugin_config || {}; return getSlotComponents(slot, reduxState, props) .map((component, i) => React.createElement(component, {key: i, ...props, config: pluginConfig})); } diff --git a/plugin-api/beta/client/hocs/withReaction.js b/plugin-api/beta/client/hocs/withReaction.js index 40ee6e14c..7f43cc5b2 100644 --- a/plugin-api/beta/client/hocs/withReaction.js +++ b/plugin-api/beta/client/hocs/withReaction.js @@ -271,6 +271,7 @@ export default (reaction) => (WrappedComponent) => { alreadyReacted={alreadyReacted} postReaction={this.postReaction} deleteReaction={this.deleteReaction} + config={this.props.config} />; } } From c4a91d225e57657cdf56d4861373413dea374348 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 8 Aug 2017 19:57:23 +0700 Subject: [PATCH 2/3] Pass config also to withTags --- plugin-api/beta/client/hocs/withTags.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin-api/beta/client/hocs/withTags.js b/plugin-api/beta/client/hocs/withTags.js index 75d434bef..e9b5bdff0 100644 --- a/plugin-api/beta/client/hocs/withTags.js +++ b/plugin-api/beta/client/hocs/withTags.js @@ -68,16 +68,17 @@ export default (tag) => (WrappedComponent) => { } render() { - const {comment} = this.props; + const {comment, user, config} = this.props; const alreadyTagged = isTagged(comment.tags, TAG); return ; } } From 7bdd28cb9c192ef8aa4e3a83e430f32aaf237d6f Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 8 Aug 2017 20:47:21 +0700 Subject: [PATCH 3/3] Emit `ui.AllCommentsPane.viewNewComments` and `ui.Comment.showMoreReplies` --- client/coral-embed-stream/src/components/AllCommentsPane.js | 3 +++ client/coral-embed-stream/src/components/Comment.js | 1 + client/coral-embed-stream/src/components/Stream.js | 1 + client/coral-embed-stream/src/containers/Stream.js | 3 ++- plugin-api/beta/client/hocs/index.js | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/coral-embed-stream/src/components/AllCommentsPane.js b/client/coral-embed-stream/src/components/AllCommentsPane.js index 7166aa6e9..6c5d6bb23 100644 --- a/client/coral-embed-stream/src/components/AllCommentsPane.js +++ b/client/coral-embed-stream/src/components/AllCommentsPane.js @@ -93,6 +93,7 @@ class AllCommentsPane extends React.Component { viewNewComments = () => { this.setState(resetCursors); + this.props.emit('ui.AllCommentsPane.viewNewComments'); }; // getVisibileComments returns a list containing comments @@ -142,6 +143,7 @@ class AllCommentsPane extends React.Component { charCountEnable, maxCharCount, editComment, + emit, } = this.props; const {loadingState} = this.state; @@ -181,6 +183,7 @@ class AllCommentsPane extends React.Component { charCountEnable={charCountEnable} maxCharCount={maxCharCount} editComment={editComment} + emit={emit} />; })} diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index 34f672d8a..a8bba1ca3 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -224,6 +224,7 @@ export default class Comment extends React.Component { return; } this.setState(resetCursors); + this.props.emit('ui.Comment.showMoreReplies'); }; showReplyBox = () => { diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index 1e0ff7ea9..7b9e5f566 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -292,6 +292,7 @@ class Stream extends React.Component { charCountEnable={asset.settings.charCountEnable} maxCharCount={asset.settings.charCount} editComment={editComment} + emit={this.props.emit} /> diff --git a/client/coral-embed-stream/src/containers/Stream.js b/client/coral-embed-stream/src/containers/Stream.js index fcedbcb0b..73676713c 100644 --- a/client/coral-embed-stream/src/containers/Stream.js +++ b/client/coral-embed-stream/src/containers/Stream.js @@ -14,7 +14,7 @@ import {editName} from 'coral-framework/actions/user'; import {setActiveReplyBox, setActiveTab, viewAllComments} from '../actions/stream'; import Stream from '../components/Stream'; import Comment from './Comment'; -import {withFragments} from 'coral-framework/hocs'; +import {withFragments, withEmit} from 'coral-framework/hocs'; import {getDefinitionName, getSlotFragmentSpreads} from 'coral-framework/utils'; import {Spinner} from 'coral-ui'; import { @@ -326,6 +326,7 @@ const mapDispatchToProps = (dispatch) => export default compose( withFragments(fragments), + withEmit, connect(mapStateToProps, mapDispatchToProps), withPostComment, withPostFlag, diff --git a/plugin-api/beta/client/hocs/index.js b/plugin-api/beta/client/hocs/index.js index 68547692d..60b118522 100644 --- a/plugin-api/beta/client/hocs/index.js +++ b/plugin-api/beta/client/hocs/index.js @@ -3,3 +3,4 @@ export {default as withTags} from './withTags'; export {default as withFragments} from 'coral-framework/hocs/withFragments'; export {default as excludeIf} from 'coral-framework/hocs/excludeIf'; export {default as connect} from 'coral-framework/hocs/connect'; +export {default as withEmit} from 'coral-framework/hocs/withEmit';