/** @jsx React.DOM */
/* jshint quotmark:false */
// Unleash
// - Menu
// - FeatureList
// - UnsavedFeature
// - SavedFeature
//
var Menu = React.createClass({
render: function() { return
; }
});
var UnsavedFeature = React.createClass({
// TODO: form
render: function() { return ; }
});
var SavedFeature = React.createClass({
render: function() {
return (
{this.props.feature.name}
);
}
});
var FeatureList = React.createClass({
render: function() {
var featureNodes = [];
this.props.unsavedFeatures.forEach(function(feature) {
featureNodes.push();
});
this.props.savedFeatures.forEach(function(feature) {
featureNodes.push(
);
});
return ({featureNodes}
);
}
});
var Unleash = React.createClass({
getInitialState: function() {
return { savedFeatures: [], unsavedFeatures: [] };
},
componentDidMount: function () {
this.loadFeaturesFromServer();
setInterval(this.loadFeaturesFromServer, this.props.pollInterval);
},
loadFeaturesFromServer: function () {
reqwest('features').then(this.setFeatures, this.handleError);
},
setFeatures: function (data) {
this.setState({savedFeatures: data.features});
},
handleError: function (error) {
// TODO: ErrorComponent
window.alert(error);
},
updateFeature: function (changeRequest) {
console.log(changeRequest);
},
createFeature: function (feature) {
console.log(feature);
},
render: function() {
return (
);
}
});
React.renderComponent(
,
document.getElementById('content')
);