From a7af5e46036150c5ee1292292690f3bcbda7343c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Fri, 22 Mar 2019 09:48:20 +0100 Subject: [PATCH] Create DEFAULT_ACTIONABLE_STATUSES constant (https://github.com/woocommerce/woocommerce-admin/pull/1867) --- .../client/analytics/settings/config.js | 7 ++++++- .../client/header/activity-panel/index.js | 7 +++---- .../client/header/activity-panel/panels/orders.js | 9 ++++----- plugins/woocommerce-admin/client/wc-api/constants.js | 2 ++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/plugins/woocommerce-admin/client/analytics/settings/config.js b/plugins/woocommerce-admin/client/analytics/settings/config.js index c3c2c5b2489..fa2c0a2e670 100644 --- a/plugins/woocommerce-admin/client/analytics/settings/config.js +++ b/plugins/woocommerce-admin/client/analytics/settings/config.js @@ -12,6 +12,11 @@ import interpolateComponents from 'interpolate-components'; */ import { Link } from '@woocommerce/components'; +/** + * Internal dependencies + */ +import { DEFAULT_ACTIONABLE_STATUSES } from 'wc-api/constants'; + const SETTINGS_FILTER = 'woocommerce_admin_analytics_settings'; const defaultOrderStatuses = [ @@ -122,6 +127,6 @@ export const analyticsSettings = applyFilters( SETTINGS_FILTER, [ 'woocommerce-admin' ), initialValue: wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses || [], - defaultValue: [ 'processing', 'on-hold' ], + defaultValue: DEFAULT_ACTIONABLE_STATUSES, }, ] ); diff --git a/plugins/woocommerce-admin/client/header/activity-panel/index.js b/plugins/woocommerce-admin/client/header/activity-panel/index.js index d2307adedd4..da053e303c8 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/index.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/index.js @@ -15,6 +15,7 @@ import { partial, uniqueId, find } from 'lodash'; */ import './style.scss'; import ActivityPanelToggleBubble from './toggle-bubble'; +import { DEFAULT_ACTIONABLE_STATUSES } from 'wc-api/constants'; import { H, Section } from '@woocommerce/components'; import InboxPanel from './panels/inbox'; import OrdersPanel from './panels/orders'; @@ -277,10 +278,8 @@ export default withSelect( select => { isGetReviewsRequesting, } = select( 'wc-api' ); const userData = getCurrentUserData(); - const orderStatuses = wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses || [ - 'processing', - 'on-hold', - ]; + const orderStatuses = + wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses || DEFAULT_ACTIONABLE_STATUSES; const notesQuery = { page: 1, diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js index 9746c32fa1d..74235793e85 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js @@ -32,7 +32,7 @@ import { getAdminLink, getNewPath } from '@woocommerce/navigation'; import { ActivityCard, ActivityCardPlaceholder } from '../activity-card'; import ActivityHeader from '../activity-header'; import ActivityOutboundLink from '../activity-outbound-link'; -import { QUERY_DEFAULTS } from 'wc-api/constants'; +import { DEFAULT_ACTIONABLE_STATUSES, QUERY_DEFAULTS } from 'wc-api/constants'; import withSelect from 'wc-api/with-select'; function OrdersPanel( { orders, isRequesting, isError, orderStatuses } ) { @@ -220,10 +220,9 @@ export default compose( withSelect( ( select, props ) => { const { getReportItems, getReportItemsError, isReportItemsRequesting } = select( 'wc-api' ); const { isEmpty } = props; - const orderStatuses = wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses || [ - 'processing', - 'on-hold', - ]; + const orderStatuses = + wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses || + DEFAULT_ACTIONABLE_STATUSES; if ( ! orderStatuses.length ) { return { orders: [], isError: true, isRequesting: false, orderStatuses }; diff --git a/plugins/woocommerce-admin/client/wc-api/constants.js b/plugins/woocommerce-admin/client/wc-api/constants.js index 37ca42d5bc4..34824e024ad 100644 --- a/plugins/woocommerce-admin/client/wc-api/constants.js +++ b/plugins/woocommerce-admin/client/wc-api/constants.js @@ -14,6 +14,8 @@ export const DEFAULT_REQUIREMENT = { // WordPress & WooCommerce both set a hard limit of 100 for the per_page parameter export const MAX_PER_PAGE = 100; +export const DEFAULT_ACTIONABLE_STATUSES = [ 'processing', 'on-hold' ]; + export const QUERY_DEFAULTS = { pageSize: 25, period: 'month',