var React = require('react'); var strategyStore = require('../../stores/StrategyStore'); var FeatureForm = React.createClass({ getInitialState: function() { return {strategyOptions: []}; }, componentWillMount: function() { strategyStore.getStrategies().then(this.handleStrategyResponse); }, handleStrategyResponse: function(response) { var strategyNames = response.strategies.map(function(strategy) { return strategy.name; }); this.setState({strategyOptions: strategyNames}); }, render: function() { var currentStrategy = this.props.feature ? this.props.feature.strategy : ""; var strategyNodes = this.state.strategyOptions.map(function(name) { return ( ); }); var feature = this.props.feature || { name: '', strategy: 'default', enabled: false }; return (
); }, saveFeature: function(e) { e.preventDefault(); var feature = { name: this.refs.name.getDOMNode().value, description: this.refs.description.getDOMNode().value, strategy: this.refs.strategy.getDOMNode().value, enabled: this.refs.enabled.getDOMNode().checked } this.props.onSubmit(feature); }, cancelFeature: function(e) { e.preventDefault(); this.props.onCancel(); } }); module.exports = FeatureForm;