diff --git a/packages/unleash-frontend-next/package.json b/packages/unleash-frontend-next/package.json index 5af42c2565..1bc5a34c67 100644 --- a/packages/unleash-frontend-next/package.json +++ b/packages/unleash-frontend-next/package.json @@ -33,6 +33,7 @@ "main": "./index.js", "dependencies": { "immutability-helper": "^2.0.0", + "immutable": "^3.8.1", "normalize.css": "^4.2.0", "react": "^15.3.1", "react-addons-css-transition-group": "^15.3.1", diff --git a/packages/unleash-frontend-next/src/store/feature-store.js b/packages/unleash-frontend-next/src/store/feature-store.js new file mode 100644 index 0000000000..3c6506178a --- /dev/null +++ b/packages/unleash-frontend-next/src/store/feature-store.js @@ -0,0 +1,31 @@ +import Immutable from 'immutable'; + +import { + ADD_FEATURE_TOGGLE, + RECEIVE_FEATURE_TOGGLES, + UPDATE_FEATURE_TOGGLE, +} from './feature-actions'; + +const features = (state = [], action) => { + switch (action.type) { + case ADD_FEATURE_TOGGLE: + return [ + ...state, + action.featureToggle, + ]; + case UPDATE_FEATURE_TOGGLE: + return state.map(t => { + if (t.name !== action.featureToggle.name) { + return t; + } + return action.featureToggle; + }); + case RECEIVE_FEATURE_TOGGLES: { + return action.featureToggles; + } + default: + return state; + } +}; + +export default features; diff --git a/packages/unleash-frontend-next/src/store/features.js b/packages/unleash-frontend-next/src/store/features.js deleted file mode 100644 index 39fdf70042..0000000000 --- a/packages/unleash-frontend-next/src/store/features.js +++ /dev/null @@ -1,40 +0,0 @@ -import { - ADD_FEATURE_TOGGLE, - RECEIVE_FEATURE_TOGGLES, - UPDATE_FEATURE_TOGGLE, -} from './feature-actions'; - -const feature = (state = {}, action) => { - switch (action.type) { - case ADD_FEATURE_TOGGLE: - return action.featureToggle; - case UPDATE_FEATURE_TOGGLE: - if (state.name !== action.featureToggle.name) { - return state; - } - return action.featureToggle; - default: - return state; - } -}; - -const features = (state = [], action) => { - switch (action.type) { - case ADD_FEATURE_TOGGLE: - return [ - ...state, - feature(undefined, action), - ]; - case UPDATE_FEATURE_TOGGLE: - return state.map(t => - feature(t, action) - ); - case RECEIVE_FEATURE_TOGGLES: { - return action.featureToggles; - } - default: - return state; - } -}; - -export default features; diff --git a/packages/unleash-frontend-next/src/store/index.js b/packages/unleash-frontend-next/src/store/index.js index bebe5c7167..be388c0c9d 100644 --- a/packages/unleash-frontend-next/src/store/index.js +++ b/packages/unleash-frontend-next/src/store/index.js @@ -1,5 +1,5 @@ import { combineReducers } from 'redux'; -import features from './features'; +import features from './feature-store'; const unleashStore = combineReducers({ features, diff --git a/packages/unleash-frontend-next/src/store/urls.js b/packages/unleash-frontend-next/src/store/urls.js deleted file mode 100644 index 2f5d6621f5..0000000000 --- a/packages/unleash-frontend-next/src/store/urls.js +++ /dev/null @@ -1,6 +0,0 @@ -export const urls = { - features: '/features', - strategies: '/strategies', - events: '/events', - archive: '/archive/features', -};