From f89366033d758a224d7a2768236c6d9543c13198 Mon Sep 17 00:00:00 2001 From: Chi-Hsuan Huang Date: Fri, 13 Sep 2024 08:34:17 +0800 Subject: [PATCH] Dynamically set plugin_name when redirecting to Jetpack Auth from core profiler (#51278) * Dynamically set plugin_name when redirecting to Jetpack Auth from core profiler * Add changelog * Update param name --- .../client/core-profiler/index.tsx | 15 ++++++++++++++- .../changelog/update-dynamically-set-plugin-name | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/update-dynamically-set-plugin-name diff --git a/plugins/woocommerce-admin/client/core-profiler/index.tsx b/plugins/woocommerce-admin/client/core-profiler/index.tsx index 428566a4578..8dbcd742f3f 100644 --- a/plugins/woocommerce-admin/client/core-profiler/index.tsx +++ b/plugins/woocommerce-admin/client/core-profiler/index.tsx @@ -300,15 +300,28 @@ const exitToWooHome = fromPromise( async () => { window.location.href = getNewPath( {}, '/', {} ); } ); +const getPluginNameParam = ( + pluginsSelected: CoreProfilerStateMachineContext[ 'pluginsSelected' ] +) => { + if ( pluginsSelected.includes( 'woocommerce-payments' ) ) { + return 'woocommerce-payments'; + } + return 'jetpack-ai'; +}; + const redirectToJetpackAuthPage = ( { event, + context, }: { context: CoreProfilerStateMachineContext; event: { output: { url: string } }; } ) => { const url = new URL( event.output.url ); url.searchParams.set( 'installed_ext_success', '1' ); - url.searchParams.set( 'plugin_name', 'jetpack-ai' ); + url.searchParams.set( + 'plugin_name', + getPluginNameParam( context.pluginsSelected ) + ); window.location.href = url.toString(); }; diff --git a/plugins/woocommerce/changelog/update-dynamically-set-plugin-name b/plugins/woocommerce/changelog/update-dynamically-set-plugin-name new file mode 100644 index 00000000000..079eb126b45 --- /dev/null +++ b/plugins/woocommerce/changelog/update-dynamically-set-plugin-name @@ -0,0 +1,4 @@ +Significance: patch +Type: update + +Dynamically set plugin_name when redirecting to Jetpack Auth from core profiler