diff --git a/unleash-server/public/js/unleash.jsx b/unleash-server/public/js/unleash.jsx index eadc60c70a..9cc7c0317a 100644 --- a/unleash-server/public/js/unleash.jsx +++ b/unleash-server/public/js/unleash.jsx @@ -18,44 +18,72 @@ var FeatureForm = React.createClass({ + getInitialState: function () { + return {name: '', description: '', strategy: 'Default'}; + }, + + handleNameChange: function(e) { this.setState({name: e.target.value.trim()}); }, + handleDescriptionChange: function(e) { this.setState({description: e.target.value.trim()}); }, + handleStrategyChange: function(e) { this.setState({strategy: e.target.value.trim()}); }, + + handleSubmit: function(e) { + e.preventDefault(); + this.props.onFeatureSubmit(this.state); + return; + }, + render: function () { return ( -
+
Add a new feature
- +
- +

Give the feature a name

- +
- +

Describe the feature

- +
- +
-
- +
@@ -152,7 +180,7 @@ var FeatureList = React.createClass({ f[changeRequest.field] = changeRequest.value; } }); - console.log(changeRequest); + reqwest({ url: 'features/' + changeRequest.name, method: 'patch', @@ -166,6 +194,20 @@ var FeatureList = React.createClass({ }.bind(this)); }, + createFeature: function (feature, callback) { + reqwest({ + url: 'features', + method: 'post', + type: 'json', + contentType: 'application/json', + data: JSON.stringify(feature) + }).then(function() { + // how do we communicate success? + }.bind(this), function() { + window.alert('create failed'); + }.bind(this)); + }, + render: function () { var featureNodes = this.state.features.map(function (feature) { return ( @@ -180,7 +222,7 @@ var FeatureList = React.createClass({
{featureNodes} - +
);