2018-12-17 20:50:45 +00:00
/** @format */
/ * *
* External dependencies
* /
import { _ _ , _x } from '@wordpress/i18n' ;
2019-05-20 01:57:06 +00:00
import { applyFilters } from '@wordpress/hooks' ;
2018-12-17 20:50:45 +00:00
/ * *
* Internal dependencies
* /
2019-01-24 09:35:27 +00:00
import { getCustomerLabels , getProductLabels } from 'lib/async-requests' ;
2018-12-17 20:50:45 +00:00
2019-08-28 14:55:55 +00:00
const DOWLOADS _REPORT _CHARTS _FILTER = 'woocommerce_admin_downloads_report_charts' ;
2019-08-23 16:41:42 +00:00
const DOWLOADS _REPORT _FILTERS _FILTER = 'woocommerce_admin_downloads_report_filters' ;
const DOWLOADS _REPORT _ADVANCED _FILTERS _FILTER =
'woocommerce_admin_downloads_report_advanced_filters' ;
2019-05-20 01:57:06 +00:00
2019-08-28 14:55:55 +00:00
export const charts = applyFilters ( DOWLOADS _REPORT _CHARTS _FILTER , [
2018-12-19 11:18:43 +00:00
{
2019-01-07 11:54:42 +00:00
key : 'download_count' ,
2019-03-13 17:14:02 +00:00
label : _ _ ( 'Downloads' , 'woocommerce-admin' ) ,
2018-12-19 11:18:43 +00:00
type : 'number' ,
} ,
2019-05-20 01:57:06 +00:00
] ) ;
2018-12-19 11:18:43 +00:00
2019-08-23 16:41:42 +00:00
export const filters = applyFilters ( DOWLOADS _REPORT _FILTERS _FILTER , [
2018-12-17 20:50:45 +00:00
{
2019-03-13 17:14:02 +00:00
label : _ _ ( 'Show' , 'woocommerce-admin' ) ,
2018-12-17 20:50:45 +00:00
staticParams : [ ] ,
param : 'filter' ,
showFilters : ( ) => true ,
filters : [
2019-03-13 17:14:02 +00:00
{ label : _ _ ( 'All Downloads' , 'woocommerce-admin' ) , value : 'all' } ,
{ label : _ _ ( 'Advanced Filters' , 'woocommerce-admin' ) , value : 'advanced' } ,
2018-12-17 20:50:45 +00:00
] ,
} ,
2019-08-23 16:41:42 +00:00
] ) ;
2018-12-17 20:50:45 +00:00
/*eslint-disable max-len*/
2019-08-23 16:41:42 +00:00
export const advancedFilters = applyFilters ( DOWLOADS _REPORT _ADVANCED _FILTERS _FILTER , {
2018-12-17 20:50:45 +00:00
title : _x (
'Downloads Match {{select /}} Filters' ,
'A sentence describing filters for Downloads. See screen shot for context: https://cloudup.com/ccxhyH2mEDg' ,
2019-03-13 17:14:02 +00:00
'woocommerce-admin'
2018-12-17 20:50:45 +00:00
) ,
filters : {
product : {
labels : {
2019-03-13 17:14:02 +00:00
add : _ _ ( 'Product' , 'woocommerce-admin' ) ,
placeholder : _ _ ( 'Search' , 'woocommerce-admin' ) ,
remove : _ _ ( 'Remove product filter' , 'woocommerce-admin' ) ,
rule : _ _ ( 'Select a product filter match' , 'woocommerce-admin' ) ,
2018-12-17 20:50:45 +00:00
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
title : _ _ ( '{{title}}Product{{/title}} {{rule /}} {{filter /}}' , 'woocommerce-admin' ) ,
filter : _ _ ( 'Select product' , 'woocommerce-admin' ) ,
2018-12-17 20:50:45 +00:00
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to products including a given product(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
label : _x ( 'Includes' , 'products' , 'woocommerce-admin' ) ,
2018-12-17 20:50:45 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to products excluding a products(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
label : _x ( 'Excludes' , 'products' , 'woocommerce-admin' ) ,
2018-12-17 20:50:45 +00:00
} ,
] ,
input : {
component : 'Search' ,
type : 'products' ,
2019-01-24 09:35:27 +00:00
getLabels : getProductLabels ,
2018-12-17 20:50:45 +00:00
} ,
} ,
2019-02-19 19:35:29 +00:00
customer : {
2018-12-22 00:40:41 +00:00
labels : {
2019-03-13 17:14:02 +00:00
add : _ _ ( 'Username' , 'woocommerce-admin' ) ,
placeholder : _ _ ( 'Search customer username' , 'woocommerce-admin' ) ,
remove : _ _ ( 'Remove customer username filter' , 'woocommerce-admin' ) ,
rule : _ _ ( 'Select a customer username filter match' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
/* translators: A sentence describing a customer username filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
title : _ _ ( '{{title}}Username{{/title}} {{rule /}} {{filter /}}' , 'woocommerce-admin' ) ,
filter : _ _ ( 'Select customer username' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to customer usernames including a given username(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
label : _x ( 'Includes' , 'customer usernames' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to customer usernames excluding a given username(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
label : _x ( 'Excludes' , 'customer usernames' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
] ,
input : {
component : 'Search' ,
type : 'usernames' ,
2019-01-24 09:35:27 +00:00
getLabels : getCustomerLabels ,
2018-12-22 00:40:41 +00:00
} ,
} ,
order : {
labels : {
2019-03-13 17:14:02 +00:00
add : _ _ ( 'Order number' , 'woocommerce-admin' ) ,
placeholder : _ _ ( 'Search order number' , 'woocommerce-admin' ) ,
remove : _ _ ( 'Remove order number filter' , 'woocommerce-admin' ) ,
rule : _ _ ( 'Select a order number filter match' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
/* translators: A sentence describing a order number filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
title : _ _ ( '{{title}}Order number{{/title}} {{rule /}} {{filter /}}' , 'woocommerce-admin' ) ,
filter : _ _ ( 'Select order number' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to order numbers including a given order(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
label : _x ( 'Includes' , 'order numbers' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to order numbers excluding a given order(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
label : _x ( 'Excludes' , 'order numbers' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
] ,
input : {
component : 'Search' ,
type : 'orders' ,
2019-01-24 09:35:27 +00:00
getLabels : async value => {
const orderIds = value . split ( ',' ) ;
return await orderIds . map ( orderId => ( {
id : orderId ,
label : '#' + orderId ,
} ) ) ;
} ,
2018-12-22 00:40:41 +00:00
} ,
} ,
2019-01-08 16:51:19 +00:00
ip _address : {
2018-12-22 00:40:41 +00:00
labels : {
2019-03-13 17:14:02 +00:00
add : _ _ ( 'IP Address' , 'woocommerce-admin' ) ,
placeholder : _ _ ( 'Search IP address' , 'woocommerce-admin' ) ,
remove : _ _ ( 'Remove IP address filter' , 'woocommerce-admin' ) ,
rule : _ _ ( 'Select an IP address filter match' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
/* translators: A sentence describing a order number filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
title : _ _ ( '{{title}}IP Address{{/title}} {{rule /}} {{filter /}}' , 'woocommerce-admin' ) ,
filter : _ _ ( 'Select IP address' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to IP addresses including a given address(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
label : _x ( 'Includes' , 'IP addresses' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to IP addresses excluding a given address(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
2019-03-13 17:14:02 +00:00
label : _x ( 'Excludes' , 'IP addresses' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
] ,
input : {
component : 'Search' ,
type : 'downloadIps' ,
getLabels : async value => {
const ips = value . split ( ',' ) ;
return await ips . map ( ip => {
return {
id : ip ,
label : ip ,
} ;
} ) ;
} ,
} ,
} ,
2018-12-17 20:50:45 +00:00
} ,
2019-08-23 16:41:42 +00:00
} ) ;
2018-12-17 20:50:45 +00:00
/*eslint-enable max-len*/