mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-06 01:15:28 +02:00
* changed do @babel/preset-env * runned lint fix * added beforeEach in ui-config-store-test
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { createMapper, createActions } from '../../input-helpers';
|
|
import ViewFeatureToggleComponent from './form-view-feature-component';
|
|
|
|
const ID = 'view-feature-toggle';
|
|
function getId(props) {
|
|
return [ID, props.featureToggle.name];
|
|
}
|
|
// TODO: need to scope to the active featureToggle
|
|
// best is to emulate the "input-storage"?
|
|
const mapStateToProps = createMapper({
|
|
id: getId,
|
|
getDefault: (state, ownProps) => {
|
|
ownProps.featureToggle.strategies.forEach((strategy, index) => {
|
|
strategy.id = Math.round(Math.random() * 1000000 * (1 + index));
|
|
});
|
|
return ownProps.featureToggle;
|
|
},
|
|
prepare: props => {
|
|
props.editmode = true;
|
|
return props;
|
|
},
|
|
});
|
|
|
|
const prepare = methods => {
|
|
methods.onCancel = evt => {
|
|
evt.preventDefault();
|
|
methods.clear();
|
|
this.props.history.push(`/archive`);
|
|
};
|
|
return methods;
|
|
};
|
|
|
|
const actions = createActions({
|
|
id: getId,
|
|
prepare,
|
|
});
|
|
|
|
export default connect(
|
|
mapStateToProps,
|
|
actions
|
|
)(ViewFeatureToggleComponent);
|