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

Add/plans meta data #23314

Merged
merged 2 commits into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
91 changes: 69 additions & 22 deletions client/lib/plans/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { compact, includes } from 'lodash';
* Internal dependencies
*/
import { isEnabled } from 'config';
import { isBusinessPlan, isFreePlan, isPersonalPlan, isPremiumPlan } from './index';

// plans constants
export const PLAN_BUSINESS = 'business-bundle';
Expand Down Expand Up @@ -143,7 +144,22 @@ export const FEATURE_CONCIERGE_SETUP = 'concierge-setup-jetpack';
export const FEATURE_MARKETING_AUTOMATION = 'marketing-automation';
export const FEATURE_SEARCH = 'search';

// Meta grouping constants
export const GROUP_WPCOM = 'GROUP_WPCOM';
export const GROUP_JETPACK = 'GROUP_JETPACK';

export const TERM_MONTHLY = 'TERM_MONTHLY';
export const TERM_ANNUALLY = 'TERM_ANNUALLY';
export const TERM_BIENNIALLY = 'TERM_BIENNIALLY';

export const TYPE_FREE = 'TYPE_FREE';
export const TYPE_PERSONAL = 'TYPE_PERSONAL';
export const TYPE_PREMIUM = 'TYPE_PREMIUM';
export const TYPE_BUSINESS = 'TYPE_BUSINESS';

