This commit is contained in:
Justin Shreve 2018-12-17 15:50:45 -05:00 committed by GitHub
parent e42ad6956b
commit 5924be5fa2
5 changed files with 125 additions and 2 deletions

View File

@ -4,8 +4,12 @@
*/ */
import { __, _x } from '@wordpress/i18n'; import { __, _x } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities'; import { decodeEntities } from '@wordpress/html-entities';
import { getRequestByIdString } from '../../../lib/async-requests';
import { NAMESPACE } from '../../../store/constants'; /**
* Internal dependencies
*/
import { getRequestByIdString } from 'lib/async-requests';
import { NAMESPACE } from 'store/constants';
export const filters = [ export const filters = [
{ {

View File

@ -0,0 +1,67 @@
/** @format */
/**
* External dependencies
*/
import { __, _x } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { getRequestByIdString } from 'lib/async-requests';
import { NAMESPACE } from 'store/constants';
export const filters = [
{
label: __( 'Show', 'wc-admin' ),
staticParams: [],
param: 'filter',
showFilters: () => true,
filters: [
{ label: __( 'All Downloads', 'wc-admin' ), value: 'all' },
{ label: __( 'Advanced Filters', 'wc-admin' ), value: 'advanced' },
],
},
];
/*eslint-disable max-len*/
export const advancedFilters = {
title: _x(
'Downloads Match {{select /}} Filters',
'A sentence describing filters for Downloads. See screen shot for context: https://cloudup.com/ccxhyH2mEDg',
'wc-admin'
),
filters: {
product: {
labels: {
add: __( 'Product', 'wc-admin' ),
placeholder: __( 'Search', 'wc-admin' ),
remove: __( 'Remove product filter', 'wc-admin' ),
rule: __( 'Select a product filter match', 'wc-admin' ),
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title: __( 'Product {{rule /}} {{filter /}}', 'wc-admin' ),
filter: __( 'Select product', 'wc-admin' ),
},
rules: [
{
value: 'includes',
/* translators: Sentence fragment, logical, "Includes" refers to products including a given product(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label: _x( 'Includes', 'products', 'wc-admin' ),
},
{
value: 'excludes',
/* translators: Sentence fragment, logical, "Excludes" refers to products excluding a products(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label: _x( 'Excludes', 'products', 'wc-admin' ),
},
],
input: {
component: 'Search',
type: 'products',
getLabels: getRequestByIdString( NAMESPACE + 'products', product => ( {
id: product.id,
label: product.name,
} ) ),
},
},
},
};
/*eslint-enable max-len*/

View File

@ -0,0 +1,38 @@
/** @format */
/**
* External dependencies
*/
import { Component, Fragment } from '@wordpress/element';
import PropTypes from 'prop-types';
/**
* WooCommerce dependencies
*/
import { ReportFilters } from '@woocommerce/components';
/**
* Internal dependencies
*/
import { filters, advancedFilters } from './config';
export default class DownloadsReport extends Component {
render() {
const { query, path } = this.props;
return (
<Fragment>
<ReportFilters
query={ query }
path={ path }
filters={ filters }
showDatePicker={ false }
advancedFilters={ advancedFilters }
/>
</Fragment>
);
}
}
DownloadsReport.propTypes = {
query: PropTypes.object.isRequired,
};

View File

@ -24,6 +24,7 @@ import RevenueReport from './revenue';
import CategoriesReport from './categories'; import CategoriesReport from './categories';
import CouponsReport from './coupons'; import CouponsReport from './coupons';
import TaxesReport from './taxes'; import TaxesReport from './taxes';
import DownloadsReport from './downloads';
import StockReport from './stock'; import StockReport from './stock';
import CustomersReport from './customers'; import CustomersReport from './customers';
@ -61,6 +62,11 @@ const getReports = () => {
title: __( 'Taxes', 'wc-admin' ), title: __( 'Taxes', 'wc-admin' ),
component: TaxesReport, component: TaxesReport,
}, },
{
report: 'downloads',
title: __( 'Downloads', 'wc-admin' ),
component: DownloadsReport,
},
{ {
report: 'stock', report: 'stock',
title: __( 'Stock', 'wc-admin' ), title: __( 'Stock', 'wc-admin' ),

View File

@ -133,6 +133,14 @@ function wc_admin_register_pages() {
) )
); );
wc_admin_register_page(
array(
'title' => __( 'Downloads', 'wc-admin' ),
'parent' => '/analytics/revenue',
'path' => '/analytics/downloads',
)
);
wc_admin_register_page( wc_admin_register_page(
array( array(
'title' => __( 'Stock', 'wc-admin' ), 'title' => __( 'Stock', 'wc-admin' ),