diff --git a/frontend/src/component/feature/form/form-add-feature-component.jsx b/frontend/src/component/feature/form/form-add-feature-component.jsx index fc2c575b15..1d357e285c 100644 --- a/frontend/src/component/feature/form/form-add-feature-component.jsx +++ b/frontend/src/component/feature/form/form-add-feature-component.jsx @@ -13,6 +13,10 @@ class AddFeatureComponent extends Component { window.onbeforeunload = () => 'Data will be lost if you leave the page, are you sure?'; } + componentWillUnmount() { + window.onbeforeunload = false; + } + render() { const { input, diff --git a/frontend/src/component/feature/form/form-add-feature-container.jsx b/frontend/src/component/feature/form/form-add-feature-container.jsx index 1943315150..3b52947ae0 100644 --- a/frontend/src/component/feature/form/form-add-feature-container.jsx +++ b/frontend/src/component/feature/form/form-add-feature-container.jsx @@ -11,7 +11,7 @@ class WrapperComponent extends Component { constructor() { super(); this.state = { - featureToggle: { strategies: [], enabled: true }, + featureToggle: { name: '', description: '', strategies: [], enabled: true }, errors: {}, dirty: false, }; @@ -71,7 +71,7 @@ class WrapperComponent extends Component { const { featureToggle } = this.state; featureToggle.createdAt = new Date(); - if (Array.isArray(featureToggle.strategies)) { + if (Array.isArray(featureToggle.strategies && featureToggle.strategies.length > 0)) { featureToggle.strategies.forEach(s => { delete s.id; }); @@ -115,7 +115,7 @@ const mapDispatchToProps = dispatch => ({ }); const FormAddContainer = connect( - () => {}, + () => ({}), mapDispatchToProps )(WrapperComponent); diff --git a/frontend/src/component/feature/form/form-copy-feature-component.jsx b/frontend/src/component/feature/form/form-copy-feature-component.jsx index a27534658a..3dfeb97464 100644 --- a/frontend/src/component/feature/form/form-copy-feature-component.jsx +++ b/frontend/src/component/feature/form/form-copy-feature-component.jsx @@ -66,7 +66,7 @@ class CopyFeatureComponent extends Component { if (replaceGroupId) { copyToggle.strategies.forEach(s => { - if (s.parameters.groupId) { + if (s.parameters && s.parameters.groupId) { s.parameters.groupId = newToggleName; } }); diff --git a/frontend/src/component/feature/form/strategies-section.jsx b/frontend/src/component/feature/form/strategies-section.jsx index 8241142dda..308debc184 100644 --- a/frontend/src/component/feature/form/strategies-section.jsx +++ b/frontend/src/component/feature/form/strategies-section.jsx @@ -8,7 +8,7 @@ import { HeaderTitle } from '../../common'; class StrategiesSectionComponent extends React.Component { static propTypes = { strategies: PropTypes.array.isRequired, - featureToggleName: PropTypes.string.isRequired, + featureToggleName: PropTypes.string, addStrategy: PropTypes.func, removeStrategy: PropTypes.func, updateStrategy: PropTypes.func, diff --git a/frontend/src/component/feature/form/strategy-input-percentage.jsx b/frontend/src/component/feature/form/strategy-input-percentage.jsx index 4652d214a7..4f0e7b6976 100644 --- a/frontend/src/component/feature/form/strategy-input-percentage.jsx +++ b/frontend/src/component/feature/form/strategy-input-percentage.jsx @@ -26,7 +26,7 @@ const InputPercentage = ({ name, minLabel, maxLabel, value, onChange }) => ( {maxLabel}  - + ); diff --git a/frontend/src/component/menu/drawer.jsx b/frontend/src/component/menu/drawer.jsx index 095b31ed9f..fe4b020920 100644 --- a/frontend/src/component/menu/drawer.jsx +++ b/frontend/src/component/menu/drawer.jsx @@ -40,6 +40,7 @@ export const DrawerMenu = ({ links = [] }) => ( {links.map(link => (