diff --git a/frontend/CHANGELOG.md b/frontend/CHANGELOG.md index 7854d0cb1f..f44496016e 100644 --- a/frontend/CHANGELOG.md +++ b/frontend/CHANGELOG.md @@ -10,6 +10,9 @@ The latest version of this document is always available in ## [Unreleased] +## [3.1.1] +- fix(strategy-create): Should be able to open the create strategy view. + ## [3.1.0] - fix(react-router): Upgrade to react-router v4. - fix(feature-create): Default strategy should be chosen if strategy list is empty. diff --git a/frontend/src/component/app.jsx b/frontend/src/component/app.jsx index 863f27816d..b206d32222 100644 --- a/frontend/src/component/app.jsx +++ b/frontend/src/component/app.jsx @@ -20,10 +20,6 @@ export default class App extends Component { match: PropTypes.object.isRequired, }; - static contextTypes = { - router: PropTypes.object, - }; - componentWillReceiveProps(nextProps) { if (this.props.location.pathname !== nextProps.location.pathname) { clearTimeout(this.timer); diff --git a/frontend/src/component/feature/list-component.jsx b/frontend/src/component/feature/list-component.jsx index 5e1087e50c..849542ed51 100644 --- a/frontend/src/component/feature/list-component.jsx +++ b/frontend/src/component/feature/list-component.jsx @@ -21,10 +21,6 @@ export default class FeatureListComponent extends React.Component { history: PropTypes.object.isRequired, }; - static contextTypes = { - router: PropTypes.object, - }; - componentDidMount() { if (this.props.logout) { this.props.logoutUser(); diff --git a/frontend/src/component/strategies/add-strategy.jsx b/frontend/src/component/strategies/add-strategy.jsx index 551d47815a..ef6ca9b5f1 100644 --- a/frontend/src/component/strategies/add-strategy.jsx +++ b/frontend/src/component/strategies/add-strategy.jsx @@ -1,8 +1,8 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { Textfield, IconButton, Menu, MenuItem, Checkbox, Grid, Cell } from 'react-mdl'; -import { FormButtons } from '../common'; +import { Textfield, IconButton, Menu, MenuItem, Checkbox, CardTitle, Card, CardActions } from 'react-mdl'; +import { styles as commonStyles, FormButtons } from '../common'; const trim = value => { if (value && value.trim) { @@ -129,10 +129,12 @@ class AddStrategy extends Component { const { input, setValue, updateInList, incValue, onCancel, editmode = false, onSubmit } = this.props; return ( - - -
- {editmode ? : } + + + {editmode ? : } + + +
{' '}  Add parameter -
-
+
+ - -
-
+ + + ); } } diff --git a/frontend/src/component/strategies/edit-container.js b/frontend/src/component/strategies/edit-container.js index bf13af98ed..adcb05da7d 100644 --- a/frontend/src/component/strategies/edit-container.js +++ b/frontend/src/component/strategies/edit-container.js @@ -21,7 +21,7 @@ const mapStateToProps = createMapper({ }, }); -const prepare = (methods, dispatch) => { +const prepare = (methods, dispatch, ownProps) => { methods.onSubmit = input => e => { e.preventDefault(); // clean @@ -40,14 +40,13 @@ const prepare = (methods, dispatch) => { parameters, })(dispatch) .then(() => methods.clear()) - .then(() => this.props.history.push(`/strategies/view/${input.name}`)); + .then(() => ownProps.history.push(`/strategies/view/${input.name}`)); }; methods.onCancel = e => { e.preventDefault(); methods.clear(); - // somewhat quickfix / hacky to go back.. - window.history.back(); + ownProps.history.push(`/strategies/view/${ownProps.strategy.name}`); }; return methods; diff --git a/frontend/src/component/strategies/list-component.jsx b/frontend/src/component/strategies/list-component.jsx index a48ef734cf..a1fbbc0c85 100644 --- a/frontend/src/component/strategies/list-component.jsx +++ b/frontend/src/component/strategies/list-component.jsx @@ -10,10 +10,7 @@ class StrategiesListComponent extends Component { strategies: PropTypes.array.isRequired, fetchStrategies: PropTypes.func.isRequired, removeStrategy: PropTypes.func.isRequired, - }; - - static contextTypes = { - router: PropTypes.object, + history: PropTypes.object.isRequired, }; componentDidMount() { @@ -32,7 +29,7 @@ class StrategiesListComponent extends Component { this.context.router.push('/strategies/create')} + onClick={() => this.props.history.push('/strategies/create')} title="Add new strategy" /> } diff --git a/frontend/src/component/strategies/strategy-details-component.jsx b/frontend/src/component/strategies/strategy-details-component.jsx index 9c612cdfb8..49a7b4a4f5 100644 --- a/frontend/src/component/strategies/strategy-details-component.jsx +++ b/frontend/src/component/strategies/strategy-details-component.jsx @@ -37,7 +37,7 @@ export default class StrategyDetails extends Component { getTabContent(activeTabId) { if (activeTabId === TABS.edit) { - return ; + return ; } else { return ( ; +const render = ({ history }) => ; + +render.propTypes = { + history: PropTypes.object.isRequired, +}; + +export default render; diff --git a/frontend/src/page/strategies/index.js b/frontend/src/page/strategies/index.js index 6485b3c760..ef36bb3dc6 100644 --- a/frontend/src/page/strategies/index.js +++ b/frontend/src/page/strategies/index.js @@ -1,4 +1,11 @@ import React from 'react'; import Strategies from '../../component/strategies/list-container'; +import PropTypes from 'prop-types'; -export default () => ; +const render = ({ history }) => ; + +render.propTypes = { + history: PropTypes.object.isRequired, +}; + +export default render; diff --git a/frontend/src/page/strategies/show.js b/frontend/src/page/strategies/show.js index 6f3125935e..a349f1165e 100644 --- a/frontend/src/page/strategies/show.js +++ b/frontend/src/page/strategies/show.js @@ -2,12 +2,13 @@ import React from 'react'; import PropTypes from 'prop-types'; import ShowStrategy from '../../component/strategies/strategy-details-container'; -const render = ({ match: { params } }) => ( - +const render = ({ match: { params }, history }) => ( + ); render.propTypes = { match: PropTypes.object.isRequired, + history: PropTypes.object.isRequired, }; export default render;