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

Adds Offer Reset constants #44705

Merged
merged 4 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions client/lib/plans/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
PRODUCT_JETPACK_SCAN_MONTHLY,
PRODUCT_JETPACK_ANTI_SPAM,
PRODUCT_JETPACK_ANTI_SPAM_MONTHLY,
PRODUCT_JETPACK_SEARCH,
PRODUCT_JETPACK_SEARCH_MONTHLY,
} from 'lib/products-values/constants';

// plans constants
Expand All @@ -32,6 +34,12 @@ export const PLAN_JETPACK_PERSONAL = 'jetpack_personal';
export const PLAN_JETPACK_PREMIUM_MONTHLY = 'jetpack_premium_monthly';
export const PLAN_JETPACK_BUSINESS_MONTHLY = 'jetpack_business_monthly';
export const PLAN_JETPACK_PERSONAL_MONTHLY = 'jetpack_personal_monthly';
export const PLAN_JETPACK_SECURITY_DAILY = 'jetpack_security_daily';
export const PLAN_JETPACK_SECURITY_DAILY_MONTHLY = 'jetpack_security_daily_monthly';
export const PLAN_JETPACK_SECURITY_REALTIME = 'jetpack_security_realtime';
export const PLAN_JETPACK_SECURITY_REALTIME_MONTHLY = 'jetpack_security_realtime_monthly';
export const PLAN_JETPACK_COMPLETE = 'jetpack_complete';
export const PLAN_JETPACK_COMPLETE_MONTHLY = 'jetpack_complete_monthly';
export const PLAN_HOST_BUNDLE = 'host-bundle';
export const PLAN_WPCOM_ENTERPRISE = 'wpcom-enterprise';
export const PLAN_CHARGEBACK = 'chargeback';
Expand All @@ -51,6 +59,31 @@ export const JETPACK_MONTHLY_PLANS = [
PLAN_JETPACK_PREMIUM_MONTHLY,
PLAN_JETPACK_BUSINESS_MONTHLY,
PLAN_JETPACK_PERSONAL_MONTHLY,
PLAN_JETPACK_SECURITY_DAILY_MONTHLY,
PLAN_JETPACK_SECURITY_REALTIME_MONTHLY,
PLAN_JETPACK_COMPLETE_MONTHLY,
];
export const JETPACK_LEGACY_PLANS = [
PLAN_JETPACK_PERSONAL,
PLAN_JETPACK_PERSONAL_MONTHLY,
PLAN_JETPACK_BUSINESS,
PLAN_JETPACK_BUSINESS_MONTHLY,
PLAN_JETPACK_PREMIUM,
PLAN_JETPACK_PREMIUM_MONTHLY,
];
export const JETPACK_SECURITY_PLANS = [
PLAN_JETPACK_SECURITY_DAILY,
PLAN_JETPACK_SECURITY_DAILY_MONTHLY,
PLAN_JETPACK_SECURITY_REALTIME,
PLAN_JETPACK_SECURITY_REALTIME_MONTHLY,
];
export const JETPACK_RESET_PLANS = [
PLAN_JETPACK_SECURITY_DAILY,
PLAN_JETPACK_SECURITY_DAILY_MONTHLY,
PLAN_JETPACK_SECURITY_REALTIME,
PLAN_JETPACK_SECURITY_REALTIME_MONTHLY,
PLAN_JETPACK_COMPLETE,
PLAN_JETPACK_COMPLETE_MONTHLY,
];

export const PLAN_MONTHLY_PERIOD = 31;
Expand Down Expand Up @@ -177,6 +210,8 @@ export const FEATURE_JETPACK_SCAN_DAILY = PRODUCT_JETPACK_SCAN;
export const FEATURE_JETPACK_SCAN_DAILY_MONTHLY = PRODUCT_JETPACK_SCAN_MONTHLY;
export const FEATURE_JETPACK_ANTI_SPAM = PRODUCT_JETPACK_ANTI_SPAM;
export const FEATURE_JETPACK_ANTI_SPAM_MONTHLY = PRODUCT_JETPACK_ANTI_SPAM_MONTHLY;
export const FEATURE_JETPACK_SEARCH = PRODUCT_JETPACK_SEARCH;
export const FEATURE_JETPACK_SEARCH_MONTHLY = PRODUCT_JETPACK_SEARCH_MONTHLY;

