From 3108b166caca76736411b655d09c561c0a6da571 Mon Sep 17 00:00:00 2001 From: Ilya Zarembsky Date: Tue, 6 Oct 2020 14:00:23 -0400 Subject: [PATCH 1/2] For clicks from promo modals, always open links in same window as panel --- app/shared-components/PromoModal/PromoModal.jsx | 4 +++- app/shared-components/PromoModal/index.js | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/shared-components/PromoModal/PromoModal.jsx b/app/shared-components/PromoModal/PromoModal.jsx index eb98a4d51..1edc471e5 100644 --- a/app/shared-components/PromoModal/PromoModal.jsx +++ b/app/shared-components/PromoModal/PromoModal.jsx @@ -63,7 +63,7 @@ class PromoModal extends React.Component { * Handle clicks on the download buttons */ _handlePromoTryProductClick = (product, utm_campaign) => { - const { actions } = this.props; + const { actions, tab_id } = this.props; actions.togglePromoModal(); let url; @@ -84,6 +84,7 @@ class PromoModal extends React.Component { sendMessage('openNewTab', { url, become_active: true, + tab_id, // Make sure we open the tab in the window with the open extension panel, even if another window is active }); } @@ -199,6 +200,7 @@ PromoModal.propTypes = { type: PropTypes.string.isRequired, location: PropTypes.string, isPlus: PropTypes.bool, + tab_id: PropTypes.number.isRequired, }; PromoModal.defaultProps = { diff --git a/app/shared-components/PromoModal/index.js b/app/shared-components/PromoModal/index.js index f4aeb36da..4e0232c9f 100644 --- a/app/shared-components/PromoModal/index.js +++ b/app/shared-components/PromoModal/index.js @@ -11,6 +11,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0 */ +import { connect } from 'react-redux'; import PromoModalContainer from './PromoModalContainer'; -export default PromoModalContainer; +const mapStateToProps = state => ({ tab_id: state.panel.tab_id }); + +export default connect(mapStateToProps, undefined)(PromoModalContainer); From 3d93154491e4561a5931fe5c71af4b0a7909b6a1 Mon Sep 17 00:00:00 2001 From: Ilya Zarembsky Date: Tue, 27 Oct 2020 17:36:39 -0400 Subject: [PATCH 2/2] Fix Hub Home view breaking bug --- app/shared-components/PromoModal/PromoModal.jsx | 3 ++- app/shared-components/PromoModal/index.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/shared-components/PromoModal/PromoModal.jsx b/app/shared-components/PromoModal/PromoModal.jsx index 1edc471e5..c15b86a7a 100644 --- a/app/shared-components/PromoModal/PromoModal.jsx +++ b/app/shared-components/PromoModal/PromoModal.jsx @@ -200,12 +200,13 @@ PromoModal.propTypes = { type: PropTypes.string.isRequired, location: PropTypes.string, isPlus: PropTypes.bool, - tab_id: PropTypes.number.isRequired, + tab_id: PropTypes.number, }; PromoModal.defaultProps = { location: 'panel', isPlus: false, + tab_id: null, }; export default PromoModal; diff --git a/app/shared-components/PromoModal/index.js b/app/shared-components/PromoModal/index.js index 4e0232c9f..d3986c052 100644 --- a/app/shared-components/PromoModal/index.js +++ b/app/shared-components/PromoModal/index.js @@ -14,6 +14,7 @@ import { connect } from 'react-redux'; import PromoModalContainer from './PromoModalContainer'; -const mapStateToProps = state => ({ tab_id: state.panel.tab_id }); +// We may be in the Hub, where state.panel may be undefined +const mapStateToProps = state => ({ tab_id: ((state.panel && state.panel.tab_id) || null) }); export default connect(mapStateToProps, undefined)(PromoModalContainer);