1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

feat(feature-create): Default strategy is actually default

Closes https://github.com/Unleash/unleash/issues/204
This commit is contained in:
Ivar Conradi Østhus 2018-02-04 22:50:52 +01:00 committed by ivaosthu
parent 9338635337
commit c0ed3b4007
3 changed files with 13 additions and 5 deletions

View File

@ -3,6 +3,8 @@ import { createFeatureToggles, validateName } from './../../../store/feature-act
import { createMapper, createActions } from './../../input-helpers'; import { createMapper, createActions } from './../../input-helpers';
import AddFeatureComponent from './form-add-feature-component'; import AddFeatureComponent from './form-add-feature-component';
const defaultStrategy = { name: 'default' };
const ID = 'add-feature-toggle'; const ID = 'add-feature-toggle';
const mapStateToProps = createMapper({ const mapStateToProps = createMapper({
id: ID, id: ID,
@ -26,6 +28,8 @@ const prepare = (methods, dispatch, ownProps) => {
input.strategies.forEach(s => { input.strategies.forEach(s => {
delete s.id; delete s.id;
}); });
} else {
input.strategies = [defaultStrategy];
} }
createFeatureToggles(input)(dispatch) createFeatureToggles(input)(dispatch)

View File

@ -18,7 +18,11 @@ class StrategiesList extends React.Component {
const { strategies, configuredStrategies, moveStrategy, removeStrategy, updateStrategy } = this.props; const { strategies, configuredStrategies, moveStrategy, removeStrategy, updateStrategy } = this.props;
if (!configuredStrategies || configuredStrategies.length === 0) { if (!configuredStrategies || configuredStrategies.length === 0) {
return <i style={{ color: 'red' }}>No strategies added</i>; return (
<p style={{ padding: '0 16px' }}>
<i>No activation strategies selected.</i>
</p>
);
} }
const blocks = configuredStrategies.map((strategy, i) => ( const blocks = configuredStrategies.map((strategy, i) => (

View File

@ -8,9 +8,9 @@ import { HeaderTitle } from '../../common';
class StrategiesSectionComponent extends React.Component { class StrategiesSectionComponent extends React.Component {
static propTypes = { static propTypes = {
strategies: PropTypes.array.isRequired, strategies: PropTypes.array.isRequired,
addStrategy: PropTypes.func, addStrategy: PropTypes.func.isRequired,
removeStrategy: PropTypes.func, removeStrategy: PropTypes.func.isRequired,
updateStrategy: PropTypes.func, updateStrategy: PropTypes.func.isRequired,
fetchStrategies: PropTypes.func.isRequired, fetchStrategies: PropTypes.func.isRequired,
}; };
@ -24,7 +24,7 @@ class StrategiesSectionComponent extends React.Component {
} }
return ( return (
<div> <div style={{ padding: '10px 0' }}>
{this.props.addStrategy ? ( {this.props.addStrategy ? (
<HeaderTitle title="Activation strategies" actions={<AddStrategy {...this.props} />} /> <HeaderTitle title="Activation strategies" actions={<AddStrategy {...this.props} />} />
) : ( ) : (