Skip to content

Commit

Permalink
Add Jetpack AI Yearly supporting code (#79959)
Browse files Browse the repository at this point in the history
* Remove MONTHLY_ONLY code logic

* Add jetpack_ai_yearly to product constants

* Add jetpack_ai_yearly to product list, copy, icons
  • Loading branch information
robertsreberski authored Aug 1, 2023
1 parent 7d566a9 commit a445c3d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
10 changes: 1 addition & 9 deletions client/my-sites/plans/jetpack-plans/product-grid/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
JETPACK_RESET_PLANS,
JETPACK_MONTHLY_ONLY_PRODUCTS,
PLAN_JETPACK_SECURITY_T1_YEARLY,
PLAN_JETPACK_SECURITY_T1_MONTHLY,
PLAN_JETPACK_SECURITY_T2_YEARLY,
Expand Down Expand Up @@ -95,14 +94,7 @@ export const getProductsToDisplay = ( {
// Remove add-on products
.filter( removeAddons )
// Remove products that don't match the selected duration
// However, allow products that ONLY have a monthly term to come through in either view
.filter(
( product ): product is SelectorProduct =>
product?.term === duration ||
( JETPACK_MONTHLY_ONLY_PRODUCTS as ReadonlyArray< string > ).includes(
product?.productSlug
)
)
.filter( ( product ): product is SelectorProduct => product?.term === duration )
// TODO: Identify a suitable Stats plan according to the site classification.
.filter( ( product ) => {
if (
Expand Down
15 changes: 10 additions & 5 deletions packages/calypso-products/src/constants/jetpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const GROUP_JETPACK = 'GROUP_JETPACK';

// Products
export const PRODUCT_JETPACK_AI_MONTHLY = 'jetpack_ai_monthly';
export const PRODUCT_JETPACK_AI_YEARLY = 'jetpack_ai_yearly';
export const PRODUCT_JETPACK_BOOST = 'jetpack_boost_yearly';
export const PRODUCT_JETPACK_BOOST_MONTHLY = 'jetpack_boost_monthly';
export const PRODUCT_JETPACK_BACKUP = 'jetpack_backup';
Expand Down Expand Up @@ -191,9 +192,7 @@ export const JETPACK_VIDEOPRESS_PRODUCTS = <const>[
PRODUCT_JETPACK_VIDEOPRESS_MONTHLY,
];

export const JETPACK_AI_PRODUCTS = <const>[ PRODUCT_JETPACK_AI_MONTHLY ];

export const JETPACK_MONTHLY_ONLY_PRODUCTS = <const>[ PRODUCT_JETPACK_AI_MONTHLY ];
export const JETPACK_AI_PRODUCTS = <const>[ PRODUCT_JETPACK_AI_MONTHLY, PRODUCT_JETPACK_AI_YEARLY ];

// WooCommerce Products
export const WOOCOMMERCE_PRODUCTS = <const>[
Expand Down Expand Up @@ -276,7 +275,7 @@ export const JETPACK_PRODUCTS_BY_TERM = <const>[
monthly: PRODUCT_JETPACK_SOCIAL_ADVANCED_MONTHLY,
},
{
yearly: null,
yearly: PRODUCT_JETPACK_AI_YEARLY,
monthly: PRODUCT_JETPACK_AI_MONTHLY,
},
];
Expand Down Expand Up @@ -696,7 +695,13 @@ export const JETPACK_PRODUCT_RECCOMENDATION_MAP: Record< string, string[] > = {
JETPACK_TAG_FOR_ONLINE_FORUMS,
JETPACK_TAG_FOR_WOOCOMMERCE_STORES,
],

[ PRODUCT_JETPACK_AI_YEARLY ]: [
JETPACK_TAG_FOR_BLOGGERS,
JETPACK_TAG_FOR_NEWS_ORGANISATIONS,
JETPACK_TAG_FOR_MEMBERSHIP_SITES,
JETPACK_TAG_FOR_ONLINE_FORUMS,
JETPACK_TAG_FOR_WOOCOMMERCE_STORES,
],
// WooCommerce Extensions
[ PRODUCT_WOOCOMMERCE_BOOKINGS ]: [ JETPACK_TAG_FOR_WOOCOMMERCE_STORES ],
[ PRODUCT_WOOCOMMERCE_SUBSCRIPTIONS ]: [ JETPACK_TAG_FOR_WOOCOMMERCE_STORES ],
Expand Down
12 changes: 12 additions & 0 deletions packages/calypso-products/src/products-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
PLAN_ANNUAL_PERIOD,
PLAN_MONTHLY_PERIOD,
PRODUCT_JETPACK_AI_MONTHLY,
PRODUCT_JETPACK_AI_YEARLY,
PRODUCT_JETPACK_ANTI_SPAM,
PRODUCT_JETPACK_ANTI_SPAM_MONTHLY,
PRODUCT_JETPACK_BACKUP_DAILY,
Expand Down Expand Up @@ -115,6 +116,17 @@ export const JETPACK_SITE_PRODUCTS_WITH_FEATURES: Record<
getProductId: () => 2450,
getStoreSlug: () => PRODUCT_JETPACK_AI_MONTHLY,
},
[ PRODUCT_JETPACK_AI_YEARLY ]: {
product_name: PRODUCT_SHORT_NAMES[ PRODUCT_JETPACK_AI_YEARLY ],
product_slug: PRODUCT_JETPACK_AI_YEARLY,
type: PRODUCT_JETPACK_AI_YEARLY,
term: TERM_ANNUALLY,
bill_period: PLAN_ANNUAL_PERIOD,
categories: [],
getFeatures: () => [],
getProductId: () => 2451,
getStoreSlug: () => PRODUCT_JETPACK_AI_YEARLY,
},
[ PRODUCT_JETPACK_BACKUP_DAILY ]: {
product_name: PRODUCT_SHORT_NAMES[ PRODUCT_JETPACK_BACKUP_DAILY ],
product_slug: PRODUCT_JETPACK_BACKUP_DAILY,
Expand Down
14 changes: 14 additions & 0 deletions packages/calypso-products/src/translations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
PRODUCT_JETPACK_SOCIAL_ADVANCED,
PRODUCT_JETPACK_SOCIAL_ADVANCED_MONTHLY,
PRODUCT_JETPACK_AI_MONTHLY,
PRODUCT_JETPACK_AI_YEARLY,
JETPACK_TAG_FOR_VIDEOGRAPHERS,
JETPACK_TAG_FOR_ALL_SITES,
JETPACK_TAG_FOR_BLOGGERS,
Expand Down Expand Up @@ -142,6 +143,7 @@ export const getJetpackProductsShortNames = (): Record< string, TranslateResult
context: 'Jetpack product name',
} ),
[ PRODUCT_JETPACK_AI_MONTHLY ]: translate( 'AI' ),
[ PRODUCT_JETPACK_AI_YEARLY ]: translate( 'AI' ),
};
};

Expand Down Expand Up @@ -238,6 +240,7 @@ export const getJetpackProductsDisplayNames = (): Record< string, TranslateResul

return {
[ PRODUCT_JETPACK_AI_MONTHLY ]: aiAssistant,
[ PRODUCT_JETPACK_AI_YEARLY ]: aiAssistant,
[ PRODUCT_JETPACK_BACKUP_DAILY ]: backupDaily,
[ PRODUCT_JETPACK_BACKUP_DAILY_MONTHLY ]: backupDaily,
[ PRODUCT_JETPACK_BACKUP_REALTIME ]: backupRealtime,
Expand Down Expand Up @@ -312,6 +315,7 @@ export const getJetpackProductsCallToAction = (): Record< string, TranslateResul

return {
[ PRODUCT_JETPACK_AI_MONTHLY ]: aiAssistant,
[ PRODUCT_JETPACK_AI_YEARLY ]: aiAssistant,
[ PRODUCT_JETPACK_BACKUP_DAILY ]: backupDaily,
[ PRODUCT_JETPACK_BACKUP_DAILY_MONTHLY ]: backupDaily,
[ PRODUCT_JETPACK_BACKUP_REALTIME ]: backupRealtime,
Expand Down Expand Up @@ -381,6 +385,10 @@ export const getJetpackProductsTaglines = (): Record<
default: aiAssistantTagLine,
owned: aiAssistantOwnedTagLine,
},
[ PRODUCT_JETPACK_AI_YEARLY ]: {
default: aiAssistantTagLine,
owned: aiAssistantOwnedTagLine,
},
[ PRODUCT_JETPACK_BACKUP_DAILY ]: {
default: backupDailyTagline,
owned: backupOwnedTagline,
Expand Down Expand Up @@ -578,6 +586,7 @@ export const getJetpackProductsDescriptions = (): Record< string, TranslateResul

return {
[ PRODUCT_JETPACK_AI_MONTHLY ]: aiAssistantDescription,
[ PRODUCT_JETPACK_AI_YEARLY ]: aiAssistantDescription,
[ PRODUCT_JETPACK_BACKUP_DAILY ]: backupDailyDescription,
[ PRODUCT_JETPACK_BACKUP_DAILY_MONTHLY ]: backupDailyDescription,
[ PRODUCT_JETPACK_BACKUP_REALTIME ]: backupRealtimeDescription,
Expand Down Expand Up @@ -641,6 +650,7 @@ export const getJetpackProductsShortDescriptions = (): Record< string, Translate

return {
[ PRODUCT_JETPACK_AI_MONTHLY ]: aiAssistantShortDescription,
[ PRODUCT_JETPACK_AI_YEARLY ]: aiAssistantShortDescription,
[ PRODUCT_JETPACK_BACKUP_DAILY ]: backupDailyShortDescription,
[ PRODUCT_JETPACK_BACKUP_DAILY_MONTHLY ]: backupDailyShortDescription,
[ PRODUCT_JETPACK_BACKUP_REALTIME ]: backupRealtimeShortDescription,
Expand Down Expand Up @@ -706,6 +716,7 @@ export const getJetpackProductsFeaturedDescription = (): Record< string, Transla

return {
[ PRODUCT_JETPACK_AI_MONTHLY ]: aiAssistantFeaturedText,
[ PRODUCT_JETPACK_AI_YEARLY ]: aiAssistantFeaturedText,
[ PRODUCT_JETPACK_BACKUP_DAILY ]: backupDailyFeaturedText,
[ PRODUCT_JETPACK_BACKUP_DAILY_MONTHLY ]: backupDailyFeaturedText,
[ PRODUCT_JETPACK_BACKUP_REALTIME ]: backupFeaturedText,
Expand Down Expand Up @@ -789,6 +800,7 @@ export const getJetpackProductsLightboxDescription = (): Record< string, Transla

return {
[ PRODUCT_JETPACK_AI_MONTHLY ]: aiAssistantLightboxDescription,
[ PRODUCT_JETPACK_AI_YEARLY ]: aiAssistantLightboxDescription,
[ PRODUCT_JETPACK_BACKUP_DAILY ]: backupDailyLightboxDescription,
[ PRODUCT_JETPACK_BACKUP_DAILY_MONTHLY ]: backupDailyLightboxDescription,
[ PRODUCT_JETPACK_BACKUP_REALTIME ]: backupLightboxDescription,
Expand Down Expand Up @@ -1041,6 +1053,7 @@ export const getJetpackProductsWhatIsIncluded = (): Record< string, Array< Trans

return {
[ PRODUCT_JETPACK_AI_MONTHLY ]: aiAssistantIncludesInfo,
[ PRODUCT_JETPACK_AI_YEARLY ]: aiAssistantIncludesInfo,
[ PRODUCT_JETPACK_BACKUP_T0_YEARLY ]: backupIncludesInfoT0,
[ PRODUCT_JETPACK_BACKUP_T0_MONTHLY ]: backupIncludesInfoT0,
[ PRODUCT_JETPACK_BACKUP_DAILY ]: backupIncludesInfoT1,
Expand Down Expand Up @@ -1221,6 +1234,7 @@ export const getJetpackProductsBenefits = (): Record< string, Array< TranslateRe

return {
[ PRODUCT_JETPACK_AI_MONTHLY ]: aiAssistantBenefits,
[ PRODUCT_JETPACK_AI_YEARLY ]: aiAssistantBenefits,
[ PRODUCT_JETPACK_BACKUP_DAILY ]: backupBenefits,
[ PRODUCT_JETPACK_BACKUP_DAILY_MONTHLY ]: backupBenefits,
[ PRODUCT_JETPACK_BACKUP_REALTIME ]: backupBenefits,
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/product-icon/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type SupportedSlugs =
| 'pro-plan'
| 'starter-plan'
| 'jetpack_ai_monthly'
| 'jetpack_ai_yearly'
| 'jetpack_free'
| 'jetpack_personal'
| 'jetpack_personal_monthly'
Expand Down Expand Up @@ -162,7 +163,7 @@ export const iconToProductSlugMap: Record< keyof typeof paths, readonly Supporte
],
'wpcom-ecommerce': [ 'ecommerce-bundle', 'ecommerce-bundle-2y', 'ecommerce-bundle-monthly' ],
'wpcom-business': [ 'business-bundle', 'business-bundle-2y', 'business-bundle-monthly' ],
'jetpack-ai': [ 'jetpack_ai_monthly' ],
'jetpack-ai': [ 'jetpack_ai_monthly', 'jetpack_ai_yearly' ],
'jetpack-free': [ 'jetpack_free' ],
'jetpack-personal': [ 'jetpack_personal', 'jetpack_personal_monthly' ],
'jetpack-premium': [ 'jetpack_premium', 'jetpack_premium_monthly' ],
Expand Down

0 comments on commit a445c3d

Please sign in to comment.