From b885ae4157451ae3d75cc29dca021c3ae50eb665 Mon Sep 17 00:00:00 2001 From: Joshua T Flowers Date: Wed, 3 Apr 2019 09:36:20 +0800 Subject: [PATCH] Update default hidden dashboard items (https://github.com/woocommerce/woocommerce-admin/pull/1973) --- .../dashboard/dashboard-charts/index.js | 15 ++++++- .../client/dashboard/leaderboards/index.js | 2 +- .../dashboard/store-performance/index.js | 40 ++++++++++++------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/plugins/woocommerce-admin/client/dashboard/dashboard-charts/index.js b/plugins/woocommerce-admin/client/dashboard/dashboard-charts/index.js index 28dc115cfdf..a8193632856 100644 --- a/plugins/woocommerce-admin/client/dashboard/dashboard-charts/index.js +++ b/plugins/woocommerce-admin/client/dashboard/dashboard-charts/index.js @@ -31,7 +31,20 @@ class DashboardCharts extends Component { super( ...arguments ); this.state = { chartType: props.userPrefChartType || 'line', - hiddenChartKeys: props.userPrefCharts || [], + hiddenChartKeys: props.userPrefCharts || [ + 'avg_order_value', + 'avg_items_per_order', + 'items_sold', + 'gross_revenue', + 'refunds', + 'coupons', + 'taxes', + 'shipping', + 'amount', + 'total_tax', + 'order_tax', + 'shipping_tax', + ], interval: props.userPrefIntervals || 'day', }; diff --git a/plugins/woocommerce-admin/client/dashboard/leaderboards/index.js b/plugins/woocommerce-admin/client/dashboard/leaderboards/index.js index 5e3a05cdc7f..11d2de0588c 100644 --- a/plugins/woocommerce-admin/client/dashboard/leaderboards/index.js +++ b/plugins/woocommerce-admin/client/dashboard/leaderboards/index.js @@ -29,7 +29,7 @@ class Leaderboards extends Component { constructor( props ) { super( ...arguments ); this.state = { - hiddenLeaderboardKeys: props.userPrefLeaderboards || [], + hiddenLeaderboardKeys: props.userPrefLeaderboards || [ 'top-coupons', 'top-customers' ], rowsPerTable: parseInt( props.userPrefLeaderboardRows ) || 5, }; diff --git a/plugins/woocommerce-admin/client/dashboard/store-performance/index.js b/plugins/woocommerce-admin/client/dashboard/store-performance/index.js index b0c0b0ce221..239c786c353 100644 --- a/plugins/woocommerce-admin/client/dashboard/store-performance/index.js +++ b/plugins/woocommerce-admin/client/dashboard/store-performance/index.js @@ -36,7 +36,7 @@ class StorePerformance extends Component { constructor( props ) { super( props ); this.state = { - userPrefs: props.userPrefs || [], + hiddenIndicators: props.hiddenIndicators || [], }; this.toggle = this.toggle.bind( this ); } @@ -44,19 +44,19 @@ class StorePerformance extends Component { toggle( statKey ) { return () => { this.setState( state => { - const prefs = [ ...state.userPrefs ]; - let newPrefs = []; - if ( ! prefs.includes( statKey ) ) { - prefs.push( statKey ); - newPrefs = prefs; + const indicators = [ ...state.hiddenIndicators ]; + let newHiddenIndicators = []; + if ( ! indicators.includes( statKey ) ) { + indicators.push( statKey ); + newHiddenIndicators = indicators; } else { - newPrefs = prefs.filter( pref => pref !== statKey ); + newHiddenIndicators = indicators.filter( indicator => indicator !== statKey ); } this.props.updateCurrentUserData( { - dashboard_performance_indicators: newPrefs, + dashboard_performance_indicators: newHiddenIndicators, } ); return { - userPrefs: newPrefs, + hiddenIndicators: newHiddenIndicators, }; } ); }; @@ -68,7 +68,7 @@ class StorePerformance extends Component { { __( 'Display Stats:', 'woocommerce-admin' ) } { indicators.map( ( indicator, i ) => { - const checked = ! this.state.userPrefs.includes( indicator.stat ); + const checked = ! this.state.hiddenIndicators.includes( indicator.stat ); return (