From c2b86650ed65491a9891d236c59eaac810d27985 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Mon, 26 Aug 2024 16:34:10 -0300 Subject: [PATCH] My Jetpack: handle AI is_upgradable (#39074) * copy edits * compute is_upgradable properly based on current tier and if tier plans are disabled * fix glitch when trying to calculate remaining days * fix interstitial parameters and cta label * revert description until we figure out a good one, if needed * fix versions --- .../product-interstitial/jetpack-ai/index.jsx | 6 ++++-- .../jetpack-ai/product-page.jsx | 6 ++++-- .../change-my-jetpack-disabled-tiers-handle | 4 ++++ projects/packages/my-jetpack/package.json | 2 +- .../my-jetpack/src/class-initializer.php | 2 +- .../src/products/class-jetpack-ai.php | 21 ++++++++++++------- 6 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 projects/packages/my-jetpack/changelog/change-my-jetpack-disabled-tiers-handle diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/index.jsx b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/index.jsx index c6a9245b281c1..246c1b831c90c 100644 --- a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/index.jsx +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/index.jsx @@ -1,6 +1,7 @@ /** * External dependencies */ +import { __ } from '@wordpress/i18n'; import debugFactory from 'debug'; import { useCallback } from 'react'; /** @@ -41,13 +42,14 @@ export default function JetpackAiInterstitial() { return ( - Search + Jetpack AI ); } diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx index 0f8f37370ac74..5a8981407e29e 100644 --- a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx @@ -64,10 +64,11 @@ export default function () { nextTier, usagePeriod: usage, isOverLimit, + tierPlansEnabled, } = aiAssistantFeature || {}; - const hasUnlimited = currentTier?.value === 1; const isFree = currentTier?.value === 0; + const hasUnlimited = currentTier?.value === 1 || ( ! tierPlansEnabled && ! isFree ); const hasPaidTier = ! isFree && ! hasUnlimited; const shouldContactUs = ! hasUnlimited && hasPaidTier && ! nextTier && currentTier; const freeRequestsLeft = isFree && 20 - allTimeRequests >= 0 ? 20 - allTimeRequests : 0; @@ -116,8 +117,9 @@ export default function () { 'Wait for %d days to reset your limit, or upgrade now to a higher tier for additional requests and keep your work moving forward.', 'jetpack-my-jetpack' ), - Math.floor( ( new Date( usage?.[ 'next-start' ] ) - new Date() ) / ( 1000 * 60 * 60 * 24 ) ) + Math.floor( ( new Date( usage?.nextStart || null ) - new Date() ) / ( 1000 * 60 * 60 * 24 ) ) ); + const upgradeNoticeBody = __( 'Reach for More with Jetpack AI! Upgrade now for additional requests and keep your momentum going.', 'jetpack-my-jetpack' diff --git a/projects/packages/my-jetpack/changelog/change-my-jetpack-disabled-tiers-handle b/projects/packages/my-jetpack/changelog/change-my-jetpack-disabled-tiers-handle new file mode 100644 index 0000000000000..49cd68c2f1c58 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/change-my-jetpack-disabled-tiers-handle @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +My Jetpack: reflect tier filters properly on product class and UI. Fix little nuances with date constructor diff --git a/projects/packages/my-jetpack/package.json b/projects/packages/my-jetpack/package.json index 3735b0ac72a5d..2b9094fdd102b 100644 --- a/projects/packages/my-jetpack/package.json +++ b/projects/packages/my-jetpack/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-my-jetpack", - "version": "4.33.0", + "version": "4.33.1-alpha", "description": "WP Admin page with information and configuration shared among all Jetpack stand-alone plugins", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/my-jetpack/#readme", "bugs": { diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index b0be741ad3c7b..67a7ff1ee44a9 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -42,7 +42,7 @@ class Initializer { * * @var string */ - const PACKAGE_VERSION = '4.33.0'; + const PACKAGE_VERSION = '4.33.1-alpha'; /** * HTML container ID for the IDC screen on My Jetpack page. diff --git a/projects/packages/my-jetpack/src/products/class-jetpack-ai.php b/projects/packages/my-jetpack/src/products/class-jetpack-ai.php index eeb28354094c5..4bf2a21197110 100644 --- a/projects/packages/my-jetpack/src/products/class-jetpack-ai.php +++ b/projects/packages/my-jetpack/src/products/class-jetpack-ai.php @@ -272,11 +272,12 @@ public static function get_features_by_usage_tier( $tier ) { } $features = array( - __( 'Artificial intelligence chatbot', 'jetpack-my-jetpack' ), __( 'Generate text, tables, lists, and forms', 'jetpack-my-jetpack' ), - __( 'Refine the tone and content to your liking', 'jetpack-my-jetpack' ), - __( 'Get feedback about your post', 'jetpack-my-jetpack' ), - __( 'Seamless WordPress editor integration', 'jetpack-my-jetpack' ), + __( 'Easily refine content to your liking', 'jetpack-my-jetpack' ), + __( 'Make your content easier to read', 'jetpack-my-jetpack' ), + __( 'Generate images with one-click', 'jetpack-my-jetpack' ), + __( 'Optimize your titles for better performance', 'jetpack-my-jetpack' ), + __( 'Priority support', 'jetpack-my-jetpack' ), ); $tiered_features = array( @@ -468,9 +469,15 @@ public static function has_paid_plan_for_product() { * @return boolean */ public static function is_upgradable() { - $has_ai_feature = static::does_site_have_feature( 'ai-assistant' ); - $current_tier = self::get_current_usage_tier(); - $next_tier = self::get_next_usage_tier(); + $has_ai_feature = static::does_site_have_feature( 'ai-assistant' ); + $tier_plans_enabled = self::are_tier_plans_enabled(); + $current_tier = self::get_current_usage_tier(); + + if ( $has_ai_feature && ! $tier_plans_enabled && $current_tier >= 1 ) { + return false; + } + + $next_tier = self::get_next_usage_tier(); // The check below is debatable, not having the feature should not flag as not upgradable. // If user is free (tier = 0), not unlimited (tier = 1) and has a next tier, then it's upgradable.