From 289636abba4f71b80348fff3cda1009b89ac4c56 Mon Sep 17 00:00:00 2001 From: Fernando Date: Wed, 10 Jun 2020 10:33:30 -0300 Subject: [PATCH] Modified layout.js withSelect (https://github.com/woocommerce/woocommerce-admin/pull/4480) * Changed some API responses This commit adds changes to some API responses * Changed "woocommerce_task_list_complete" loading in frontend * Updated "$migrated_options" array This commit updates "$migrated_options" array and adds a deletion control * Changed "taskListComplete" in customizable.js Co-authored-by: Fernando Marichal --- .../client/dashboard/customizable.js | 8 +++----- .../woocommerce-admin/client/homepage/layout.js | 6 +++--- .../woocommerce-admin/client/task-list/index.js | 4 ++-- plugins/woocommerce-admin/src/Install.php | 14 ++++++++++++-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/plugins/woocommerce-admin/client/dashboard/customizable.js b/plugins/woocommerce-admin/client/dashboard/customizable.js index a4329f9a60d..9a6daea2a9a 100644 --- a/plugins/woocommerce-admin/client/dashboard/customizable.js +++ b/plugins/woocommerce-admin/client/dashboard/customizable.js @@ -347,11 +347,9 @@ export default compose( withSelectData.taskListHidden = get( options, [ 'woocommerce_task_list_hidden' ], 'no' ) === 'yes'; - withSelectData.taskListComplete = get( - options, - [ 'woocommerce_task_list_complete' ], - false - ); + withSelectData.taskListComplete = + get( options, [ 'woocommerce_task_list_complete' ], 'no' ) === + 'yes'; } return withSelectData; diff --git a/plugins/woocommerce-admin/client/homepage/layout.js b/plugins/woocommerce-admin/client/homepage/layout.js index 4a865b6b4ce..fce4e79463c 100644 --- a/plugins/woocommerce-admin/client/homepage/layout.js +++ b/plugins/woocommerce-admin/client/homepage/layout.js @@ -158,9 +158,9 @@ export default compose( 'woocommerce_task_list_complete', 'woocommerce_task_list_hidden', ] ), - taskListComplete: get( options, [ - 'woocommerce_task_list_complete', - ] ), + taskListComplete: + get( options, [ 'woocommerce_task_list_complete' ] ) === + 'yes', taskListHidden: get( options, [ 'woocommerce_task_list_hidden' ] ) === 'yes', diff --git a/plugins/woocommerce-admin/client/task-list/index.js b/plugins/woocommerce-admin/client/task-list/index.js index 0394f40342a..2777d8c6826 100644 --- a/plugins/woocommerce-admin/client/task-list/index.js +++ b/plugins/woocommerce-admin/client/task-list/index.js @@ -51,7 +51,7 @@ class TaskDashboard extends Component { if ( ! incompleteTasks.length ) { updateOptions( { - woocommerce_task_list_complete: true, + woocommerce_task_list_complete: 'yes', } ); } @@ -80,7 +80,7 @@ class TaskDashboard extends Component { if ( ! incompleteTasks.length && prevIncompleteTasks.length ) { updateOptions( { - woocommerce_task_list_complete: true, + woocommerce_task_list_complete: 'yes', } ); } diff --git a/plugins/woocommerce-admin/src/Install.php b/plugins/woocommerce-admin/src/Install.php index 3ef6497814a..466c1df1e02 100644 --- a/plugins/woocommerce-admin/src/Install.php +++ b/plugins/woocommerce-admin/src/Install.php @@ -40,7 +40,7 @@ class Install { 'wc_admin_update_0251_remove_unsnooze_action', 'wc_admin_update_0251_db_version', ), - '1.1.0' => array( + '1.1.0' => array( 'wc_admin_update_110_remove_facebook_note', 'wc_admin_update_110_db_version', ), @@ -60,6 +60,8 @@ class Install { 'woocommerce_admin_last_orders_milestone' => 'wc_admin_last_orders_milestone', 'woocommerce_admin-wc-helper-last-refresh' => 'wc-admin-wc-helper-last-refresh', 'woocommerce_admin_report_export_status' => 'wc_admin_report_export_status', + 'woocommerce_task_list_complete' => 'woocommerce_task_list_complete', + 'woocommerce_task_list_hidden' => 'woocommerce_task_list_hidden', ); /** @@ -87,8 +89,16 @@ class Install { continue; } + if ( '1' === $old_option_value ) { + $old_option_value = 'yes'; + } elseif ( '0' === $old_option_value ) { + $old_option_value = 'no'; + } + update_option( $new_option, $old_option_value ); - delete_option( $old_option ); + if ( $new_option !== $old_option ) { + delete_option( $old_option ); + } } }