mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
minor refactor
This commit is contained in:
parent
a176e72186
commit
b8359954fe
@ -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",
|
||||
|
31
packages/unleash-frontend-next/src/store/feature-store.js
Normal file
31
packages/unleash-frontend-next/src/store/feature-store.js
Normal 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;
|
@ -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;
|
@ -1,5 +1,5 @@
|
||||
import { combineReducers } from 'redux';
|
||||
import features from './features';
|
||||
import features from './feature-store';
|
||||
|
||||
const unleashStore = combineReducers({
|
||||
features,
|
||||
|
@ -1,6 +0,0 @@
|
||||
export const urls = {
|
||||
features: '/features',
|
||||
strategies: '/strategies',
|
||||
events: '/events',
|
||||
archive: '/archive/features',
|
||||
};
|
Loading…
Reference in New Issue
Block a user