Make analytics tables use the site's date format setting (https://github.com/woocommerce/woocommerce-admin/pull/3715)
* Make analytics tables use the site's date format setting * Use getSetting instead of the wcSettings global * Use configured date format in coupons analytics table * Use default date format as fallback in analytics * Rename downloads table class name
This commit is contained in:
parent
43274b9fa8
commit
2a7e4f0c97
|
@ -13,6 +13,7 @@ import { defaultTableDateFormat } from 'lib/date';
|
|||
import { formatCurrency, getCurrencyFormatDecimal } from 'lib/currency-format';
|
||||
import { getNewPath, getPersistedQuery } from '@woocommerce/navigation';
|
||||
import { formatValue } from 'lib/number-format';
|
||||
import { getSetting } from '@woocommerce/wc-admin-settings';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -69,6 +70,7 @@ export default class CouponsReportTable extends Component {
|
|||
getRowsContent( coupons ) {
|
||||
const { query } = this.props;
|
||||
const persistedQuery = getPersistedQuery( query );
|
||||
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
|
||||
|
||||
return map( coupons, ( coupon ) => {
|
||||
const { amount, coupon_id: couponId, orders_count: ordersCount } = coupon;
|
||||
|
@ -121,7 +123,7 @@ export default class CouponsReportTable extends Component {
|
|||
display: (
|
||||
<Date
|
||||
date={ dateCreated }
|
||||
visibleFormat={ defaultTableDateFormat }
|
||||
visibleFormat={ dateFormat }
|
||||
/>
|
||||
),
|
||||
value: dateCreated,
|
||||
|
@ -130,7 +132,7 @@ export default class CouponsReportTable extends Component {
|
|||
display: dateExpires ? (
|
||||
<Date
|
||||
date={ dateExpires }
|
||||
visibleFormat={ defaultTableDateFormat }
|
||||
visibleFormat={ dateFormat }
|
||||
/>
|
||||
) : (
|
||||
__( 'N/A', 'woocommerce-admin' )
|
||||
|
|
|
@ -8,11 +8,11 @@ import { Tooltip } from '@wordpress/components';
|
|||
/**
|
||||
* WooCommerce dependencies
|
||||
*/
|
||||
import { defaultTableDateFormat } from 'lib/date';
|
||||
import { formatCurrency, getCurrencyFormatDecimal } from 'lib/currency-format';
|
||||
import { Date, Link } from '@woocommerce/components';
|
||||
import { formatValue } from 'lib/number-format';
|
||||
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
|
||||
import { defaultTableDateFormat } from 'lib/date';
|
||||
|
||||
const { countries } = getSetting( 'dataEndpoints', { countries: {} } );
|
||||
|
||||
|
@ -113,6 +113,8 @@ export default class CustomersReportTable extends Component {
|
|||
}
|
||||
|
||||
getRowsContent( customers ) {
|
||||
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
|
||||
|
||||
return customers.map( ( customer ) => {
|
||||
const {
|
||||
avg_order_value: avgOrderValue,
|
||||
|
@ -145,7 +147,7 @@ export default class CustomersReportTable extends Component {
|
|||
const dateLastActiveDisplay = dateLastActive ? (
|
||||
<Date
|
||||
date={ dateLastActive }
|
||||
visibleFormat={ defaultTableDateFormat }
|
||||
visibleFormat={ dateFormat }
|
||||
/>
|
||||
) : (
|
||||
'—'
|
||||
|
@ -154,7 +156,7 @@ export default class CustomersReportTable extends Component {
|
|||
const dateRegisteredDisplay = dateRegistered ? (
|
||||
<Date
|
||||
date={ dateRegistered }
|
||||
visibleFormat={ defaultTableDateFormat }
|
||||
visibleFormat={ dateFormat }
|
||||
/>
|
||||
) : (
|
||||
'—'
|
||||
|
|
|
@ -9,18 +9,18 @@ import moment from 'moment';
|
|||
/**
|
||||
* WooCommerce dependencies
|
||||
*/
|
||||
import { defaultTableDateFormat, getCurrentDates } from 'lib/date';
|
||||
import { getCurrentDates, defaultTableDateFormat } from 'lib/date';
|
||||
import { Date, Link } from '@woocommerce/components';
|
||||
import { getNewPath, getPersistedQuery } from '@woocommerce/navigation';
|
||||
import { formatValue } from 'lib/number-format';
|
||||
import { getAdminLink } from '@woocommerce/wc-admin-settings';
|
||||
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import ReportTable from 'analytics/components/report-table';
|
||||
|
||||
export default class CouponsReportTable extends Component {
|
||||
export default class DownloadsReportTable extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
@ -68,6 +68,7 @@ export default class CouponsReportTable extends Component {
|
|||
getRowsContent( downloads ) {
|
||||
const { query } = this.props;
|
||||
const persistedQuery = getPersistedQuery( query );
|
||||
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
|
||||
|
||||
return map( downloads, ( download ) => {
|
||||
const {
|
||||
|
@ -97,7 +98,7 @@ export default class CouponsReportTable extends Component {
|
|||
display: (
|
||||
<Date
|
||||
date={ date }
|
||||
visibleFormat={ defaultTableDateFormat }
|
||||
visibleFormat={ dateFormat }
|
||||
/>
|
||||
),
|
||||
value: date,
|
||||
|
|
|
@ -9,10 +9,10 @@ import { map } from 'lodash';
|
|||
* WooCommerce dependencies
|
||||
*/
|
||||
import { Date, Link, OrderStatus, ViewMoreList } from '@woocommerce/components';
|
||||
import { defaultTableDateFormat } from 'lib/date';
|
||||
import { formatCurrency, renderCurrency } from 'lib/currency-format';
|
||||
import { formatValue } from 'lib/number-format';
|
||||
import { getSetting } from '@woocommerce/wc-admin-settings';
|
||||
import { defaultTableDateFormat } from 'lib/date';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -104,6 +104,8 @@ export default class OrdersReportTable extends Component {
|
|||
getRowsContent( tableData ) {
|
||||
const { query } = this.props;
|
||||
const persistedQuery = getPersistedQuery( query );
|
||||
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
|
||||
|
||||
return map( tableData, ( row ) => {
|
||||
const {
|
||||
currency,
|
||||
|
@ -143,7 +145,7 @@ export default class OrdersReportTable extends Component {
|
|||
display: (
|
||||
<Date
|
||||
date={ dateCreated }
|
||||
visibleFormat={ defaultTableDateFormat }
|
||||
visibleFormat={ dateFormat }
|
||||
/>
|
||||
),
|
||||
value: dateCreated,
|
||||
|
|
|
@ -22,6 +22,7 @@ import {
|
|||
renderCurrency,
|
||||
} from 'lib/currency-format';
|
||||
import { formatValue } from 'lib/number-format';
|
||||
import { getSetting } from '@woocommerce/wc-admin-settings';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -110,6 +111,8 @@ class RevenueReportTable extends Component {
|
|||
}
|
||||
|
||||
getRowsContent( data = [] ) {
|
||||
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
|
||||
|
||||
return data.map( ( row ) => {
|
||||
const {
|
||||
coupons,
|
||||
|
@ -140,7 +143,7 @@ class RevenueReportTable extends Component {
|
|||
display: (
|
||||
<Date
|
||||
date={ row.date_start }
|
||||
visibleFormat={ defaultTableDateFormat }
|
||||
visibleFormat={ dateFormat }
|
||||
/>
|
||||
),
|
||||
value: row.date_start,
|
||||
|
|
|
@ -690,6 +690,7 @@ class Loader {
|
|||
$settings['wcVersion'] = WC_VERSION;
|
||||
$settings['siteUrl'] = site_url();
|
||||
$settings['onboardingEnabled'] = self::is_onboarding_enabled();
|
||||
$settings['dateFormat'] = get_option( 'date_format' );
|
||||
|
||||
if ( ! empty( $preload_data_endpoints ) ) {
|
||||
$settings['dataEndpoints'] = isset( $settings['dataEndpoints'] )
|
||||
|
|
Loading…
Reference in New Issue