From 9794fed1398c0b8aae33535fd6e1dd15369b49ff Mon Sep 17 00:00:00 2001 From: Jeff Stieler Date: Thu, 18 Jun 2020 10:56:30 -0400 Subject: [PATCH] Disable task list on analytics dashboard when homepage is enabled. (https://github.com/woocommerce/woocommerce-admin/pull/4617) Regression from 8a2750c973c983af0c2bded58e5f4a42e18d9775. --- .../client/dashboard/customizable.js | 3 ++- .../src/Features/AnalyticsDashboard.php | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-admin/client/dashboard/customizable.js b/plugins/woocommerce-admin/client/dashboard/customizable.js index 30ababcaa14..1b7e941e603 100644 --- a/plugins/woocommerce-admin/client/dashboard/customizable.js +++ b/plugins/woocommerce-admin/client/dashboard/customizable.js @@ -73,6 +73,7 @@ const mergeSectionsWithDefaults = ( prefSections ) => { const CustomizableDashboard = ( { defaultDateRange, + homepageEnabled, path, query, taskListComplete, @@ -92,7 +93,7 @@ const CustomizableDashboard = ( { const sections = dashSections || defaultSections; - const isTaskListEnabled = isOnboardingEnabled() && ! taskListHidden; + const isTaskListEnabled = ! homepageEnabled && isOnboardingEnabled() && ! taskListHidden; const isDashboardShown = ! isTaskListEnabled || ( ! query.task && taskListComplete ); diff --git a/plugins/woocommerce-admin/src/Features/AnalyticsDashboard.php b/plugins/woocommerce-admin/src/Features/AnalyticsDashboard.php index e928ac61a79..6308b309ef5 100644 --- a/plugins/woocommerce-admin/src/Features/AnalyticsDashboard.php +++ b/plugins/woocommerce-admin/src/Features/AnalyticsDashboard.php @@ -45,6 +45,7 @@ class AnalyticsDashboard { add_action( 'admin_menu', array( $this, 'register_page' ) ); // priority is 20 to run after https://github.com/woocommerce/woocommerce/blob/a55ae325306fc2179149ba9b97e66f32f84fdd9c/includes/admin/class-wc-admin-menus.php#L165. add_action( 'admin_head', array( $this, 'update_link_structure' ), 20 ); + add_filter( 'woocommerce_admin_preload_options', array( $this, 'preload_options' ) ); } /** @@ -78,6 +79,18 @@ class AnalyticsDashboard { ); } + /** + * Preload options to prime state of the application. + * + * @param array $options Array of options to preload. + * @return array + */ + public function preload_options( $options ) { + $options[] = 'woocommerce_homescreen_enabled'; + + return $options; + } + /** * Registers dashboard page. */