From baa4e0e2c359cca73b575f5e20706b1f0a9518b0 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Mon, 7 Oct 2019 16:18:49 -0400 Subject: [PATCH] refactor intro.jsx and navigation.jsx to use new navigation reducer single registration open request action --- src/components/intro/intro.jsx | 27 +++++--------------- src/components/navigation/www/navigation.jsx | 21 +++------------ 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/components/intro/intro.jsx b/src/components/intro/intro.jsx index c8bca547e..a9d31fd19 100644 --- a/src/components/intro/intro.jsx +++ b/src/components/intro/intro.jsx @@ -15,20 +15,12 @@ class Intro extends React.Component { constructor (props) { super(props); bindAll(this, [ - 'handleClickRegistration', 'handleShowVideo' ]); this.state = { videoOpen: false }; } - handleClickRegistration (event) { - if (this.props.useScratch3Registration) { - this.props.navigateToRegistration(event); - } else { - this.props.handleOpenRegistration(event); - } - } handleShowVideo () { this.setState({videoOpen: true}); } @@ -52,7 +44,7 @@ class Intro extends React.Component { {this.props.messages['intro.join']} @@ -115,7 +107,7 @@ class Intro extends React.Component { } Intro.propTypes = { - handleOpenRegistration: PropTypes.func, + handleClickRegistration: PropTypes.func, messages: PropTypes.shape({ 'intro.aboutScratch': PropTypes.string, 'intro.forEducators': PropTypes.string, @@ -125,9 +117,7 @@ Intro.propTypes = { 'intro.tagLine1': PropTypes.string, 'intro.tagLine2': PropTypes.string, 'intro.watchVideo': PropTypes.string - }), - navigateToRegistration: PropTypes.func, - useScratch3Registration: PropTypes.bool + }) }; Intro.defaultProps = { @@ -145,18 +135,13 @@ Intro.defaultProps = { }; const mapStateToProps = state => ({ - session: state.session, - useScratch3Registration: state.navigation.useScratch3Registration + session: state.session }); const mapDispatchToProps = dispatch => ({ - handleOpenRegistration: event => { + handleClickRegistration: event => { event.preventDefault(); - dispatch(navigationActions.setRegistrationOpen(true)); - }, - navigateToRegistration: event => { - event.preventDefault(); - navigationActions.navigateToRegistration(); + dispatch(navigationActions.handleRegistrationRequested()); } }); diff --git a/src/components/navigation/www/navigation.jsx b/src/components/navigation/www/navigation.jsx index 98f68cead..515b29b82 100644 --- a/src/components/navigation/www/navigation.jsx +++ b/src/components/navigation/www/navigation.jsx @@ -27,7 +27,6 @@ class Navigation extends React.Component { super(props); bindAll(this, [ 'getProfileUrl', - 'handleClickRegistration', 'handleSearchSubmit' ]); this.state = { @@ -78,13 +77,6 @@ class Navigation extends React.Component { if (!this.props.user) return; return `/users/${this.props.user.username}/`; } - handleClickRegistration (event) { - if (this.props.useScratch3Registration) { - this.props.navigateToRegistration(event); - } else { - this.props.handleOpenRegistration(event); - } - } handleSearchSubmit (formData) { let targetUrl = '/search/projects'; if (formData.q) { @@ -201,7 +193,7 @@ class Navigation extends React.Component { @@ -239,13 +231,12 @@ class Navigation extends React.Component { Navigation.propTypes = { accountNavOpen: PropTypes.bool, getMessageCount: PropTypes.func, + handleClickRegistration: PropTypes.func, handleCloseAccountNav: PropTypes.func, handleLogOut: PropTypes.func, - handleOpenRegistration: PropTypes.func, handleToggleAccountNav: PropTypes.func, handleToggleLoginOpen: PropTypes.func, intl: intlShape, - navigateToRegistration: PropTypes.func, permissions: PropTypes.shape({ admin: PropTypes.bool, social: PropTypes.bool, @@ -296,9 +287,9 @@ const mapDispatchToProps = dispatch => ({ handleCloseAccountNav: () => { dispatch(navigationActions.setAccountNavOpen(false)); }, - handleOpenRegistration: event => { + handleClickRegistration: event => { event.preventDefault(); - dispatch(navigationActions.setRegistrationOpen(true)); + dispatch(navigationActions.handleRegistrationRequested()); }, handleLogOut: event => { event.preventDefault(); @@ -308,10 +299,6 @@ const mapDispatchToProps = dispatch => ({ event.preventDefault(); dispatch(navigationActions.toggleLoginOpen()); }, - navigateToRegistration: event => { - event.preventDefault(); - navigationActions.navigateToRegistration(); - }, setMessageCount: newCount => { dispatch(messageCountActions.setCount(newCount)); }