From 5924be5fa29f853c1a3176882782cfb8f5e718dd Mon Sep 17 00:00:00 2001 From: Justin Shreve Date: Mon, 17 Dec 2018 15:50:45 -0500 Subject: [PATCH] Add base downloads report page (https://github.com/woocommerce/woocommerce-admin/pull/1106) --- .../analytics/report/customers/config.js | 8 ++- .../analytics/report/downloads/config.js | 67 +++++++++++++++++++ .../analytics/report/downloads/index.js | 38 +++++++++++ .../client/analytics/report/index.js | 6 ++ plugins/woocommerce-admin/lib/admin.php | 8 +++ 5 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 plugins/woocommerce-admin/client/analytics/report/downloads/config.js create mode 100644 plugins/woocommerce-admin/client/analytics/report/downloads/index.js diff --git a/plugins/woocommerce-admin/client/analytics/report/customers/config.js b/plugins/woocommerce-admin/client/analytics/report/customers/config.js index 3afba2bcd3c..157c45bde5f 100644 --- a/plugins/woocommerce-admin/client/analytics/report/customers/config.js +++ b/plugins/woocommerce-admin/client/analytics/report/customers/config.js @@ -4,8 +4,12 @@ */ import { __, _x } from '@wordpress/i18n'; 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 = [ { diff --git a/plugins/woocommerce-admin/client/analytics/report/downloads/config.js b/plugins/woocommerce-admin/client/analytics/report/downloads/config.js new file mode 100644 index 00000000000..fc0802ecbfe --- /dev/null +++ b/plugins/woocommerce-admin/client/analytics/report/downloads/config.js @@ -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*/ diff --git a/plugins/woocommerce-admin/client/analytics/report/downloads/index.js b/plugins/woocommerce-admin/client/analytics/report/downloads/index.js new file mode 100644 index 00000000000..8460f8452fd --- /dev/null +++ b/plugins/woocommerce-admin/client/analytics/report/downloads/index.js @@ -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 ( + + + + ); + } +} + +DownloadsReport.propTypes = { + query: PropTypes.object.isRequired, +}; diff --git a/plugins/woocommerce-admin/client/analytics/report/index.js b/plugins/woocommerce-admin/client/analytics/report/index.js index 6b06b987f5b..635b45c25bd 100644 --- a/plugins/woocommerce-admin/client/analytics/report/index.js +++ b/plugins/woocommerce-admin/client/analytics/report/index.js @@ -24,6 +24,7 @@ import RevenueReport from './revenue'; import CategoriesReport from './categories'; import CouponsReport from './coupons'; import TaxesReport from './taxes'; +import DownloadsReport from './downloads'; import StockReport from './stock'; import CustomersReport from './customers'; @@ -61,6 +62,11 @@ const getReports = () => { title: __( 'Taxes', 'wc-admin' ), component: TaxesReport, }, + { + report: 'downloads', + title: __( 'Downloads', 'wc-admin' ), + component: DownloadsReport, + }, { report: 'stock', title: __( 'Stock', 'wc-admin' ), diff --git a/plugins/woocommerce-admin/lib/admin.php b/plugins/woocommerce-admin/lib/admin.php index 86d281b18b0..2adbb706106 100644 --- a/plugins/woocommerce-admin/lib/admin.php +++ b/plugins/woocommerce-admin/lib/admin.php @@ -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( array( 'title' => __( 'Stock', 'wc-admin' ),