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

add dummy strategies

This commit is contained in:
Ivar 2016-10-17 22:23:08 +02:00 committed by Ivar Conradi Østhus
parent 6e120546f7
commit 13f722bcaa
5 changed files with 40 additions and 7 deletions

View File

@ -3,6 +3,9 @@ import { connect } from 'react-redux';
import { Input, Switch, Button } from 'react-toolbox';
import { createFeatureToggles } from '../../store/feature-actions';
const mapStateToProps = (state) => ({
strategies: state.strategies.toJS(),
});
class AddFeatureToggle extends React.Component {
constructor () {
@ -23,6 +26,7 @@ class AddFeatureToggle extends React.Component {
static propTypes () {
return {
dispatch: PropTypes.func.isRequired,
strategies: PropTypes.array,
};
}
@ -51,7 +55,12 @@ class AddFeatureToggle extends React.Component {
renderAddStrategy () {
if (this.state.showAddStrategy) {
return <h4>Adding strat</h4>;
return (
<div>
<h4>Adding strat</h4>
<p>Possible: {this.props.strategies.map(s => s.name).join(', ')}</p>
</div>
);
} else {
return <a onClick={this.addStrategy} href="#addStrategy">Add strategy..</a>;
}
@ -101,4 +110,4 @@ class AddFeatureToggle extends React.Component {
}
}
export default connect()(AddFeatureToggle);
export default connect(mapStateToProps)(AddFeatureToggle);

View File

@ -4,6 +4,7 @@ import FeatureList from './FeatureList';
const mapStateToProps = (state) => ({
features: state.features.toJS(),
strategies: state.strategies.toJS(),
});
const mapDispatchToProps = {

View File

@ -1,4 +1,4 @@
import { List, Map } from 'immutable';
import { List, Map as $Map } from 'immutable';
import {
@ -11,17 +11,17 @@ import {
const features = (state = new List([]), action) => {
switch (action.type) {
case ADD_FEATURE_TOGGLE:
return state.push(new Map(action.featureToggle));
return state.push(new $Map(action.featureToggle));
case UPDATE_FEATURE_TOGGLE:
return state.map(t => {
return state.$Map(t => {
if (t.get('name') === action.featureToggle.name) {
return new Map(action.featureToggle);
return new $Map(action.featureToggle);
} else {
return t;
}
});
case RECEIVE_FEATURE_TOGGLES:
return new List(action.featureToggles.map(t => new Map(t)));
return new List(action.featureToggles.$Map(t => new $Map(t)));
default:
return state;
}

View File

@ -1,8 +1,10 @@
import { combineReducers } from 'redux';
import features from './feature-store';
import strategies from './strategy-store';
const unleashStore = combineReducers({
features,
strategies,
});
export default unleashStore;

View File

@ -0,0 +1,21 @@
import { List, Map as $Map } from 'immutable';
const init = new List([
new $Map({ name: 'default', description: 'Default on/off strategy' }),
new $Map(
{
name: 'ActiveForUserWithEmail',
description: 'Active for user with specified email',
parametersTemplate: { emails: 'string' },
}),
]);
const strategies = (state = init, action) => {
switch (action.type) {
default:
return state;
}
};
export default strategies;