+
{children}
);
@@ -21,7 +21,7 @@ Slot.propTypes = {
fill: React.PropTypes.string
};
-const mapStateToProps = ({config: {plugin_config = {}}}) => ({plugin_config});
+const mapStateToProps = (state) => ({pluginConfig: state.config.plugin_config});
export default connect(mapStateToProps, null)(Slot);
diff --git a/client/coral-framework/constants/auth.js b/client/coral-framework/constants/auth.js
index 57bde6f3f..324f75f44 100644
--- a/client/coral-framework/constants/auth.js
+++ b/client/coral-framework/constants/auth.js
@@ -3,6 +3,8 @@ export const CLEAN_STATE = 'CLEAN_STATE';
export const SHOW_SIGNIN_DIALOG = 'SHOW_SIGNIN_DIALOG';
export const HIDE_SIGNIN_DIALOG = 'HIDE_SIGNIN_DIALOG';
+export const FOCUS_SIGNIN_DIALOG = 'FOCUS_SIGNIN_DIALOG';
+export const BLUR_SIGNIN_DIALOG = 'BLUR_SIGNIN_DIALOG';
export const CREATE_USERNAME_REQUEST = 'CREATE_USERNAME_REQUEST';
export const CREATE_USERNAME_SUCCESS = 'CREATE_USERNAME_SUCCESS';
diff --git a/client/coral-framework/helpers/plugins.js b/client/coral-framework/helpers/plugins.js
index 625a0ee3f..55fdaf6c5 100644
--- a/client/coral-framework/helpers/plugins.js
+++ b/client/coral-framework/helpers/plugins.js
@@ -7,32 +7,31 @@ import flatten from 'lodash/flatten';
import flattenDeep from 'lodash/flattenDeep';
import {getDefinitionName, mergeDocuments} from 'coral-framework/utils';
import {loadTranslations} from 'coral-framework/services/i18n';
-import {injectReducers, getStore} from 'coral-framework/services/store';
+import {injectReducers} from 'coral-framework/services/store';
import camelize from './camelize';
-export function getSlotComponents(slot) {
- const pluginConfig = getStore().getState().config.plugin_config;
-
+export function getSlotComponents(slot, pluginConfig, props = {}) {
return flatten(plugins
- // Filter out components that have slots and have been disabled in `plugin_config`
+ // Filter out components that have slots and have been disabled in `plugin_config`
.filter((o) => o.module.slots && (!pluginConfig || !pluginConfig[o.name] || !pluginConfig[o.name].disable_components))
.filter((o) => o.module.slots[slot])
.map((o) => o.module.slots[slot])
- );
+ )
+ .filter((component) => !component.isExcluded || !component.isExcluded({...props, config: pluginConfig}));
}
-export function isSlotEmpty(slot) {
- return getSlotComponents(slot).length === 0;
+export function isSlotEmpty(slot, pluginConfig, props) {
+ return getSlotComponents(slot, pluginConfig, props).length === 0;
}
/**
* Returns React Elements for given slot.
*/
-export function getSlotElements(slot, props = {}) {
- return getSlotComponents(slot)
- .map((component, i) => React.createElement(component, {key: i, ...props}));
+export function getSlotElements(slot, pluginConfig, props = {}) {
+ return getSlotComponents(slot, pluginConfig, props)
+ .map((component, i) => React.createElement(component, {key: i, ...props, config: pluginConfig}));
}
function getComponentFragments(components) {
diff --git a/client/coral-framework/hocs/excludeIf.js b/client/coral-framework/hocs/excludeIf.js
new file mode 100644
index 000000000..ec2f0f27a
--- /dev/null
+++ b/client/coral-framework/hocs/excludeIf.js
@@ -0,0 +1,4 @@
+export default (condition) => (BaseComponent) => {
+ BaseComponent.isExcluded = condition;
+ return BaseComponent;
+};
diff --git a/client/coral-framework/hocs/withFragments.js b/client/coral-framework/hocs/withFragments.js
index d62d62ae3..62e96444c 100644
--- a/client/coral-framework/hocs/withFragments.js
+++ b/client/coral-framework/hocs/withFragments.js
@@ -1,14 +1,5 @@
-import React from 'react';
-import {getDisplayName} from '../helpers/hoc';
-
// TODO: revisit `filtering` after https://github.com/apollographql/graphql-anywhere/issues/38.
-export default (fragments) => (WrappedComponent) => {
- class WithFragments extends React.Component {
- render() {
- return
;
- }
- }
- WithFragments.fragments = fragments;
- WithFragments.displayName = `WithFragments(${getDisplayName(WrappedComponent)})`;
- return WithFragments;
+export default (fragments) => (BaseComponent) => {
+ BaseComponent.fragments = fragments;
+ return BaseComponent;
};
diff --git a/client/coral-framework/reducers/auth.js b/client/coral-framework/reducers/auth.js
index 92d676abe..5481b7a5e 100644
--- a/client/coral-framework/reducers/auth.js
+++ b/client/coral-framework/reducers/auth.js
@@ -7,6 +7,7 @@ const initialState = Map({
loggedIn: false,
user: null,
showSignInDialog: false,
+ signInDialogFocus: false,
showCreateUsernameDialog: false,
checkedInitialLogin: false,
view: 'SIGNIN',
@@ -29,13 +30,21 @@ const purge = (user) => {
export default function auth (state = initialState, action) {
switch (action.type) {
+ case actions.FOCUS_SIGNIN_DIALOG:
+ return state
+ .set('signInDialogFocus', true);
+ case actions.BLUR_SIGNIN_DIALOG:
+ return state
+ .set('signInDialogFocus', false);
case actions.SHOW_SIGNIN_DIALOG :
return state
- .set('showSignInDialog', true);
+ .set('showSignInDialog', true)
+ .set('signInDialogFocus', true);
case actions.HIDE_SIGNIN_DIALOG :
return state.merge(Map({
isLoading: false,
showSignInDialog: false,
+ signInDialogFocus: false,
view: 'SIGNIN',
error: '',
passwordRequestFailure: null,
diff --git a/plugin-api/beta/client/hocs/index.js b/plugin-api/beta/client/hocs/index.js
index 7f3476cfd..ed8b5cec4 100644
--- a/plugin-api/beta/client/hocs/index.js
+++ b/plugin-api/beta/client/hocs/index.js
@@ -1,2 +1,3 @@
export {default as withReaction} from './withReaction';
export {default as withFragments} from 'coral-framework/hocs/withFragments';
+export {default as excludeIf} from 'coral-framework/hocs/excludeIf';
diff --git a/plugin-api/beta/client/selectors/index.js b/plugin-api/beta/client/selectors/index.js
new file mode 100644
index 000000000..09e25d453
--- /dev/null
+++ b/plugin-api/beta/client/selectors/index.js
@@ -0,0 +1 @@
+export const pluginConfigSelector = (state) => state.config.pluginConfig;
diff --git a/plugins/talk-plugin-featured/client/containers/Tab.js b/plugins/talk-plugin-featured/client/containers/Tab.js
index 0bcb49e13..f5d5678e6 100644
--- a/plugins/talk-plugin-featured/client/containers/Tab.js
+++ b/plugins/talk-plugin-featured/client/containers/Tab.js
@@ -1,5 +1,6 @@
import {compose, gql} from 'react-apollo';
import withFragments from 'coral-framework/hocs/withFragments';
+import excludeIf from 'coral-framework/hocs/excludeIf';
import Tab from '../components/Tab';
// TODO: This is just example code, and needs to replaced by an actual implementation.
@@ -12,6 +13,7 @@ const enhance = compose(
}
}`,
}),
+ excludeIf((props) => props.asset.recentComments.length === 0)
);
export default enhance(Tab);