Fix react router

This commit is contained in:
Pavel Dohnal
2018-12-04 17:20:44 +01:00
committed by Amine Ben hammou
parent 3831f127c1
commit b6dd13c5c0
3 changed files with 16 additions and 14 deletions

View File

@@ -280,7 +280,10 @@ Selection.propTypes = {
onValueChange: PropTypes.func, onValueChange: PropTypes.func,
field: PropTypes.shape({ field: PropTypes.shape({
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
values: PropTypes.object, values: PropTypes.oneOfType([
PropTypes.object,
PropTypes.array,
]),
getLabel: PropTypes.func, getLabel: PropTypes.func,
resetSelect2OnUpdate: PropTypes.bool, resetSelect2OnUpdate: PropTypes.bool,
selected: PropTypes.func, selected: PropTypes.func,
@@ -297,7 +300,7 @@ Selection.propTypes = {
disabled: PropTypes.bool, disabled: PropTypes.bool,
validation: PropTypes.object, validation: PropTypes.object,
}).isRequired, }).isRequired,
item: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types item: PropTypes.object, // eslint-disable-line react/forbid-prop-types
disabled: PropTypes.bool, disabled: PropTypes.bool,
width: PropTypes.string, width: PropTypes.string,
}; };
@@ -308,6 +311,7 @@ Selection.defaultProps = {
}, },
disabled: false, disabled: false,
width: '', width: '',
item: undefined,
}; };

View File

@@ -111,6 +111,7 @@ if (container) {
component={route.component} component={route.component}
name={route.name || null} name={route.name || null}
data={route.data || null} data={route.data || null}
render={route.render}
/> />
))} ))}
</Switch> </Switch>

View File

@@ -4,11 +4,12 @@ import AutomaticEmailEvent from 'newsletters/types/automatic_emails/event.jsx';
import MailPoet from 'mailpoet'; import MailPoet from 'mailpoet';
import _ from 'underscore'; import _ from 'underscore';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { withRouter } from 'react-router-dom';
class AutomaticEmailEventsList extends React.Component { class AutomaticEmailEventsList extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.email = this.props.route.data.email; this.email = this.props.email;
this.emailEvents = this.email.events; this.emailEvents = this.email.events;
this.eventsConfigurator = this.eventsConfigurator.bind(this); this.eventsConfigurator = this.eventsConfigurator.bind(this);
} }
@@ -19,7 +20,7 @@ class AutomaticEmailEventsList extends React.Component {
'MailPoet Premium version': window.mailpoet_premium_version, 'MailPoet Premium version': window.mailpoet_premium_version,
'Email type': eventSlug, 'Email type': eventSlug,
}); });
this.props.router.push(`new/${this.email.slug}/${eventSlug}/conditions`); this.props.history.push(`/new/${this.email.slug}/${eventSlug}/conditions`);
} }
displayEvents() { displayEvents() {
@@ -59,18 +60,14 @@ class AutomaticEmailEventsList extends React.Component {
} }
AutomaticEmailEventsList.propTypes = { AutomaticEmailEventsList.propTypes = {
route: PropTypes.shape({ email: PropTypes.shape({
data: PropTypes.shape({ title: PropTypes.string.isRequired,
email: PropTypes.shape({ slug: PropTypes.string.isRequired,
title: PropTypes.string.isRequired, premium: PropTypes.bool,
slug: PropTypes.string.isRequired,
premium: PropTypes.bool,
}).isRequired,
}).isRequired,
}).isRequired, }).isRequired,
router: PropTypes.shape({ history: PropTypes.shape({
push: PropTypes.func.isRequired, push: PropTypes.func.isRequired,
}).isRequired, }).isRequired,
}; };
module.exports = AutomaticEmailEventsList; module.exports = withRouter(AutomaticEmailEventsList);