1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-06 01:15:28 +02:00
unleash.unleash/frontend/src/component/feature/form/form-view-feature-container.jsx
Luan Raithz Machado c25c0a76a8 fix: babel-preset-env (#190)
* changed do @babel/preset-env

* runned lint fix

* added beforeEach in ui-config-store-test
2019-10-09 19:58:49 +02:00

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);