// Meta grouping constants
export const GROUP_WPCOM = 'GROUP_WPCOM';
Expand All @@ -192,6 +227,7 @@ export const TYPE_PERSONAL = 'TYPE_PERSONAL';
export const TYPE_PREMIUM = 'TYPE_PREMIUM';
export const TYPE_BUSINESS = 'TYPE_BUSINESS';
export const TYPE_ECOMMERCE = 'TYPE_ECOMMERCE';
export const TYPE_SECURITY = 'TYPE_SECURITY';

export function isMonthly( plan ) {
return plan === PLAN_BUSINESS_MONTHLY || JETPACK_MONTHLY_PLANS.includes( plan );
Expand Down
154 changes: 153 additions & 1 deletion client/lib/plans/plans-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import React from 'react';
import { compact, includes } from 'lodash';
import i18n from 'i18n-calypso';
import i18n, { translate } from 'i18n-calypso';

/**
* Internal dependencies
Expand All @@ -14,6 +14,18 @@ import * as constants from './constants';
const WPComGetBillingTimeframe = () => i18n.translate( 'per month, billed annually' );
const WPComGetBiennialBillingTimeframe = () => i18n.translate( '/month, billed every two years' );

const getAnnualTimeframe = () => ( {
term: constants.TERM_ANNUALLY,
getBillingTimeFrame: () => translate( 'per year' ),
getSignupBillingTimeFrame: () => translate( 'per year' ),
} );

const getMonthlyTimeframe = () => ( {
term: constants.TERM_MONTHLY,
getBillingTimeFrame: () => translate( 'per month, billed monthly' ),
getSignupBillingTimeFrame: () => translate( 'per month' ),
} );

const plansDescriptionHeadingComponent = {
components: {
strong: <strong className="plans__features plan-features__targeted-description-heading" />,
Expand Down Expand Up @@ -357,6 +369,98 @@ const getPlanBusinessDetails = () => ( {
getInferiorHiddenFeatures: () => [],
} );

const getPlanJetpackSecurityDailyDetails = () => ( {
group: constants.GROUP_JETPACK,
type: constants.TYPE_SECURITY,
getTitle: () =>
translate( 'Jetpack Security {{em}}Daily{{/em}}', { components: { em: <em /> } } ),
ChaosExAnima marked this conversation as resolved.
Show resolved Hide resolved
getAudience: () => translate(),
availableFor: ( plan ) =>
[ constants.PLAN_JETPACK_FREE, ...constants.JETPACK_LEGACY_PLANS ].includes( plan ),
getDescription: () =>
translate(
'Enjoy the peace of mind of complete site protection. ' +
'Great for brochure sites, restaurants, blogs, and resume sites.'
),
getTagline: () => translate( 'Best for sites with occasional updates' ),
getPlanCompareFeatures: () => [],
getSignupFeatures: () => [],
getHiddenFeatures: () => [
constants.FEATURE_JETPACK_BACKUP_DAILY,
constants.FEATURE_JETPACK_BACKUP_DAILY_MONTHLY,
constants.FEATURE_JETPACK_SCAN_DAILY,
constants.FEATURE_JETPACK_SCAN_DAILY_MONTHLY,
constants.FEATURE_JETPACK_ANTI_SPAM,
constants.FEATURE_JETPACK_ANTI_SPAM_MONTHLY,
],
getInferiorHiddenFeatures: () => [],
} );

const getPlanJetpackSecurityRealtimeDetails = () => ( {
group: constants.GROUP_JETPACK,
type: constants.TYPE_SECURITY,
getTitle: () =>
translate( 'Jetpack Security {{em}}Real-time{{/em}}', { components: { em: <em /> } } ),
ChaosExAnima marked this conversation as resolved.
Show resolved Hide resolved
getAudience: () => translate(),
availableFor: ( plan ) =>
[
constants.PLAN_JETPACK_FREE,
constants.PLAN_JETPACK_SECURITY_DAILY,
constants.PLAN_JETPACK_SECURITY_DAILY_MONTHLY,
...constants.JETPACK_LEGACY_PLANS,
].includes( plan ),
getDescription: () =>
translate(
'Additional security for sites with 24/7 activity. ' +
'Recommended for eCommerce stores, news organizations, and online forums.'
),
getTagline: () => translate( 'Best for sites with frequent updates' ),
getPlanCompareFeatures: () => [],
getSignupFeatures: () => [],
getHiddenFeatures: () => [
constants.FEATURE_JETPACK_BACKUP_REALTIME,
constants.FEATURE_JETPACK_BACKUP_REALTIME_MONTHLY,
constants.FEATURE_JETPACK_SCAN_DAILY,
constants.FEATURE_JETPACK_SCAN_DAILY_MONTHLY,
constants.FEATURE_JETPACK_ANTI_SPAM,
constants.FEATURE_JETPACK_ANTI_SPAM_MONTHLY,
],
getInferiorHiddenFeatures: () => [
constants.FEATURE_JETPACK_BACKUP_DAILY,
constants.FEATURE_JETPACK_BACKUP_DAILY_MONTHLY,
],
} );

const getPlanJetpackCompleteDetails = () => ( {
group: constants.GROUP_JETPACK,
getTitle: () => translate( 'Jetpack Complete' ),
getAudience: () => translate(),
availableFor: ( plan ) =>
[
constants.PLAN_JETPACK_FREE,
...constants.JETPACK_SECURITY_PLANS,
...constants.JETPACK_LEGACY_PLANS,
].includes( plan ),
getDescription: () =>
translate( 'The most powerful WordPress sites: Top-tier security bundle, enhanced search' ),
getTagline: () => translate( 'Complete WordPress security, performance, and growth' ),
getPlanCompareFeatures: () => [],
getSignupFeatures: () => [],
getHiddenFeatures: () => [],
getInferiorHiddenFeatures: () => [
constants.FEATURE_JETPACK_BACKUP_DAILY,
constants.FEATURE_JETPACK_BACKUP_DAILY_MONTHLY,
constants.FEATURE_JETPACK_BACKUP_REALTIME,
constants.FEATURE_JETPACK_BACKUP_REALTIME_MONTHLY,
constants.FEATURE_JETPACK_SCAN_DAILY,
constants.FEATURE_JETPACK_SCAN_DAILY_MONTHLY,
constants.FEATURE_JETPACK_ANTI_SPAM,
constants.FEATURE_JETPACK_ANTI_SPAM_MONTHLY,
constants.FEATURE_JETPACK_SEARCH,
constants.FEATURE_JETPACK_SEARCH,
],
} );

// DO NOT import. Use `getPlan` from `lib/plans` instead.
export const PLANS_LIST = {
[ constants.PLAN_FREE ]: {
Expand Down Expand Up @@ -1068,6 +1172,54 @@ export const PLANS_LIST = {
constants.FEATURE_JETPACK_SCAN_DAILY_MONTHLY,
],
},

[ constants.PLAN_JETPACK_SECURITY_DAILY ]: {
...getPlanJetpackSecurityDailyDetails(),
...getAnnualTimeframe(),
getStoreSlug: () => constants.PLAN_JETPACK_SECURITY_DAILY,
getPathSlug: () => 'security-daily',
getProductId: () => 2010,
},

[ constants.PLAN_JETPACK_SECURITY_DAILY_MONTHLY ]: {
...getPlanJetpackSecurityDailyDetails(),
...getMonthlyTimeframe(),
getStoreSlug: () => constants.PLAN_JETPACK_SECURITY_DAILY_MONTHLY,
getPathSlug: () => 'security-daily-monthly',
getProductId: () => 2011,
},

[ constants.PLAN_JETPACK_SECURITY_REALTIME ]: {
...getPlanJetpackSecurityRealtimeDetails(),
...getAnnualTimeframe(),
getStoreSlug: () => constants.PLAN_JETPACK_SECURITY_REALTIME,
getPathSlug: () => 'security-realtime',
getProductId: () => 2012,
},

[ constants.PLAN_JETPACK_SECURITY_REALTIME_MONTHLY ]: {
...getPlanJetpackSecurityDailyDetails(),
...getMonthlyTimeframe(),
getStoreSlug: () => constants.PLAN_JETPACK_SECURITY_REALTIME_MONTHLY,
getPathSlug: () => 'security-realtime-monthly',
getProductId: () => 2013,
},

[ constants.PLAN_JETPACK_COMPLETE ]: {
...getPlanJetpackCompleteDetails(),
...getAnnualTimeframe(),
getStoreSlug: () => constants.PLAN_JETPACK_COMPLETE,
getPathSlug: () => 'complete',
getProductId: () => 2014,
},

[ constants.PLAN_JETPACK_COMPLETE_MONTHLY ]: {
...getPlanJetpackCompleteDetails(),
...getMonthlyTimeframe(),
getStoreSlug: () => constants.PLAN_JETPACK_COMPLETE_MONTHLY,
getPathSlug: () => 'complete-monthly',
getProductId: () => 2015,
},
};

export const PLANS_CONSTANTS_LIST = Object.keys( PLANS_LIST );
Expand Down