diff --git a/packages/unleash-frontend-next/src/component/feature/AddFeatureToggle.jsx b/packages/unleash-frontend-next/src/component/feature/AddFeatureToggle.jsx
index ba5937df87..f9371286f7 100644
--- a/packages/unleash-frontend-next/src/component/feature/AddFeatureToggle.jsx
+++ b/packages/unleash-frontend-next/src/component/feature/AddFeatureToggle.jsx
@@ -1,9 +1,7 @@
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
-import { Input, Switch, Button } from 'react-toolbox';
import { createFeatureToggles } from '../../store/feature-actions';
-import AddFeatureToggleStrategy from './AddFeatureToggleStrategy';
-import ConfiguredStrategies from './ConfiguredStrategies';
+import AddFeatureToggleUI from './AddFeatureToggleUI';
const mapStateToProps = (state) => ({
strategies: state.strategies.toJS(),
@@ -13,12 +11,10 @@ class AddFeatureToggle extends React.Component {
constructor () {
super();
this.state = {
- featureToggle: {
- name: '',
- description: '',
- enabled: false,
- strategies: [],
- },
+ name: '',
+ description: '',
+ enabled: false,
+ strategies: [],
};
}
@@ -35,79 +31,44 @@ class AddFeatureToggle extends React.Component {
onSubmit = (evt) => {
evt.preventDefault();
- this.props.dispatch(createFeatureToggles(this.state.featureToggle));
+ this.props.dispatch(createFeatureToggles(this.state));
this.context.router.push('/features');
};
- handleChange = (key, value) => {
+ onCancel = (evt) => {
+ evt.preventDefault();
+ this.context.router.push('/features');
+ };
+
+ updateField = (key, value) => {
const change = {};
change[key] = value;
- const updatedFeatureToggle = Object.assign({}, this.state.featureToggle, change);
-
- this.setState({ featureToggle: updatedFeatureToggle });
+ this.setState(change);
};
addStrategy = (strategy) => {
- const strategies = this.state.featureToggle.strategies;
+ const strategies = this.state.strategies;
strategies.push(strategy);
- const updatedFeatureToggle = Object.assign({}, this.state.featureToggle, { strategies });
- this.setState({ featureToggle: updatedFeatureToggle });
+ this.setState({ strategies });
}
removeStrategy = (strategy) => {
- const strategies = this.state.featureToggle.strategies.filter(s => s !== strategy);
- const updatedFeatureToggle = Object.assign({}, this.state.featureToggle, { strategies });
- this.setState({ featureToggle: updatedFeatureToggle });
+ const strategies = this.state.strategies.filter(s => s !== strategy);
+ this.setState({ strategies });
}
render () {
- const configuredStrategies = this.state.featureToggle.strategies;
-
return (
);
}
diff --git a/packages/unleash-frontend-next/src/component/feature/AddFeatureToggleUI.jsx b/packages/unleash-frontend-next/src/component/feature/AddFeatureToggleUI.jsx
new file mode 100644
index 0000000000..0fc10c51de
--- /dev/null
+++ b/packages/unleash-frontend-next/src/component/feature/AddFeatureToggleUI.jsx
@@ -0,0 +1,72 @@
+import React, { PropTypes } from 'react';
+import { Input, Switch, Button } from 'react-toolbox';
+import AddFeatureToggleStrategy from './AddFeatureToggleStrategy';
+import ConfiguredStrategies from './ConfiguredStrategies';
+
+class AddFeatureToggleUI extends React.Component {
+ static propTypes () {
+ return {
+ strategies: PropTypes.array.required,
+ featureToggle: PropTypes.object,
+ updateField: PropTypes.func.required,
+ addStrategy: PropTypes.func.required,
+ removeStrategy: PropTypes.func.required,
+ onSubmit: PropTypes.func.required,
+ onCancel: PropTypes.func.required,
+ };
+ }
+
+ render () {
+ const configuredStrategies = this.props.featureToggle.strategies;
+
+ return (
+
+ );
+ }
+}
+
+export default AddFeatureToggleUI;
diff --git a/packages/unleash-frontend-next/src/component/feature/EditFeatureToggle.jsx b/packages/unleash-frontend-next/src/component/feature/EditFeatureToggle.jsx
new file mode 100644
index 0000000000..bcb407a4e0
--- /dev/null
+++ b/packages/unleash-frontend-next/src/component/feature/EditFeatureToggle.jsx
@@ -0,0 +1,41 @@
+import React, { PropTypes } from 'react';
+import { connect } from 'react-redux';
+
+const mapStateToProps = (state) => ({
+ strategies: state.strategies.toJS(),
+});
+
+class EditFeatureToggle extends React.Component {
+ constructor () {
+ super();
+ this.state = {
+ featureToggle: {
+ name: '',
+ description: '',
+ enabled: false,
+ strategies: [],
+ },
+ };
+ }
+
+ static propTypes () {
+ return {
+ dispatch: PropTypes.func.isRequired,
+ strategies: PropTypes.array,
+ };
+ }
+
+ static contextTypes = {
+ router: React.PropTypes.object,
+ }
+
+ render () {
+ return (
+
+ );
+ }
+}
+
+export default connect(mapStateToProps)(EditFeatureToggle);
diff --git a/packages/unleash-frontend-next/src/component/feature/Feature.jsx b/packages/unleash-frontend-next/src/component/feature/Feature.jsx
index c975e20160..e917e73da9 100644
--- a/packages/unleash-frontend-next/src/component/feature/Feature.jsx
+++ b/packages/unleash-frontend-next/src/component/feature/Feature.jsx
@@ -2,6 +2,7 @@
import React, { PropTypes } from 'react';
import { Switch, FontIcon } from 'react-toolbox';
+import { Link } from 'react-router';
const Feature = ({ onClick, name, enabled, strategies }) => (
@@ -9,7 +10,9 @@ const Feature = ({ onClick, name, enabled, strategies }) => (
{name} |
{strategies.map(s => s.name).join(', ')} |
-
+
+
+
|
diff --git a/packages/unleash-frontend-next/src/index.jsx b/packages/unleash-frontend-next/src/index.jsx
index 27243b0abf..a16fa4e1e2 100644
--- a/packages/unleash-frontend-next/src/index.jsx
+++ b/packages/unleash-frontend-next/src/index.jsx
@@ -10,6 +10,7 @@ import App from './App';
import Features from './page/features';
import CreateFeatureToggle from './page/features/create';
+import EditFeatureToggle from './page/features/edit';
import Strategies from './page/strategies';
import HistoryPage from './page/history';
import Archive from './page/archive';
@@ -28,6 +29,7 @@ ReactDOM.render(
+
diff --git a/packages/unleash-frontend-next/src/page/features/edit.js b/packages/unleash-frontend-next/src/page/features/edit.js
new file mode 100644
index 0000000000..f7794ffce7
--- /dev/null
+++ b/packages/unleash-frontend-next/src/page/features/edit.js
@@ -0,0 +1,13 @@
+import React, { Component } from 'react';
+import EditFeatureToggle from '../../component/feature/EditFeatureToggle';
+
+export default class Features extends Component {
+ render () {
+ return (
+
+
Edit Feature Toggle
+
+
+ );
+ }
+};