From c0ed3b40075f127431d85496d52c9c82b7159fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Sun, 4 Feb 2018 22:50:52 +0100 Subject: [PATCH] feat(feature-create): Default strategy is actually default Closes https://github.com/Unleash/unleash/issues/204 --- .../component/feature/form/form-add-feature-container.jsx | 4 ++++ frontend/src/component/feature/form/strategies-list.jsx | 6 +++++- .../src/component/feature/form/strategies-section.jsx | 8 ++++---- 3 files changed, 13 insertions(+), 5 deletions(-) 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 6835ffbc52..332a1e9fa3 100644 --- a/frontend/src/component/feature/form/form-add-feature-container.jsx +++ b/frontend/src/component/feature/form/form-add-feature-container.jsx @@ -3,6 +3,8 @@ import { createFeatureToggles, validateName } from './../../../store/feature-act import { createMapper, createActions } from './../../input-helpers'; import AddFeatureComponent from './form-add-feature-component'; +const defaultStrategy = { name: 'default' }; + const ID = 'add-feature-toggle'; const mapStateToProps = createMapper({ id: ID, @@ -26,6 +28,8 @@ const prepare = (methods, dispatch, ownProps) => { input.strategies.forEach(s => { delete s.id; }); + } else { + input.strategies = [defaultStrategy]; } createFeatureToggles(input)(dispatch) diff --git a/frontend/src/component/feature/form/strategies-list.jsx b/frontend/src/component/feature/form/strategies-list.jsx index dabaf01aa6..c7dcd709e8 100644 --- a/frontend/src/component/feature/form/strategies-list.jsx +++ b/frontend/src/component/feature/form/strategies-list.jsx @@ -18,7 +18,11 @@ class StrategiesList extends React.Component { const { strategies, configuredStrategies, moveStrategy, removeStrategy, updateStrategy } = this.props; if (!configuredStrategies || configuredStrategies.length === 0) { - return No strategies added; + return ( +

+ No activation strategies selected. +

+ ); } const blocks = configuredStrategies.map((strategy, i) => ( diff --git a/frontend/src/component/feature/form/strategies-section.jsx b/frontend/src/component/feature/form/strategies-section.jsx index ed3c24605b..2006d82210 100644 --- a/frontend/src/component/feature/form/strategies-section.jsx +++ b/frontend/src/component/feature/form/strategies-section.jsx @@ -8,9 +8,9 @@ import { HeaderTitle } from '../../common'; class StrategiesSectionComponent extends React.Component { static propTypes = { strategies: PropTypes.array.isRequired, - addStrategy: PropTypes.func, - removeStrategy: PropTypes.func, - updateStrategy: PropTypes.func, + addStrategy: PropTypes.func.isRequired, + removeStrategy: PropTypes.func.isRequired, + updateStrategy: PropTypes.func.isRequired, fetchStrategies: PropTypes.func.isRequired, }; @@ -24,7 +24,7 @@ class StrategiesSectionComponent extends React.Component { } return ( -
+
{this.props.addStrategy ? ( } /> ) : (