diff --git a/unleash-server/public/js/unleash.jsx b/unleash-server/public/js/unleash.jsx
index 0f85e4e970..6c9818ba3e 100644
--- a/unleash-server/public/js/unleash.jsx
+++ b/unleash-server/public/js/unleash.jsx
@@ -14,12 +14,66 @@ var Menu = React.createClass({
var UnsavedFeature = React.createClass({
- // TODO: form
- render: function() { return
Features
-
@@ -86,7 +148,6 @@ var FeatureList = React.createClass({
var ErrorMessages = React.createClass({
-
render: function() {
if (!this.props.errors.length) {
return
;
@@ -151,7 +212,40 @@ var Unleash = React.createClass({
},
createFeature: function (feature) {
- console.log(feature);
+ var unsaved = [], state = this.state;
+
+ this.state.unsavedFeatures.forEach(function(f) {
+ // TODO: make sure we don't overwrite an existing feature
+ if (f.name === feature.name) {
+ state.savedFeatures.unshift(f);
+ } else {
+ unsaved.push(f);
+ }
+ });
+
+ this.setState({unsavedFeatures: unsaved});
+
+ reqwest({
+ url: 'features',
+ method: 'post',
+ type: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(feature)
+ }).then(function(r) {
+ console.log(r);
+ }.bind(this), this.handleError);
+ },
+
+ newFeature: function() {
+ var blankFeature = {
+ name: '',
+ enabled: false,
+ strategy: 'default',
+ parameters: {}
+ };
+
+ this.state.unsavedFeatures.push(blankFeature);
+ this.forceUpdate();
},
render: function() {
@@ -163,7 +257,9 @@ var Unleash = React.createClass({
unsavedFeatures={this.state.unsavedFeatures}
savedFeatures={this.state.savedFeatures}
onFeatureChanged={this.updateFeature}
- onFeatureSubmit={this.createFeature} />
+ onFeatureSubmit={this.createFeature}
+ onNewFeature={this.newFeature}
+ />
);
}