var React = require('react');
var Feature = require('./Feature');
var noop = function() {};
var FeatureList = React.createClass({
propTypes: {
features: React.PropTypes.array.isRequired,
strategies: React.PropTypes.array.isRequired
},
getDefaultProps: function() {
return {
onFeatureChanged: noop,
onFeatureArchive: noop
};
},
getInitialState: function() {
return {
filter: undefined
};
},
onFilterChange: function(e) {
e.preventDefault();
this.setState({filter: e.target.value.trim()});
},
filteredFeatures: function() {
if(this.state.filter) {
var regex = new RegExp(this.state.filter, "i");
return this.props.features.filter(function(item) {
return regex.test(item.name) || regex.test(item.strategy);
}.bind(this));
} else {
return this.props.features;
}
},
render: function() {
var featureNodes = this.filteredFeatures().map(function(feature) {
return (
Name | Strategy | ||
---|---|---|---|