diff --git a/frontend/src/component/feature/form-add-container.jsx b/frontend/src/component/feature/form-add-container.jsx index d058ce0cf8..9699f49c36 100644 --- a/frontend/src/component/feature/form-add-container.jsx +++ b/frontend/src/component/feature/form-add-container.jsx @@ -31,7 +31,7 @@ const prepare = (methods, dispatch) => { createFeatureToggles(input)(dispatch) .then(() => methods.clear()) - .then(() => hashHistory.push(`/features/edit/${input.name}`)); + .then(() => hashHistory.push(`/features/strategies/${input.name}`)); }; methods.onCancel = evt => { diff --git a/frontend/src/component/feature/form-edit-container.jsx b/frontend/src/component/feature/form-edit-container.jsx index 9b68e43b33..f75961dad4 100644 --- a/frontend/src/component/feature/form-edit-container.jsx +++ b/frontend/src/component/feature/form-edit-container.jsx @@ -34,6 +34,10 @@ const prepare = (methods, dispatch) => { delete s.id; }); } + if (input.editmode) { + delete input.description; + } + // TODO: should add error handling requestUpdateFeatureToggle(input)(dispatch) .then(() => methods.clear()) diff --git a/frontend/src/component/feature/form/index.jsx b/frontend/src/component/feature/form/index.jsx index 1d2c249f22..43d6575874 100644 --- a/frontend/src/component/feature/form/index.jsx +++ b/frontend/src/component/feature/form/index.jsx @@ -42,7 +42,7 @@ class AddFeatureToggleComponent extends Component { enabled, } = input; const configuredStrategies = input.strategies || []; - + input.editmode = editmode; return (
@@ -59,16 +59,17 @@ class AddFeatureToggleComponent extends Component { onChange={v => setValue('name', trim(v.target.value))} /> )} - setValue('description', v.target.value)} - /> - + {!editmode && ( + setValue('description', v.target.value)} + /> + )} {!editmode && (

diff --git a/frontend/src/component/feature/view-component.jsx b/frontend/src/component/feature/view-component.jsx index b9a0ee1931..b186460892 100644 --- a/frontend/src/component/feature/view-component.jsx +++ b/frontend/src/component/feature/view-component.jsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Tabs, Tab, ProgressBar, Button, Card, CardTitle, CardActions, Switch } from 'react-mdl'; +import { Tabs, Tab, ProgressBar, Button, Card, CardText, CardTitle, CardActions, Textfield, Switch } from 'react-mdl'; import { hashHistory, Link } from 'react-router'; import HistoryComponent from '../history/history-list-toggle-container'; @@ -26,6 +26,7 @@ export default class ViewFeatureToggleComponent extends React.Component { toggleFeature: PropTypes.func.isRequired, removeFeatureToggle: PropTypes.func.isRequired, fetchFeatureToggles: PropTypes.func.isRequired, + editFeatureToggle: PropTypes.func.isRequired, featureToggle: PropTypes.object, }; @@ -56,6 +57,7 @@ export default class ViewFeatureToggleComponent extends React.Component { featureToggle, features, activeTab, + // setValue, featureToggleName, toggleFeature, removeFeatureToggle, @@ -92,10 +94,37 @@ export default class ViewFeatureToggleComponent extends React.Component { hashHistory.push('/features'); } }; + const updateFeatureToggle = () => { + let feature = { ...featureToggle }; + if (Array.isArray(feature.strategies)) { + feature.strategies.forEach(s => { + delete s.id; + }); + } + + this.props.editFeatureToggle(feature); + }; + const setValue = (v, event) => { + featureToggle[v] = event.target.value; + this.forceUpdate(); + }; return ( {featureToggle.name} + + setValue('description', v)} + onBlur={updateFeatureToggle} + /> + +