Skip to content

Commit

Permalink
Scheduled Updates: Show Jetpack users migrate upsell banner (#88658)
Browse files Browse the repository at this point in the history
* Show Jetpack users migrate upsell banner

* Make sure a jetpack site is not an Atomic site

* Add ref to the query string
  • Loading branch information
ouikhuan authored Mar 22, 2024
1 parent 4fbaaa4 commit 142b29e
Showing 1 changed file with 60 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,71 @@ import { addQueryArgs } from '@wordpress/url';
import { useTranslate } from 'i18n-calypso';
import UpsellNudge from 'calypso/blocks/upsell-nudge';
import { useSelector } from 'calypso/state';
import { getSelectedSiteSlug } from 'calypso/state/ui/selectors';
import isAtomicSite from 'calypso/state/selectors/is-site-automated-transfer';
import { isJetpackSite } from 'calypso/state/sites/selectors';
import { getSelectedSiteSlug, getSelectedSiteId } from 'calypso/state/ui/selectors';

const UpsellNudgeNotice = () => {
const translate = useTranslate();
const siteSlug = useSelector( getSelectedSiteSlug );
const siteId = useSelector( getSelectedSiteId );
const isJetpack = useSelector( ( state ) => isJetpackSite( state, siteId ) );
const isAtomic = useSelector( ( state ) => isAtomicSite( state, siteId ) );

const titleText = translate(
'Upgrade to the %(businessPlanName)s plan to install plugins and manage scheduled updates.',
{
args: { businessPlanName: getPlan( PLAN_BUSINESS )?.getTitle() ?? '' },
}
);

const href = addQueryArgs( `/checkout/${ siteSlug }/business`, {
redirect_to: `/plugins/scheduled-updates/${ siteSlug }`,
} );

return (
<UpsellNudge
className="scheduled-updates-upsell-nudge"
title={ titleText }
event="calypso_scheduled_updates_upgrade_click"
href={ href }
callToAction={ translate( 'Upgrade' ) }
plan={ PLAN_BUSINESS }
showIcon={ true }
feature={ WPCOM_FEATURES_SCHEDULED_UPDATES }
/>
);
const getWpcomUpgradeNudge = () => {
const titleText = translate(
'Upgrade to the %(businessPlanName)s plan to install plugins and manage scheduled updates.',
{
args: { businessPlanName: getPlan( PLAN_BUSINESS )?.getTitle() ?? '' },
}
);

const href = addQueryArgs( `/checkout/${ siteSlug }/business`, {
redirect_to: `/plugins/scheduled-updates/${ siteSlug }`,
} );

return (
<UpsellNudge
className="scheduled-updates-upsell-nudge"
title={ titleText }
tracksImpressionName="calypso_scheduled_updates_upgrade_impression"
event="calypso_scheduled_updates_upgrade_upsell"
tracksClickName="calypso_scheduled_updates_upgrade_click"
href={ href }
callToAction={ translate( 'Upgrade' ) }
plan={ PLAN_BUSINESS }
showIcon={ true }
feature={ WPCOM_FEATURES_SCHEDULED_UPDATES }
/>
);
};

const getJetpackMigrateNudge = () => {
const titleText = translate(
'Thank you for you interest in scheduling plugin updates. Migrate your site to WordPress.com to get started!'
);

const href = addQueryArgs( `/setup/import-hosted-site/import`, {
source: 'scheduled-updates-dashboard',
ref: 'scheduled-updates-dashboard',
} );

return (
<UpsellNudge
className="scheduled-updates-upsell-nudge"
title={ titleText }
tracksImpressionName="calypso_scheduled_updates_migrate_impression"
event="calypso_scheduled_updates_migrate_upsell"
tracksClickName="calypso_scheduled_updates_migrate_click"
href={ href }
callToAction={ translate( 'Migrate' ) }
showIcon={ true }
feature={ WPCOM_FEATURES_SCHEDULED_UPDATES }
/>
);
};

return isJetpack && ! isAtomic ? getJetpackMigrateNudge() : getWpcomUpgradeNudge();
};

export default UpsellNudgeNotice;

0 comments on commit 142b29e

Please sign in to comment.