Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-1895 and GH-1896: Midnight promos #485

Merged
merged 12 commits into from Dec 12, 2019

Continue modifying front end promo code from the old Plus promos to t…

…he new Premium promo
  • Loading branch information
wlycdgr committed Dec 10, 2019
commit 3106a301313d8d8a245445a5b63e04290d1fca4f
@@ -22,7 +22,7 @@ const INSIGHTS = 'insights';
* @memberof PanelClasses
*/
class InsightsPromoModal extends React.Component {
handleNoThanksClick = () => { this.props.handleNoThanksClick(INSIGHTS); }
handleGoAwayClick = () => { this.props.handleGoAwayClick(INSIGHTS); }

handleSubscribeClick = () => { this.props.handleSubscribeClick(INSIGHTS); }

@@ -78,7 +78,7 @@ class InsightsPromoModal extends React.Component {
</div>
<div className="InsightsModal__other-options-container flex-container align-justify">
<span onClick={this.props.handleSignInClick} className="InsightsModal__link">{t('subscribe_pitch_sign_in')}</span>
<span onClick={this.handleNoThanksClick} className="InsightsModal__link">{t('no_thanks_turn_promos_off')}</span>
<span onClick={this.handleGoAwayClick} className="InsightsModal__link">{t('no_thanks_turn_promos_off')}</span>
</div>
</div>
</div>
@@ -199,15 +199,18 @@ class Panel extends React.Component {
return false;
}

_handlePromoNoThanksClick = (modal) => {
/**
* @param modal 'insights' or 'premium'
* @private
* Handle clicks on the link to turn off promos in the promo modals
*/
_handlePromoGoAwayClick = (modal) => {
this.props.actions.togglePromoModal();

sendMessage('promoModals.turnOffPromos', {});

if (modal === 'insights') {
sendMessage('ping', 'promo_modals_decline_insights_upgrade');
} else if (modal === 'plus_upgrade') {
sendMessage('ping', 'promo_modals_decline_plus_upgrade');
}

this.props.actions.showNotification({
@@ -217,32 +220,40 @@ class Panel extends React.Component {
});
};

/**
* @private
* Handle clicks on sign in links in promo modals
*/
_handlePromoSignInClick = () => {
this.props.actions.togglePromoModal();
history.push({
pathname: '/login',
});
};

_handlePromoSelectBasicClick = () => {
/**
* @private
* Handle clicks on the download button in the Premium promo modals
*/
_handlePromoTryMidnightClick = () => {
this.props.actions.togglePromoModal();

// we do not mark the choice-required initial plus promo as 'seen' until
// the user has clicked Select Basic or Select Plus
sendMessage('promoModals.sawPlusPromo', {});
};
// TODO detect OS and begin download of appropriate file
// TODO update with correct URL once it's available
const url = 'https://reddit.com';
sendMessage('openNewTab', {
url,
become_active: true,
});
}

/**
* @private
* Handle clicks on 'Select Plus' from the Plus Promo Modal (Choose Your Plan)
* Handle clicks on the 'Get Plus' option in the Premium modals
*/
_handlePromoSelectPlusClick = () => {
_handlePromoGetPlusClick = () => {
this.props.actions.togglePromoModal();

// we do not mark the choice-required initial plus promo as 'seen' until
// the user has clicked Select Basic or Select Plus
sendMessage('promoModals.sawPlusPromo', {});

const url = `https://checkout.${DOMAIN}.com/plus?utm_source=gbe&utm_campaign=in_app`;
sendMessage('openNewTab', {
url,
@@ -271,6 +282,11 @@ class Panel extends React.Component {
});
};

/**
* @param modal 'insights' or 'premium'
* @private
* Handle clicks on the 'X' close icon in promo modals
*/
_handlePromoXClick = (modal) => {
this.props.actions.togglePromoModal();

@@ -279,12 +295,22 @@ class Panel extends React.Component {
}
};

/**
* @returns {bool}
* @private
* Is the user an Insights subscriber?
*/
_insightsSubscriber = () => {
const { loggedIn, user } = this.props;

return loggedIn && (user && user.scopes && user.scopes.includes('subscriptions:insights'));
}

/**
* @returns {JSX}
* @private
* Renders the Premium promo modal
*/
_renderPremiumPromoModal = () => {
sendMessage('promoModals.sawPremiumPromo', {});

@@ -300,6 +326,11 @@ class Panel extends React.Component {
);
}

/**
* @returns {null|JSX}
* @private
* Renders the Insights promo modal if the user is not already an Insights subscriber
*/
_renderInsightsPromoModal = () => {
if (this._insightsSubscriber()) return null;

@@ -309,14 +340,19 @@ class Panel extends React.Component {

return (
<InsightsPromoModal
handleNoThanksClick={this._handlePromoNoThanksClick}
handleGoAwayClick={this._handlePromoGoAwayClick}
handleSignInClick={this._handlePromoSignInClick}
handleSubscribeClick={this._handlePromoSubscribeClick}
handleXClick={this._handlePromoXClick}
/>
);
}

/**
* @returns {null|JSX}
* @private
* Renders either the Insights or the Premium promo modal
*/
_renderPromoModal = () => {
const {
promoModal,
ProTip! Use n and p to navigate between commits in a pull request.