From 96c633ed3258ba7eb61e8f80cdfa0ce0f61b2f64 Mon Sep 17 00:00:00 2001 From: Justin Shreve Date: Wed, 16 Oct 2019 16:53:45 -0400 Subject: [PATCH] Add a feature flag check before trying to use task list selectors in the dashboard. (https://github.com/woocommerce/woocommerce-admin/pull/3053) --- .../client/dashboard/customizable.js | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/plugins/woocommerce-admin/client/dashboard/customizable.js b/plugins/woocommerce-admin/client/dashboard/customizable.js index be3f527f201..a7f8627bf5d 100644 --- a/plugins/woocommerce-admin/client/dashboard/customizable.js +++ b/plugins/woocommerce-admin/client/dashboard/customizable.js @@ -246,30 +246,31 @@ export default compose( const { getCurrentUserData, getProfileItems, getOptions } = select( 'wc-api' ); const userData = getCurrentUserData(); - const profileItems = getProfileItems(); - const taskListHidden = - 'yes' === - get( - getOptions( [ 'woocommerce_task_list_hidden' ] ), - [ 'woocommerce_task_list_hidden' ], - 'no' - ); - - const tasks = getTasks( { - profileItems, - options: getOptions( [ 'woocommerce_onboarding_payments' ] ), - query: props.query, - } ); - - const visibleTasks = filter( tasks, task => task.visible ); - const completedTasks = filter( tasks, task => task.visible && task.completed ); - const taskListCompleted = visibleTasks.length === completedTasks.length; - - return { - taskListHidden, - taskListCompleted, + const withSelectData = { userPrefSections: userData.dashboard_sections, }; + + if ( window.wcAdminFeatures.onboarding ) { + const profileItems = getProfileItems(); + const tasks = getTasks( { + profileItems, + options: getOptions( [ 'woocommerce_onboarding_payments' ] ), + query: props.query, + } ); + const visibleTasks = filter( tasks, task => task.visible ); + const completedTasks = filter( tasks, task => task.visible && task.completed ); + + withSelectData.taskListCompleted = visibleTasks.length === completedTasks.length; + withSelectData.taskListHidden = + 'yes' === + get( + getOptions( [ 'woocommerce_task_list_hidden' ] ), + [ 'woocommerce_task_list_hidden' ], + 'no' + ); + } + + return withSelectData; } ), withDispatch( dispatch => { const { updateCurrentUserData } = dispatch( 'wc-api' );