From d6fba2d515c1a82a7d7cd4b2caff5040c09d632d Mon Sep 17 00:00:00 2001 From: okbel Date: Tue, 20 Mar 2018 11:52:44 -0300 Subject: [PATCH] refactor into using config reducer --- .../coral-embed-stream/src/constants/debug.js | 2 -- .../src/reducers/configure.js | 2 +- .../coral-embed-stream/src/reducers/debug.js | 20 ------------------- client/coral-framework/components/Slot.js | 16 ++++++--------- client/coral-framework/constants/config.js | 2 ++ client/coral-framework/reducers/config.js | 14 ++++++++++++- 6 files changed, 22 insertions(+), 34 deletions(-) delete mode 100644 client/coral-embed-stream/src/constants/debug.js delete mode 100644 client/coral-embed-stream/src/reducers/debug.js diff --git a/client/coral-embed-stream/src/constants/debug.js b/client/coral-embed-stream/src/constants/debug.js deleted file mode 100644 index d31784af9..000000000 --- a/client/coral-embed-stream/src/constants/debug.js +++ /dev/null @@ -1,2 +0,0 @@ -export const ENABLE_PLUGINS_DEBUG = 'ENABLE_PLUGINS_DEBUG'; -export const DISABLE_PLUGINS_DEBUG = 'DISABLE_PLUGINS_DEBUG'; diff --git a/client/coral-embed-stream/src/reducers/configure.js b/client/coral-embed-stream/src/reducers/configure.js index 41d87f8d8..48b28ec72 100644 --- a/client/coral-embed-stream/src/reducers/configure.js +++ b/client/coral-embed-stream/src/reducers/configure.js @@ -8,7 +8,7 @@ const initialState = { errors: {}, }; -export default function config(state = initialState, action) { +export default function configure(state = initialState, action) { switch (action.type) { case actions.UPDATE_PENDING: { let next = state; diff --git a/client/coral-embed-stream/src/reducers/debug.js b/client/coral-embed-stream/src/reducers/debug.js deleted file mode 100644 index bcd919ebf..000000000 --- a/client/coral-embed-stream/src/reducers/debug.js +++ /dev/null @@ -1,20 +0,0 @@ -import * as actions from '../constants/debug'; - -const initialState = { - plugins: false, -}; - -export default function DEBUG(state = initialState, action) { - switch (action.type) { - case actions.ENABLE_PLUGINS_DEBUG: - return { - plugins: true, - }; - case actions.DISABLE_PLUGINS_DEBUG: - return { - plugins: false, - }; - default: - return state; - } -} diff --git a/client/coral-framework/components/Slot.js b/client/coral-framework/components/Slot.js index b4b0a725a..d60d69185 100644 --- a/client/coral-framework/components/Slot.js +++ b/client/coral-framework/components/Slot.js @@ -69,7 +69,6 @@ class Slot extends React.Component { defaultComponent: DefaultComponent, queryData, fill, - debug = {}, } = this.props; const { plugins } = this.context; let children = this.getChildren(); @@ -95,19 +94,18 @@ class Slot extends React.Component { children = children.map(childFactory); } - const debugProps = - debug.plugins || pluginsConfig.debug - ? { - 'data-slot-name': fill, - } - : {}; + const debugProps = pluginsConfig.debug + ? { + 'data-slot-name': fill, + } + : {}; return ( ({ reduxState: state, - debug: state.debug, }); export default connect(mapStateToProps, null)(Slot); diff --git a/client/coral-framework/constants/config.js b/client/coral-framework/constants/config.js index bf846af1d..b18b67387 100644 --- a/client/coral-framework/constants/config.js +++ b/client/coral-framework/constants/config.js @@ -1,3 +1,5 @@ const prefix = `TALK_FRAMEWORK`; export const MERGE_CONFIG = `${prefix}_MERGE_CONFIG`; +export const ENABLE_PLUGINS_DEBUG = `${prefix}_ENABLE_PLUGINS_DEBUG`; +export const DISABLE_PLUGINS_DEBUG = `${prefix}_DISABLE_PLUGINS_DEBUG`; diff --git a/client/coral-framework/reducers/config.js b/client/coral-framework/reducers/config.js index f7aebd9e2..eccc0d4bf 100644 --- a/client/coral-framework/reducers/config.js +++ b/client/coral-framework/reducers/config.js @@ -1,10 +1,22 @@ -import { MERGE_CONFIG } from '../constants/config'; +import { + MERGE_CONFIG, + ENABLE_PLUGINS_DEBUG, + DISABLE_PLUGINS_DEBUG, +} from '../constants/config'; import { LOGOUT } from '../constants/auth'; const initialState = {}; export default function config(state = initialState, action) { switch (action.type) { + case ENABLE_PLUGINS_DEBUG: + return { + plugins: true, + }; + case DISABLE_PLUGINS_DEBUG: + return { + plugins: false, + }; case LOGOUT: return { ...state,