From ace938dc23c550e8de35fd7103bc3128262febc8 Mon Sep 17 00:00:00 2001 From: Jari Bakken Date: Thu, 23 Oct 2014 16:00:13 +0200 Subject: [PATCH] UI stuff --- unleash-server/public/js/unleash.jsx | 52 ++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/unleash-server/public/js/unleash.jsx b/unleash-server/public/js/unleash.jsx index 519a41ac16..cf951ed54a 100644 --- a/unleash-server/public/js/unleash.jsx +++ b/unleash-server/public/js/unleash.jsx @@ -5,18 +5,21 @@ // Meny // FeatureList // Feature -// - name -// - status -// - description +// FeatureViewer +// - props // - button-edit // - button-delete // - toggle-status +// FeatureEditor +// - name +// - status +// - description // // NewFeaturePage // Meny // NewFeatureForm -var FeatureForm = React.createClass({ +var FeatureEditor = React.createClass({ getInitialState: function () { return {name: '', description: '', strategy: 'Default'}; @@ -84,16 +87,20 @@ var FeatureForm = React.createClass({
+
- ); } }); -var Feature = React.createClass({ +var FeatureViewer = React.createClass({ // TODO: validate props? handleEnableChange: function(event) { var feature = this.props.feature; @@ -101,7 +108,7 @@ var Feature = React.createClass({ name: feature.name, field: 'enabled', value: event.target.checked - }); + }); }, render: function () { @@ -144,7 +151,7 @@ var Feature = React.createClass({
- +
@@ -158,6 +165,32 @@ var Feature = React.createClass({ } }); +var Feature = React.createClass({ + getInitialState: function() { + return { mode: 'view' }; + }, + + onToggleMode: function() { + if (this.state.mode === 'view') { + this.setState({mode: 'edit'}); + } else if (this.state.mode === 'edit') { + this.setState({mode: 'view'}); + } else { + throw "invalid mode: " + this.state.mode; + } + }, + + render: function() { + if (this.state.mode === 'view') { + return (); + } else if (this.state.mode === 'edit') { + return (); + } else { + throw "invalid mode: " + this.state.mode; + } + } +}); + var FeatureList = React.createClass({ getInitialState: function() { return { @@ -199,7 +232,7 @@ var FeatureList = React.createClass({ }.bind(this)); }, - createFeature: function (feature, callback) { + createFeature: function (feature) { reqwest({ url: 'features', method: 'post', @@ -227,7 +260,6 @@ var FeatureList = React.createClass({
{featureNodes} -
);