From 0f515366f5bb1942f68a107e9f9895ceb5f1dad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Mon, 23 Mar 2015 23:44:31 +0100 Subject: [PATCH] Bugfix stratgy rendering inside create feature form --- public/js/UnleashApp.jsx | 8 ++++---- .../js/__tests__/components/feature/FeatureForm-test.js | 4 ++-- public/js/components/TabView.jsx | 2 +- public/js/components/feature/FeatureForm.jsx | 9 ++++----- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/public/js/UnleashApp.jsx b/public/js/UnleashApp.jsx index e15b0d1256..fb804ed8a9 100644 --- a/public/js/UnleashApp.jsx +++ b/public/js/UnleashApp.jsx @@ -15,22 +15,22 @@ var tabPanes = [ { name: 'Feature Toggles', slug: 'feature-toggles', - content: new FeatureTogglesComponent({}) + content: FeatureTogglesComponent }, { name: 'Strategies', slug: 'strategies', - content: new StrategiesComponent({}) + content: StrategiesComponent }, { name: "Log", slug: 'log', - content: new LogEntriesComponent({}) + content: LogEntriesComponent }, { name: "Archive", slug: 'archive', - content: new ArchiveFeatureComponent({}) + content: ArchiveFeatureComponent } ]; diff --git a/public/js/__tests__/components/feature/FeatureForm-test.js b/public/js/__tests__/components/feature/FeatureForm-test.js index 93fe28f78b..72c0a9b9f2 100644 --- a/public/js/__tests__/components/feature/FeatureForm-test.js +++ b/public/js/__tests__/components/feature/FeatureForm-test.js @@ -24,11 +24,11 @@ describe("FeatureForm", function () { describe("edit", function () { var feature = {name: "Test", strategy: "unknown"}; - it("should show unknown strategy as deleted", function () { + it("should show unknown strategy as default", function () { Component = TestUtils .renderIntoDocument(); var strategySelect = Component.getDOMNode().querySelector("select"); - expect(strategySelect.value).toEqual("unknown (deleted)"); + expect(strategySelect.value).toEqual("default"); }); }); diff --git a/public/js/components/TabView.jsx b/public/js/components/TabView.jsx index 2a3e03aee7..4cfcb76970 100644 --- a/public/js/components/TabView.jsx +++ b/public/js/components/TabView.jsx @@ -48,7 +48,7 @@ var TabView = React.createClass({
- {this.state.activeTab.content} + {new this.state.activeTab.content()}
diff --git a/public/js/components/feature/FeatureForm.jsx b/public/js/components/feature/FeatureForm.jsx index da03d987b9..aeb7a31e08 100644 --- a/public/js/components/feature/FeatureForm.jsx +++ b/public/js/components/feature/FeatureForm.jsx @@ -30,17 +30,16 @@ var FeatureForm = React.createClass({ }, setSelectedStrategy: function(name) { - var selectedStrategy = this.state.strategyOptions.filter(function(strategy) { + var selectedStrategy = this.props.strategies.filter(function(strategy) { return strategy.name === name; })[0]; if(selectedStrategy) { this.setStrategyParams(selectedStrategy); } else { - var updatedStrategyName = name + " (deleted)"; this.setState({ - currentStrategy: updatedStrategyName, - strategyOptions: this.state.strategyOptions.concat([{name: updatedStrategyName}]) + currentStrategy: 'default', + requiredParams: [] }); } }, @@ -129,7 +128,7 @@ var FeatureForm = React.createClass({ }, renderStrategyOptions: function() { - return this.state.strategyOptions.map(function(strategy) { + return this.props.strategies.map(function(strategy) { return (