1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

minor refactor

This commit is contained in:
Ivar 2016-10-17 21:23:15 +02:00 committed by Ivar Conradi Østhus
parent a176e72186
commit b8359954fe
5 changed files with 33 additions and 47 deletions

View File

@ -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",

View File

@ -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;

View File

@ -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;

View File

@ -1,5 +1,5 @@
import { combineReducers } from 'redux';
import features from './features';
import features from './feature-store';
const unleashStore = combineReducers({
features,

View File

@ -1,6 +0,0 @@
export const urls = {
features: '/features',
strategies: '/strategies',
events: '/events',
archive: '/archive/features',
};