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 1813/feature/in app plus promo upgrade #463

Merged
merged 35 commits into from Oct 24, 2019
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5102f35
Show plus promo modal on first view of Home view of each Hub session
wlycdgr Sep 16, 2019
e1c1f54
Stub out intro hub plus promo modal layout and implement its buttons
wlycdgr Sep 16, 2019
64869a5
Remove some unnecessary plus promo modal related CSS
wlycdgr Sep 17, 2019
5289bb9
Continue adding styling for plus promo modal
wlycdgr Sep 17, 2019
ce1fac9
Continue styling plus promo modal
wlycdgr Sep 18, 2019
361debe
Refactor plus promo modal CSS to improve alignment of elements
wlycdgr Sep 20, 2019
3c96366
Merge branch 'develop' into GH-1777/plus-intro-hub-promo
wlycdgr Sep 20, 2019
a60d6b4
Continue CSS work for plus promo modal
wlycdgr Sep 20, 2019
4f84229
Implement recommended gold banner in plus promo modal
wlycdgr Sep 23, 2019
3794709
Merge branch 'develop' into GH-1777/plus-intro-hub-promo
wlycdgr Sep 26, 2019
5cb13d5
Update and tweak plus promo modal design
wlycdgr Sep 27, 2019
f6d3298
Fix path bug in i18n-checker tool. Consolidate redundant entries in m…
wlycdgr Oct 1, 2019
4b16723
Additional consolidation of redundant and unused entries in messages
wlycdgr Oct 2, 2019
92d4923
Merge branch 'develop' into GH-1777/plus-intro-hub-promo
wlycdgr Oct 3, 2019
a1f102b
Merge branch 'develop' into GH-1777/plus-intro-hub-promo
wlycdgr Oct 3, 2019
569382e
Factor plus promo modal rendering out to shared component. Implement …
wlycdgr Oct 6, 2019
509f9eb
Move Plus Promo modal rendering to a PlusPromoModal shared component.…
wlycdgr Oct 7, 2019
833fdff
Create ModalPromos background class responsible for modal promo relat…
wlycdgr Oct 7, 2019
9e80640
Add local state to Panel to make sure component rerenders after user …
wlycdgr Oct 8, 2019
b03e312
Make PromoModals code more robust
wlycdgr Oct 8, 2019
a1270cc
Factor PlusPromoModal rendering out to helper in Panel. Extend condit…
wlycdgr Oct 8, 2019
cac56c1
Mark PromoModals methods as static. Refine PlusPromoModal implementat…
wlycdgr Oct 8, 2019
be05ce9
Add logic to hide plus promo modal from Insights subscribers. Cleanup…
wlycdgr Oct 9, 2019
ee361ad
Clean up. Finish string localization in PlusPromoModal
wlycdgr Oct 9, 2019
e19e5ab
Add gold ghostie badge svg. Begin fleshing out upgrade plus promo mod…
wlycdgr Oct 16, 2019
80d75fb
Pull non-shared upgrade version of plus promo modal out of shared Plu…
wlycdgr Oct 16, 2019
842d5ae
Merge GH-1777 into branch
wlycdgr Oct 16, 2019
d51aeec
Merge in initial plus promo modal implementation
wlycdgr Oct 18, 2019
a33c88e
Merge branch 'release/8.4.5' into GH-1813/feature/in-app-plus-promo-u…
wlycdgr Oct 18, 2019
811a19f
Flesh out upgrade promo modal UI and styles
wlycdgr Oct 18, 2019
2e4f060
Implement panel to tab link for the upgrade to plus button
wlycdgr Oct 21, 2019
c246530
Add no thanks link click handling
wlycdgr Oct 21, 2019
49161bf
Localization-proof upgrade modal CSS. Finalize UI and display logic.
wlycdgr Oct 21, 2019
05291b5
Implement ability to turn off promotions from inside plus upgrade pro…
wlycdgr Oct 23, 2019
2da1171
Merge in release/8.4.5
wlycdgr Oct 24, 2019
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Mark PromoModals methods as static. Refine PlusPromoModal implementat…

…ion and add debug code
  • Loading branch information
