From cce1e224ad37c6624a4e57317e7bcf2015479bc8 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Tue, 23 Apr 2024 17:52:29 +0200 Subject: [PATCH] CYS - AI flow: keep persisted query param when redirecting (#46820) * CYS - set flowType when the state machine is instantiated * remove not necessary code * Add changefile(s) from automation for the following project(s): woocommerce * fix action * improve logic * Add changefile(s) from automation for the following project(s): woocommerce * CYS - AI Flow: hide X button on the entrepreneur flow * CYS - AI flow: keep persisted query param when redirect * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions --- .../customize-store/assembler-hub/sidebar/index.tsx | 2 ++ .../assembler-hub/sidebar/sidebar-navigation-screen.tsx | 6 +++++- .../client/customize-store/assembler-hub/site-hub.tsx | 8 ++++++-- .../woocommerce-admin/client/customize-store/index.tsx | 3 ++- plugins/woocommerce/changelog/46820-fix-redirect-button | 4 ++++ 5 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 plugins/woocommerce/changelog/46820-fix-redirect-button diff --git a/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/index.tsx b/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/index.tsx index c862af81453..b84c247382e 100644 --- a/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/index.tsx +++ b/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/index.tsx @@ -33,6 +33,8 @@ import { updateQueryString, useQuery, } from '@woocommerce/navigation'; +// In some cases, the assembler is loaded in an iframe, so we have to re-apply the filter. +import '~/customize-store/design-with-ai/entrepreneur-flow'; function isSubset( subset: { diff --git a/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen.tsx b/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen.tsx index f42c1db8cc5..e2db95b41bd 100644 --- a/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen.tsx +++ b/plugins/woocommerce-admin/client/customize-store/assembler-hub/sidebar/sidebar-navigation-screen.tsx @@ -31,6 +31,7 @@ import { GoBackWarningModal } from '../go-back-warning-modal'; */ import { CustomizeStoreContext } from '../'; import { isAIFlow } from '~/customize-store/guards'; +import { isEntrepreneurFlow } from '~/customize-store/design-with-ai/entrepreneur-flow'; const { useLocation } = unlock( routerPrivateApis ); export const SidebarNavigationScreen = ( { @@ -98,7 +99,7 @@ export const SidebarNavigationScreen = ( { showTooltip={ false } /> ) } - { isRoot && ( + { isRoot && ! isEntrepreneurFlow() && ( { setOpenWarningModal( true ); @@ -110,6 +111,9 @@ export const SidebarNavigationScreen = ( { ) } diff --git a/plugins/woocommerce-admin/client/customize-store/index.tsx b/plugins/woocommerce-admin/client/customize-store/index.tsx index 1b66af78a21..14f4aa25e3f 100644 --- a/plugins/woocommerce-admin/client/customize-store/index.tsx +++ b/plugins/woocommerce-admin/client/customize-store/index.tsx @@ -12,6 +12,7 @@ import { getQuery, updateQueryString, getHistory, + getPersistedQuery, } from '@woocommerce/navigation'; import { OPTIONS_STORE_NAME } from '@woocommerce/data'; import { dispatch, resolveSelect } from '@wordpress/data'; @@ -81,7 +82,7 @@ const updateQueryStep = ( }; const redirectToWooHome = () => { - const url = getNewPath( {}, '/', {} ); + const url = getNewPath( getPersistedQuery(), '/', {} ); navigateOrParent( window, url ); }; diff --git a/plugins/woocommerce/changelog/46820-fix-redirect-button b/plugins/woocommerce/changelog/46820-fix-redirect-button new file mode 100644 index 00000000000..d536766c0e0 --- /dev/null +++ b/plugins/woocommerce/changelog/46820-fix-redirect-button @@ -0,0 +1,4 @@ +Significance: minor +Type: tweak + +CYS - AI flow: keep persisted query param when redirecting. \ No newline at end of file