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

Site Migration: Indicate that you own the plan on the Migrate vs Import step #98017

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
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
Expand Up @@ -2,6 +2,7 @@ import { Badge } from '@automattic/components';
import { Flex, FlexBlock, FlexItem, Card, CardBody, Icon } from '@wordpress/components';
import { chevronRight } from '@wordpress/icons';
import clsx from 'clsx';
import { type ReactNode } from 'react';
import type { BadgeType } from '@automattic/components';
import './style.scss';

Expand All @@ -13,7 +14,7 @@ interface FlowCardProps {
disabled?: boolean;
badge?: {
type: BadgeType;
text: string;
text: ReactNode;
};
className?: string;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { getPlan, isWpComBusinessPlan, PLAN_BUSINESS } from '@automattic/calypso-products';
import { getPlan, PLAN_BUSINESS } from '@automattic/calypso-products';
import { BadgeType } from '@automattic/components';
import { StepContainer } from '@automattic/onboarding';
import { canInstallPlugins } from '@automattic/sites';
import { getQueryArg } from '@wordpress/url';
import { useTranslate } from 'i18n-calypso';
import { useMemo } from 'react';
import DocumentHead from 'calypso/components/data/document-head';
import FormattedHeader from 'calypso/components/formatted-header';
import { useMigrationCancellation } from 'calypso/data/site-migration/landing/use-migration-cancellation';
Expand All @@ -22,74 +23,49 @@ const SiteMigrationImportOrMigrate: Step = function ( { navigation, flow } ) {
const importSiteQueryParam = getQueryArg( window.location.href, 'from' )?.toString() || '';
const { deleteMigrationSticker } = useMigrationStickerMutation();
const { mutate: cancelMigration } = useMigrationCancellation( site?.ID );

const isBusinessPlan = site?.plan?.product_slug
? isWpComBusinessPlan( site?.plan?.product_slug )
: false;

let options;

const siteCanInstallPlugins = canInstallPlugins( site );
const isUpgradeRequired = ! siteCanInstallPlugins;
const isMigrationExperimentEnabled = useMigrationExperiment( flow );

if ( isMigrationExperimentEnabled ) {
const badgeText = isBusinessPlan
? translate( 'Included with your plan' )
: // translators: %(planName)s is a plan name (e.g. Commerce plan).
( translate( 'Available on %(planName)s with 50% off', {
const options = useMemo( () => {
const upgradeRequiredLabel = isMigrationExperimentEnabled
? translate( 'Available on %(planName)s with 50% off', {
args: { planName: getPlan( PLAN_BUSINESS )?.getTitle() ?? '' },
} )
: translate( 'Requires %(planName)s plan', {
args: { planName: getPlan( PLAN_BUSINESS )?.getTitle() ?? '' },
} ) as string );
} );

options = [
{
label: translate( 'Migrate site' ),
description: translate(
const migrateOptionDescription = isMigrationExperimentEnabled
? translate(
"Best for WordPress sites. Seamlessly move all your site's content, themes, plugins, users, and customizations to WordPress.com."
),
value: 'migrate',
badge: {
type: 'info-blue' as BadgeType,
text: badgeText,
},
selected: true,
},
{
label: translate( 'Import content only' ),
description: translate( 'Import posts, pages, comments, and media only.' ),
value: 'import',
},
];
} else {
options = [
)
: translate( "All your site's content, themes, plugins, users and customizations." );

return [
{
label: translate( 'Migrate site' ),
description: translate(
"All your site's content, themes, plugins, users and customizations."
),
description: migrateOptionDescription,
value: 'migrate',
badge: {
type: 'info-blue' as BadgeType,
// translators: %(planName)s is a plan name (e.g. Commerce plan).
text: translate( 'Requires %(planName)s plan', {
args: { planName: getPlan( PLAN_BUSINESS )?.getTitle() ?? '' },
} ) as string,
text: isUpgradeRequired ? upgradeRequiredLabel : translate( 'Included with your plan' ),
},
selected: true,
},
{
label: translate( 'Import content only' ),
description: translate( 'Import just posts, pages, comments and media.' ),
description: translate( 'Import posts, pages, comments, and media only.' ),
value: 'import',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this copy changed?

},
];
}
}, [ isMigrationExperimentEnabled, isUpgradeRequired, translate ] );

const { data: hostingProviderDetails } = useHostingProviderUrlDetails( importSiteQueryParam );
const hostingProviderName = hostingProviderDetails.name;
const shouldDisplayHostIdentificationMessage =
! hostingProviderDetails.is_unknown && ! hostingProviderDetails.is_a8c;

const siteCanInstallPlugins = canInstallPlugins( site );

const handleClick = ( destination: string ) => {
if ( destination === 'migrate' && ! siteCanInstallPlugins ) {
return navigation.submit?.( { destination: 'upgrade' } );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,19 @@ describe( 'Site Migration Import or Migrate Step', () => {

expect( deleteMigrationSticker ).toHaveBeenCalledWith( 123 );
} );

it( 'shows the upgrade required badge when the site can not install plugins', () => {
render();

expect( screen.getByText( /Requires Business plan/ ) ).toBeInTheDocument();
} );

it( 'shows the included with your plan badge when the site can install plugins', () => {
( useSite as jest.Mock ).mockReturnValue( {
plan: { features: { active: [ 'install-plugins' ] } },
} );
render();

expect( screen.getByText( /Included with your plan/ ) ).toBeInTheDocument();
} );
} );
3 changes: 2 additions & 1 deletion packages/subscriber/src/components/flow-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Badge } from '@automattic/components';
import { Flex, FlexBlock, FlexItem, Card, CardBody, Icon } from '@wordpress/components';
import { chevronRight } from '@wordpress/icons';
import clsx from 'clsx';
import { type ReactNode } from 'react';
import type { BadgeType } from '@automattic/components';
import './style.scss';

Expand All @@ -13,7 +14,7 @@ interface FlowCardProps {
disabled?: boolean;
badge?: {
type: BadgeType;
text: string;
text: ReactNode;
};
className?: string;
}
Expand Down
Loading