Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Fix disabling search plan for Jetpack Complete


2 changes: 1 addition & 1 deletion projects/packages/search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetpack-search",
"version": "0.31.3",
"version": "0.31.4-alpha",
"description": "Package for Jetpack Search products",
"main": "main.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/search/src/class-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Search package general information
*/
class Package {
const VERSION = '0.31.3';
const VERSION = '0.31.4-alpha';
const SLUG = 'search';

/**
Expand Down
8 changes: 8 additions & 0 deletions projects/packages/search/src/class-plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ public function supports_search() {
return ( isset( $plan_info['supports_search'] ) && $plan_info['supports_search'] ) || $this->has_jetpack_search_product();
}

/**
* Returns true if the plan usage is exceeded and search should no longer work.
*/
public function must_upgrade() {
$plan_info = $this->get_plan_info();
return isset( $plan_info['plan_usage']['must_upgrade'] ) && $plan_info['plan_usage']['must_upgrade'];
}

/**
* Returns true if the plan only supports Classic Search.
*/
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/search/src/dashboard/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function check_plan_deactivate_search_module( $current_screen ) {
if (
property_exists( $current_screen, 'base' ) &&
strpos( $current_screen->base, 'jetpack_page_' ) !== false &&
! $this->plan->supports_search()
( ! $this->plan->supports_search() || $this->plan->must_upgrade() )
) {
$this->module_control->deactivate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export default function DashboardPage( { isLoading = false } ) {

const isFreePlan = useSelect( select => select( STORE_ID ).isFreePlan() );
const isOverLimit = useSelect( select => select( STORE_ID ).isOverLimit() );
const isDisabledFromOverLimitOnFreePlan = isOverLimit && isFreePlan;

const updateOptions = useDispatch( STORE_ID ).updateJetpackSettings;
const isInstantSearchPromotionActive = useSelect( select =>
Expand Down Expand Up @@ -146,7 +145,7 @@ export default function DashboardPage( { isLoading = false } ) {
siteAdminUrl={ siteAdminUrl }
updateOptions={ updateOptions }
domain={ domain }
isDisabledFromOverLimit={ isDisabledFromOverLimitOnFreePlan }
isDisabledFromOverLimit={ isOverLimit }
isInstantSearchPromotionActive={ isInstantSearchPromotionActive }
supportsOnlyClassicSearch={ supportsOnlyClassicSearch }
supportsSearch={ supportsSearch }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ const upgradeMessageRequests = apiData => {
return { description: message, cta: cta };
};

const upgradeMessageSearchDisabled = () => {
// Always returns a valid message.
const message = __(
'You’ve exceeded the limits available for your search plan.',
'jetpack-search-pkg'
);
const cta = __( 'Upgrade now to restore Jetpack Search functionality.', 'jetpack-search-pkg' );
return { description: message, cta: cta };
};

const upgradeMessageNoOverage = () => {
// Always returns a valid message.
const message = __(
Expand Down Expand Up @@ -197,7 +207,10 @@ const upgradeMessageFromAPIData = apiData => {
// apiData.currentUsage.upgrade_reason.requests
// apiData.currentUsage.months_over_plan_records_limit
// apiData.currentUsage.months_over_plan_requests_limit
if ( ! apiData.currentUsage.should_upgrade && ! apiData.currentUsage.must_upgrade ) {
if ( apiData.currentUsage.must_upgrade ) {
return upgradeMessageSearchDisabled();
}
if ( ! apiData.currentUsage.should_upgrade ) {
return null;
}
// Handle both case.
Expand All @@ -220,7 +233,11 @@ const upgradeMessageFromAPIData = apiData => {
};

const PlanUsageSection = ( { isFreePlan, planInfo, sendPaidPlanToCart, isPlanJustUpgraded } ) => {
const upgradeMessage = isFreePlan ? upgradeMessageFromAPIData( planInfo ) : null;
// For free plan, we want to show the CTA early.
// For complete plan, we only show the final CTA once search is already disabled.
// It's just because it was added later, and we didn't want to redesign existing CTAs at the time.
const upgradeMessage =
isFreePlan || planInfo.currentUsage.must_upgrade ? upgradeMessageFromAPIData( planInfo ) : null;
const usageInfo = usageInfoFromAPIData( planInfo );

return (
Expand Down