From cf0aa1a007213a6cfcf40b420acd7f4b9c1d8441 Mon Sep 17 00:00:00 2001 From: "okmttdhr, tada" Date: Mon, 7 Oct 2024 14:01:12 +0900 Subject: [PATCH] Redirect to plugins.php after plugin activation instead of Congrats page (#95050) * Redirect to plugins.php after plugin activation instead of Congrats page * See if Simple flow works with longer wait time * Check WPCOM_FEATURES_MANAGE_PLUGINS before redirecting --- .../marketplace-product-install/index.tsx | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/client/my-sites/marketplace/pages/marketplace-product-install/index.tsx b/client/my-sites/marketplace/pages/marketplace-product-install/index.tsx index cb39cd1e66873..d58a2147cdffe 100644 --- a/client/my-sites/marketplace/pages/marketplace-product-install/index.tsx +++ b/client/my-sites/marketplace/pages/marketplace-product-install/index.tsx @@ -1,4 +1,9 @@ -import { PLAN_BUSINESS, WPCOM_FEATURES_ATOMIC, getPlan } from '@automattic/calypso-products'; +import { + PLAN_BUSINESS, + WPCOM_FEATURES_ATOMIC, + getPlan, + WPCOM_FEATURES_MANAGE_PLUGINS, +} from '@automattic/calypso-products'; import page from '@automattic/calypso-router'; import { Button } from '@automattic/components'; import { css, Global, ThemeProvider } from '@emotion/react'; @@ -43,7 +48,7 @@ import getUploadedPluginId from 'calypso/state/selectors/get-uploaded-plugin-id' import isPluginUploadComplete from 'calypso/state/selectors/is-plugin-upload-complete'; import isSiteAutomatedTransfer from 'calypso/state/selectors/is-site-automated-transfer'; import siteHasFeature from 'calypso/state/selectors/site-has-feature'; -import { isJetpackSite } from 'calypso/state/sites/selectors'; +import { isJetpackSite, getSiteAdminUrl } from 'calypso/state/sites/selectors'; import { initiateThemeTransfer as initiateTransfer, installAndActivateTheme, @@ -260,29 +265,41 @@ const MarketplaceProductInstall = ( { // eslint-disable-next-line react-hooks/exhaustive-deps }, [ pluginUploadComplete, installedPlugin, setCurrentStep ] ); + const pluginsUrl = useSelector( ( state ) => + getSiteAdminUrl( state, siteId, 'plugins.php?activate=true' ) + ); + const canManagePlugins = useSelector( ( state ) => { + return siteHasFeature( state, selectedSite?.ID, WPCOM_FEATURES_MANAGE_PLUGINS ); + } ); // Check completition of all flows and redirect to thank you page useEffect( () => { if ( // Default process ( installedPlugin && pluginActive ) || // Transfer to atomic using a marketplace plugin - ( atomicFlow && transferStates.COMPLETE === automatedTransferStatus ) || + ( atomicFlow && transferStates.COMPLETE === automatedTransferStatus && canManagePlugins ) || // Transfer to atomic uploading a zip plugin ( uploadedPluginSlug && isPluginUploadFlow && ! isAtomic && - transferStates.COMPLETE === automatedTransferStatus ) + transferStates.COMPLETE === automatedTransferStatus && + canManagePlugins ) ) { - waitFor( 1 ).then( () => - page.redirect( - `/marketplace/thank-you/${ selectedSiteSlug }?hide-progress-bar&plugins=${ - installedPlugin?.slug || pluginSlug || uploadedPluginSlug - }` - ) - ); + waitFor( 1 ).then( () => { + window.location.href = pluginsUrl as string; + } ); } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [ pluginActive, automatedTransferStatus, atomicFlow, isPluginUploadFlow, isAtomic ] ); // We need to trigger this hook also when `automatedTransferStatus` changes cause the plugin install is done on the background in that case. + }, [ + pluginActive, + automatedTransferStatus, + atomicFlow, + isPluginUploadFlow, + isAtomic, + canManagePlugins, + installedPlugin, + uploadedPluginSlug, + pluginsUrl, + ] ); // We need to trigger this hook also when `automatedTransferStatus` changes cause the plugin install is done on the background in that case. // Validate theme is already active useEffect( () => {