From d65808e430918d64978939a090bbcfa1e43a464a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gardi?= Date: Thu, 17 Oct 2024 15:53:03 -0300 Subject: [PATCH] Handle A4A Pressable sites which have jetpack deactivated, when it is listed on dotcom. --- client/controller/index.web.js | 4 ++- .../dataviews-fields/site-field.tsx | 8 +++++- .../components/sites-ellipsis-menu.tsx | 26 +++++++++++++++++++ client/sites-dashboard/utils.ts | 5 ++++ packages/data-stores/src/site/types.ts | 1 + packages/sites/src/site-excerpt-constants.ts | 1 + 6 files changed, 43 insertions(+), 2 deletions(-) diff --git a/client/controller/index.web.js b/client/controller/index.web.js index 857bee183a936b..2933338444516e 100644 --- a/client/controller/index.web.js +++ b/client/controller/index.web.js @@ -288,8 +288,10 @@ export function redirectIfJetpackNonAtomic( context, next ) { const site = getSelectedSite( state ); const isAtomicSite = !! site?.is_wpcom_atomic || !! site?.is_wpcom_staging_site; const isJetpackNonAtomic = ! isAtomicSite && !! site?.jetpack; + const isDisconnectedJetpackAndNotAtomic = + ! site?.is_wpcom_atomic && site?.jetpack_connection && ! site?.jetpack; - if ( isJetpackNonAtomic ) { + if ( isJetpackNonAtomic || isDisconnectedJetpackAndNotAtomic ) { return redirectToDashboard( context ); } diff --git a/client/hosting/sites/components/sites-dataviews/dataviews-fields/site-field.tsx b/client/hosting/sites/components/sites-dataviews/dataviews-fields/site-field.tsx index e2b425e28b5d39..968633f65687d2 100644 --- a/client/hosting/sites/components/sites-dataviews/dataviews-fields/site-field.tsx +++ b/client/hosting/sites/components/sites-dataviews/dataviews-fields/site-field.tsx @@ -21,6 +21,7 @@ import { isNotAtomicJetpack, isMigrationInProgress, isStagingSite, + isDisconnectedJetpackAndNotAtomic, } from 'calypso/sites-dashboard/utils'; import { useSelector } from 'calypso/state'; import { canCurrentUser } from 'calypso/state/selectors/can-current-user'; @@ -72,7 +73,12 @@ const SiteField = ( { site, openSitePreviewPane }: Props ) => { const isAdmin = useSelector( ( state ) => canCurrentUser( state, site.ID, 'manage_options' ) ); const onSiteClick = ( event: React.MouseEvent ) => { - if ( isAdmin && ! isP2Site && ! isNotAtomicJetpack( site ) ) { + if ( + isAdmin && + ! isP2Site && + ! isNotAtomicJetpack( site ) && + ! isDisconnectedJetpackAndNotAtomic( site ) + ) { openSitePreviewPane && openSitePreviewPane( site ); } else { navigate( adminUrl ); diff --git a/client/sites-dashboard/components/sites-ellipsis-menu.tsx b/client/sites-dashboard/components/sites-ellipsis-menu.tsx index c4438afc23fbdf..2d0a4d20137275 100644 --- a/client/sites-dashboard/components/sites-ellipsis-menu.tsx +++ b/client/sites-dashboard/components/sites-ellipsis-menu.tsx @@ -39,6 +39,7 @@ import { isNotAtomicJetpack, isSimpleSite, isP2Site, + isDisconnectedJetpackAndNotAtomic, } from '../utils'; import SitePreviewModal from './site-preview-modal'; import type { SiteExcerptData } from '@automattic/sites'; @@ -273,6 +274,22 @@ const WpAdminItem = ( { site, recordTracks }: SitesMenuItemProps ) => { ); }; +const MigrateToWordPress = ( { recordTracks }: SitesMenuItemProps ) => { + const { __ } = useI18n(); + + return ( + recordTracks( 'calypso_sites_dashboard_site_action_migrate_to_wpcom_click' ) } + target="_blank" + icon={ external } + iconPosition="right" + > + { __( 'Migrate to WordPress.com' ) } + + ); +}; + const SiteMenuGroup = styled( MenuGroup )( { '> div[role="group"]': { display: 'flex', @@ -519,6 +536,7 @@ export const SitesEllipsisMenu = ( { }; const isSiteJetpackNotAtomic = isNotAtomicJetpack( site ); + const isSiteDisconnectedJetpackAndNotAtomic = isDisconnectedJetpackAndNotAtomic( site ); const hasHostingFeatures = ! isSiteJetpackNotAtomic && ! isP2Site( site ); const { shouldShowSiteCopyItem, startSiteCopy } = useSiteCopy( site ); const hasCustomDomain = isCustomDomain( site.slug ); @@ -537,6 +555,14 @@ export const SitesEllipsisMenu = ( { ); } + if ( isSiteDisconnectedJetpackAndNotAtomic ) { + return ( + + + + + ); + } return ( diff --git a/client/sites-dashboard/utils.ts b/client/sites-dashboard/utils.ts index 0cf84d118194cc..2559b60768f186 100644 --- a/client/sites-dashboard/utils.ts +++ b/client/sites-dashboard/utils.ts @@ -50,6 +50,11 @@ export const isNotAtomicJetpack = ( site: SiteExcerptNetworkData ) => { return site.jetpack && ! site?.is_wpcom_atomic; }; +// Sites connected through A4A plugin are listed on wordpress.com/sites even when Jetpack is deactivated. +export const isDisconnectedJetpackAndNotAtomic = ( site: SiteExcerptNetworkData ) => { + return ! site?.is_wpcom_atomic && site?.jetpack_connection && ! site?.jetpack; +}; + export const isSimpleSite = ( site: SiteExcerptNetworkData ) => { return ! site?.jetpack && ! site?.is_wpcom_atomic; }; diff --git a/packages/data-stores/src/site/types.ts b/packages/data-stores/src/site/types.ts index 2fdc1b0e9f66d1..117e9f603a7fc9 100644 --- a/packages/data-stores/src/site/types.ts +++ b/packages/data-stores/src/site/types.ts @@ -134,6 +134,7 @@ export interface SiteDetails { is_a4a_client?: boolean; is_a4a_dev_site?: boolean; jetpack: boolean; + jetpack_connection?: boolean; lang?: string; launch_status: string; locale: string; diff --git a/packages/sites/src/site-excerpt-constants.ts b/packages/sites/src/site-excerpt-constants.ts index fbac799595ec15..d43d4e401e0338 100644 --- a/packages/sites/src/site-excerpt-constants.ts +++ b/packages/sites/src/site-excerpt-constants.ts @@ -14,6 +14,7 @@ export const SITE_EXCERPT_REQUEST_FIELDS = [ 'p2_thumbnail_elements', 'plan', 'jetpack', + 'jetpack_connection', 'is_wpcom_atomic', 'is_wpcom_staging_site', 'user_interactions',