From b9b4c82dca8ba81a81083201787511b068c2b47c Mon Sep 17 00:00:00 2001 From: Adrian Duffell <9312929+adrianduffell@users.noreply.github.com> Date: Tue, 30 Nov 2021 05:04:34 +0800 Subject: [PATCH] Make Homescreen Default to Single Column Layout (https://github.com/woocommerce/woocommerce-admin/pull/7969) * Add database migration deleting layout option * Remove calls to update the option * Remove unused variable * Add changelog * Remove unused var (lint failure) * Increase e2e test timeout to 1000 * Fix test: navigate to homescreen Co-authored-by: Moon --- .../woocommerce-admin/changelogs/fix-default-layout | 4 ++++ plugins/woocommerce-admin/client/tasks/tasks.tsx | 1 - .../client/tasks/test/tasks.test.tsx | 1 - .../client/two-column-tasks/index.js | 13 +------------ .../includes/wc-admin-update-functions.php | 7 +++++++ .../admin-e2e-tests/src/pages/PaymentsSetup.ts | 1 - .../admin-e2e-tests/src/specs/tasks/payment.ts | 3 +++ plugins/woocommerce-admin/src/Install.php | 1 + 8 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 plugins/woocommerce-admin/changelogs/fix-default-layout diff --git a/plugins/woocommerce-admin/changelogs/fix-default-layout b/plugins/woocommerce-admin/changelogs/fix-default-layout new file mode 100644 index 00000000000..f768a5b3a0a --- /dev/null +++ b/plugins/woocommerce-admin/changelogs/fix-default-layout @@ -0,0 +1,4 @@ +Significance: patch +Type: Fix + +Ensure homescreen defaults to single column layout. #7969 diff --git a/plugins/woocommerce-admin/client/tasks/tasks.tsx b/plugins/woocommerce-admin/client/tasks/tasks.tsx index ee0d4ac33ba..b804f9c15f1 100644 --- a/plugins/woocommerce-admin/client/tasks/tasks.tsx +++ b/plugins/woocommerce-admin/client/tasks/tasks.tsx @@ -76,7 +76,6 @@ export const Tasks: React.FC< TasksProps > = ( { query } ) => { const taskListsFinished = false; updateOptions( { woocommerce_task_list_prompt_shown: true, - woocommerce_default_homepage_layout: 'two_columns', } ); }, [ taskLists, isResolving ] ); diff --git a/plugins/woocommerce-admin/client/tasks/test/tasks.test.tsx b/plugins/woocommerce-admin/client/tasks/test/tasks.test.tsx index b8bb2fff034..16b9be2e942 100644 --- a/plugins/woocommerce-admin/client/tasks/test/tasks.test.tsx +++ b/plugins/woocommerce-admin/client/tasks/test/tasks.test.tsx @@ -147,7 +147,6 @@ describe( 'Task', () => { ); expect( updateOptions ).toHaveBeenCalledWith( { woocommerce_task_list_prompt_shown: true, - woocommerce_default_homepage_layout: 'two_columns', } ); } ); diff --git a/plugins/woocommerce-admin/client/two-column-tasks/index.js b/plugins/woocommerce-admin/client/two-column-tasks/index.js index c697a1b4e6e..81429136825 100644 --- a/plugins/woocommerce-admin/client/two-column-tasks/index.js +++ b/plugins/woocommerce-admin/client/two-column-tasks/index.js @@ -3,7 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { useEffect } from '@wordpress/element'; -import { useDispatch, useSelect } from '@wordpress/data'; +import { useSelect } from '@wordpress/data'; import { ONBOARDING_STORE_NAME, OPTIONS_STORE_NAME } from '@woocommerce/data'; /** @@ -30,7 +30,6 @@ const taskDashboardSelect = ( select ) => { }; const TaskDashboard = ( { query, twoColumns } ) => { - const { updateOptions } = useDispatch( OPTIONS_STORE_NAME ); const { keepCompletedTaskList, isResolving: isResolvingOptions, @@ -119,16 +118,6 @@ const TaskDashboard = ( { query, twoColumns } ) => { 'Get ready to start selling', 'woocommerce-admin' ) } - onComplete={ () => - updateOptions( { - woocommerce_default_homepage_layout: 'two_columns', - } ) - } - onHide={ () => - updateOptions( { - woocommerce_default_homepage_layout: 'two_columns', - } ) - } /> ) } diff --git a/plugins/woocommerce-admin/includes/wc-admin-update-functions.php b/plugins/woocommerce-admin/includes/wc-admin-update-functions.php index e1ca6d9264e..7fce718cc9b 100644 --- a/plugins/woocommerce-admin/includes/wc-admin-update-functions.php +++ b/plugins/woocommerce-admin/includes/wc-admin-update-functions.php @@ -310,6 +310,13 @@ function wc_admin_update_290_update_apperance_task_option() { delete_option( 'woocommerce_task_list_appearance_complete' ); } +/** + * Delete the old woocommerce_default_homepage_layout option. + */ +function wc_admin_update_290_delete_default_homepage_layout_option() { + delete_option( 'woocommerce_default_homepage_layout' ); +} + /** * Update DB Version. */ diff --git a/plugins/woocommerce-admin/packages/admin-e2e-tests/src/pages/PaymentsSetup.ts b/plugins/woocommerce-admin/packages/admin-e2e-tests/src/pages/PaymentsSetup.ts index 53e4e43914a..3bc8ec8ad5d 100644 --- a/plugins/woocommerce-admin/packages/admin-e2e-tests/src/pages/PaymentsSetup.ts +++ b/plugins/woocommerce-admin/packages/admin-e2e-tests/src/pages/PaymentsSetup.ts @@ -54,6 +54,5 @@ export class PaymentsSetup extends BasePage { async enableCashOnDelivery() { await this.page.waitForSelector( '.woocommerce-task-payment-cod' ); await this.clickButtonWithText( 'Enable' ); - await waitForTimeout( 500 ); } } diff --git a/plugins/woocommerce-admin/packages/admin-e2e-tests/src/specs/tasks/payment.ts b/plugins/woocommerce-admin/packages/admin-e2e-tests/src/specs/tasks/payment.ts index 5ee1fc2d16c..0515dce47f3 100644 --- a/plugins/woocommerce-admin/packages/admin-e2e-tests/src/specs/tasks/payment.ts +++ b/plugins/woocommerce-admin/packages/admin-e2e-tests/src/specs/tasks/payment.ts @@ -77,6 +77,9 @@ const testAdminPaymentSetupTask = () => { await waitForTimeout( 1000 ); await homeScreen.clickOnTaskList( 'Set up payments' ); await paymentsSetup.enableCashOnDelivery(); + await homeScreen.navigate(); + await homeScreen.isDisplayed(); + await waitForTimeout( 1000 ); await homeScreen.clickOnTaskList( 'Set up payments' ); await paymentsSetup.isDisplayed(); await paymentsSetup.methodHasBeenSetup( 'cod' ); diff --git a/plugins/woocommerce-admin/src/Install.php b/plugins/woocommerce-admin/src/Install.php index 05a6c811497..5bcad7bd2ee 100644 --- a/plugins/woocommerce-admin/src/Install.php +++ b/plugins/woocommerce-admin/src/Install.php @@ -71,6 +71,7 @@ class Install { ), '2.9.0' => array( 'wc_admin_update_290_update_apperance_task_option', + 'wc_admin_update_290_delete_default_homepage_layout_option', 'wc_admin_update_290_db_version', ), '3.0.0' => array(