const getPlanPersonalDetails = () => ( {
group: GROUP_WPCOM,
type: TYPE_PERSONAL,
getTitle: () => i18n.translate( 'Personal' ),
getAudience: () => i18n.translate( 'Best for hobbyists' ),
getBlogAudience: () => i18n.translate( 'Best for hobbyists' ),
Expand Down Expand Up @@ -197,6 +213,8 @@ const getPlanPersonalDetails = () => ( {
} );

const getPlanPremiumDetails = () => ( {
group: GROUP_WPCOM,
type: TYPE_PREMIUM,
getTitle: () => i18n.translate( 'Premium' ),
getAudience: () => i18n.translate( 'Best for entrepreneurs' ),
getBlogAudience: () => i18n.translate( 'Best for professionals' ),
Expand Down Expand Up @@ -262,6 +280,8 @@ const getPlanPremiumDetails = () => ( {
} );

const getPlanBusinessDetails = () => ( {
group: GROUP_WPCOM,
type: TYPE_BUSINESS,
getTitle: () => i18n.translate( 'Business' ),
getAudience: () => i18n.translate( 'Best for small businesses' ),
getBlogAudience: () => i18n.translate( 'Best for brands' ),
Expand Down Expand Up @@ -357,6 +377,9 @@ const getPlanBusinessDetails = () => ( {
// DO NOT import. Use `getPlan` from `lib/plans` instead.
export const PLANS_LIST = {
[ PLAN_FREE ]: {
group: GROUP_WPCOM,
type: TYPE_FREE,
term: TERM_ANNUALLY,
getTitle: () => i18n.translate( 'Free' ),
getAudience: () => i18n.translate( 'Best for students' ),
getBlogAudience: () => i18n.translate( 'Best for students' ),
Expand Down Expand Up @@ -400,6 +423,7 @@ export const PLANS_LIST = {

[ PLAN_PERSONAL ]: {
...getPlanPersonalDetails(),
term: TERM_ANNUALLY,
availableFor: plan => includes( [ PLAN_FREE ], plan ),
getProductId: () => 1009,
getStoreSlug: () => PLAN_PERSONAL,
Expand All @@ -408,6 +432,7 @@ export const PLANS_LIST = {

[ PLAN_PERSONAL_2_YEARS ]: {
...getPlanPersonalDetails(),
term: TERM_BIENNIALLY,
availableFor: plan => includes( [ PLAN_FREE, PLAN_PERSONAL ], plan ),
getProductId: () => 1029,
getStoreSlug: () => PLAN_PERSONAL_2_YEARS,
Expand All @@ -416,6 +441,7 @@ export const PLANS_LIST = {

[ PLAN_PREMIUM ]: {
...getPlanPremiumDetails(),
term: TERM_ANNUALLY,
availableFor: plan => includes( [ PLAN_FREE, PLAN_PERSONAL, PLAN_PERSONAL_2_YEARS ], plan ),
getProductId: () => 1003,
getStoreSlug: () => PLAN_PREMIUM,
Expand All @@ -425,6 +451,7 @@ export const PLANS_LIST = {

[ PLAN_PREMIUM_2_YEARS ]: {
...getPlanPremiumDetails(),
term: TERM_BIENNIALLY,
availableFor: plan =>
includes( [ PLAN_FREE, PLAN_PERSONAL, PLAN_PERSONAL_2_YEARS, PLAN_PREMIUM ], plan ),
getProductId: () => 1023,
Expand All @@ -435,6 +462,7 @@ export const PLANS_LIST = {

[ PLAN_BUSINESS ]: {
...getPlanBusinessDetails(),
term: TERM_ANNUALLY,
availableFor: plan =>
includes(
[ PLAN_FREE, PLAN_PERSONAL, PLAN_PERSONAL_2_YEARS, PLAN_PREMIUM, PLAN_PREMIUM_2_YEARS ],
Expand All @@ -448,6 +476,7 @@ export const PLANS_LIST = {

[ PLAN_BUSINESS_2_YEARS ]: {
...getPlanBusinessDetails(),
term: TERM_BIENNIALLY,
availableFor: plan =>
includes(
[
Expand All @@ -467,6 +496,9 @@ export const PLANS_LIST = {
},

[ PLAN_JETPACK_FREE ]: {
term: TERM_ANNUALLY,
group: GROUP_JETPACK,
type: TYPE_FREE,
getTitle: () => i18n.translate( 'Free' ),
getAudience: () => i18n.translate( 'Best for students' ),
getProductId: () => 2002,
Expand Down Expand Up @@ -499,6 +531,9 @@ export const PLANS_LIST = {
},

[ PLAN_JETPACK_PREMIUM ]: {
group: GROUP_JETPACK,
type: TYPE_PREMIUM,
term: TERM_ANNUALLY,
getTitle: () => i18n.translate( 'Premium' ),
getAudience: () => i18n.translate( 'Best for small businesses' ),
getSubtitle: () => i18n.translate( 'Protection, speed, and revenue.' ),
Expand Down Expand Up @@ -557,6 +592,9 @@ export const PLANS_LIST = {
},

[ PLAN_JETPACK_PREMIUM_MONTHLY ]: {
group: GROUP_JETPACK,
type: TYPE_PREMIUM,
term: TERM_MONTHLY,
getTitle: () => i18n.translate( 'Premium' ),
getAudience: () => i18n.translate( 'Best for small businesses' ),
getProductId: () => 2003,
Expand Down Expand Up @@ -612,6 +650,9 @@ export const PLANS_LIST = {
},

[ PLAN_JETPACK_PERSONAL ]: {
group: GROUP_JETPACK,
type: TYPE_PERSONAL,
term: TERM_ANNUALLY,
getTitle: () => i18n.translate( 'Personal' ),
getAudience: () => i18n.translate( 'Best for hobbyists' ),
getProductId: () => 2005,
Expand Down Expand Up @@ -648,6 +689,9 @@ export const PLANS_LIST = {
},

[ PLAN_JETPACK_PERSONAL_MONTHLY ]: {
group: GROUP_JETPACK,
type: TYPE_PERSONAL,
term: TERM_MONTHLY,
getTitle: () => i18n.translate( 'Personal' ),
getAudience: () => i18n.translate( 'Best for hobbyists' ),
getStoreSlug: () => PLAN_JETPACK_PERSONAL_MONTHLY,
Expand Down Expand Up @@ -690,6 +734,9 @@ export const PLANS_LIST = {
},

[ PLAN_JETPACK_BUSINESS ]: {
group: GROUP_JETPACK,
type: TYPE_BUSINESS,
term: TERM_ANNUALLY,
getTitle: () => i18n.translate( 'Professional' ),
getAudience: () => i18n.translate( 'Best for organizations' ),
getProductId: () => 2001,
Expand Down Expand Up @@ -748,6 +795,9 @@ export const PLANS_LIST = {
},

[ PLAN_JETPACK_BUSINESS_MONTHLY ]: {
group: GROUP_JETPACK,
type: TYPE_BUSINESS,
term: TERM_MONTHLY,
getTitle: () => i18n.translate( 'Professional' ),
getAudience: () => i18n.translate( 'Best for organizations' ),
getSubtitle: () => i18n.translate( 'Ultimate security and traffic tools.' ),
Expand Down Expand Up @@ -811,6 +861,8 @@ export const PLANS_LIST = {
},
};

export const PLANS_CONSTANTS_LIST = Object.keys( PLANS_LIST );

export const FEATURES_LIST = {
[ FEATURE_BLANK ]: {
getSlug: () => FEATURE_BLANK,
Expand Down Expand Up @@ -1555,27 +1607,22 @@ export function isBestValue( plan ) {
return includes( BEST_VALUE_PLANS, plan );
}

export function getPlanClass( plan ) {
switch ( plan ) {
case PLAN_JETPACK_FREE:
case PLAN_FREE:
return 'is-free-plan';
case PLAN_PERSONAL:
case PLAN_PERSONAL_2_YEARS:
case PLAN_JETPACK_PERSONAL:
case PLAN_JETPACK_PERSONAL_MONTHLY:
return 'is-personal-plan';
case PLAN_PREMIUM:
case PLAN_PREMIUM_2_YEARS:
case PLAN_JETPACK_PREMIUM:
case PLAN_JETPACK_PREMIUM_MONTHLY:
return 'is-premium-plan';
case PLAN_BUSINESS:
case PLAN_BUSINESS_2_YEARS:
case PLAN_JETPACK_BUSINESS:
case PLAN_JETPACK_BUSINESS_MONTHLY:
return 'is-business-plan';
default:
return '';
export function getPlanClass( planKey ) {
if ( isFreePlan( planKey ) ) {
return 'is-free-plan';
}

if ( isPersonalPlan( planKey ) ) {
return 'is-personal-plan';
}

if ( isPremiumPlan( planKey ) ) {
return 'is-premium-plan';
}

if ( isBusinessPlan( planKey ) ) {
return 'is-business-plan';
}

return '';
}
Loading