wlycdgr committed Oct 8, 2019
commit cac56c12b945be4e71e3c0708b89270d220d9440
@@ -92,6 +92,7 @@ class HomeViewContainer extends Component {
show={!isPlus && !plus_promo_modal_shown}
location="hub"
clickHandler={this._dismissModal}
version={PlusPromoModal.INITIAL}
/>
<HomeView {...childProps} />
</div>
@@ -207,11 +207,11 @@ class Panel extends React.Component {

_renderPlusPromoModal = () => {
const { plusPromoModalShown } = this.state;
const { haveSeenAPlusPromo, isTimeForAPlusPromo } = this.props;
const { haveSeenInitialPlusPromo, isTimeForAPlusPromo } = this.props;

if (plusPromoModalShown || !isTimeForAPlusPromo) return null;

const version = haveSeenAPlusPromo ? 'upgrade' : 'initial';
const version = haveSeenInitialPlusPromo ? PlusPromoModal.UPGRADE : PlusPromoModal.INITIAL;

return (
<PlusPromoModal
@@ -17,12 +17,8 @@ import PropTypes from 'prop-types';
import ClassNames from 'classnames';
import Modal from '../Modal/Modal';

/**
* A Functional React component for a Plus Promo Modal
* @return {JSX} JSX for rendering a Plus Promo Modal
* @memberof SharedComponents
*/
const PlusPromoModal = (props) => {
// TODO refactor to reduce duplication alongside implementing _renderUpgradeVersion for GH-1813
function _renderInitialVersion(props) {
const { show, location, clickHandler } = props;

const isInHub = location === 'hub';
@@ -126,13 +122,62 @@ const PlusPromoModal = (props) => {
</div>
</Modal>
);
}

// TODO flesh out this stub for https://cliqztix.atlassian.net/browse/GH-1813
function _renderUpgradeVersion(props) {
const { clickHandler, location, show } = props;

const isInHub = location === 'hub';

const locationClassName = {
'in-hub': isInHub,
'in-panel': location === 'panel'
};
const contentClassNames = ClassNames(
'PlusPromoModal__content',
'flex-container',
'flex-dir-column',
'align-middle',
locationClassName
);

return (
<Modal show={show}>
<div className={contentClassNames}>
<div className="PlusPromoModal__thanks-for-download">[Upgrade version of the Plus Promo modal]</div>
<div className="PlusPromoModal__button basic button" onClick={clickHandler}>
<span>Dismiss</span>
</div>
</div>
</Modal>
);
}

/**
* A Functional React component for a Plus Promo Modal
* @return {JSX} JSX for rendering a Plus Promo Modal
* @memberof SharedComponents
*/
const PlusPromoModal = (props) => {
const { version } = props;

if (version === PlusPromoModal.INITIAL) { return _renderInitialVersion(props); }

if (version === PlusPromoModal.UPGRADE) { return _renderUpgradeVersion(props); }

return null;
};

PlusPromoModal.UPGRADE = 1;
PlusPromoModal.INITIAL = 2;

// PropTypes ensure we pass required props of the correct type
PlusPromoModal.propTypes = {
show: PropTypes.bool.isRequired,
location: PropTypes.string.isRequired,
clickHandler: PropTypes.func.isRequired,
version: PropTypes.oneOf([PlusPromoModal.UPGRADE, PlusPromoModal.INITIAL]).isRequired,
};

export default PlusPromoModal;
@@ -27,7 +27,7 @@ import tabInfo from './TabInfo';
import rewards from './Rewards';
import account from './Account';
import dispatcher from './Dispatcher';
import modalPromos from './PromoModals';
import promoModals from './PromoModals';
import { getCliqzGhosteryBugs, sendCliqzModuleCounts } from '../utils/cliqzModulesData';
import { getActiveTab, flushChromeMemoryCache, processUrl } from '../utils/utils';
import { objectEntries, log } from '../utils/common';
@@ -366,8 +366,8 @@ class PanelData {
is_expert,
is_android: globals.BROWSER_INFO.os === 'android',
language,
isTimeForAPlusPromo: modalPromos.isTimeForAPlusPromo(),
haveSeenAPlusPromo: modalPromos.haveSeenAPlusPromo(),
isTimeForAPlusPromo: promoModals.isTimeForAPlusPromo(),
haveSeenInitialPlusPromo: promoModals.haveSeenInitialPlusPromo(),
reload_banner_status,
tab_id,
trackers_banner_status,
@@ -12,12 +12,12 @@
*/

import conf from './Conf';
import globals from './Globals';

const DAYS_BETWEEN_PROMOS = {
plus: 30
plus: globals.DEBUG ? 0.00025 : 30,
};
const MSECS_IN_DAY = 1000 * 60 * 60 * 24; // msecs-in-sec * secs-in-min * mins-in-hour * hours-in-day

const MSECS_IN_DAY = 86400000; // 1000 msecs-in-sec * 60 secs-in-min * 60 mins-in-hour * 24 hours-in-day
const PLUS = 'plus';
const PROMO_MODAL_LAST_SEEN = 'promo_modal_last_seen';

@@ -26,18 +26,16 @@ const PROMO_MODAL_LAST_SEEN = 'promo_modal_last_seen';
* @memberOf BackgroundClasses
*/
class PromoModals {
haveSeenAPlusPromo() { return this._haveSeenAPromo(PLUS); }

isTimeForAPlusPromo() { return this._isTimeForAPromo(PLUS); }

recordPlusPromoSighting() { this._recordPromoSighting(PLUS); }

_haveSeenAPromo(type) {
const lastSeenTime = conf[`${type}_${PROMO_MODAL_LAST_SEEN}`];
static haveSeenInitialPlusPromo() {
const lastSeenTime = conf[`${PLUS}_${PROMO_MODAL_LAST_SEEN}`];
return (lastSeenTime !== null);
}

_isTimeForAPromo(type) {
static isTimeForAPlusPromo() { return this._isTimeForAPromo(PLUS); }

static recordPlusPromoSighting() { this._recordPromoSighting(PLUS); }

static _isTimeForAPromo(type) {
const lastSeenTime = conf[`${type}_${PROMO_MODAL_LAST_SEEN}`];

if (lastSeenTime === null) { return true; }
@@ -48,10 +46,11 @@ class PromoModals {
);
}

_recordPromoSighting(type) {
static _recordPromoSighting(type) {
conf[`${type}_${PROMO_MODAL_LAST_SEEN}`] = Date.now();
}
}

// return the class as a singleton
export default new PromoModals();
// the class is simply a namespace for some static methods,
// as we do not need to maintain any state
export default PromoModals;
ProTip! Use n and p to navigate between commits in a pull request.