Add a feature flag check before trying to use task list selectors in the dashboard. (https://github.com/woocommerce/woocommerce-admin/pull/3053)

This commit is contained in:
Justin Shreve 2019-10-16 16:53:45 -04:00 committed by GitHub
parent 9a20b0289e
commit 96c633ed32
1 changed files with 23 additions and 22 deletions

View File

@ -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' );