2018-12-17 20:50:45 +00:00
/ * *
* 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
* /
2020-08-13 02:05:22 +00:00
import {
getCustomerLabels ,
getProductLabels ,
} from '../../../lib/async-requests' ;
2018-12-17 20:50:45 +00:00
2020-02-14 02:23:21 +00:00
const DOWLOADS _REPORT _CHARTS _FILTER =
'woocommerce_admin_downloads_report_charts' ;
const DOWLOADS _REPORT _FILTERS _FILTER =
'woocommerce_admin_downloads_report_filters' ;
2019-08-23 16:41:42 +00:00
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' ) ,
2020-07-08 00:38:50 +00:00
staticParams : [ 'chartType' , 'paged' , 'per_page' ] ,
2018-12-17 20:50:45 +00:00
param : 'filter' ,
showFilters : ( ) => true ,
filters : [
2019-03-13 17:14:02 +00:00
{ label : _ _ ( 'All Downloads' , 'woocommerce-admin' ) , value : 'all' } ,
2020-02-14 02:23:21 +00:00
{
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*/
2020-02-14 02:23:21 +00:00
export const advancedFilters = applyFilters (
DOWLOADS _REPORT _ADVANCED _FILTERS _FILTER ,
{
title : _x (
'Downloads Match {{select /}} Filters' ,
'A sentence describing filters for Downloads. See screen shot for context: https://cloudup.com/ccxhyH2mEDg' ,
'woocommerce-admin'
) ,
filters : {
product : {
labels : {
add : _ _ ( 'Product' , 'woocommerce-admin' ) ,
placeholder : _ _ ( 'Search' , 'woocommerce-admin' ) ,
remove : _ _ ( 'Remove product filter' , 'woocommerce-admin' ) ,
rule : _ _ (
'Select a product filter match' ,
'woocommerce-admin'
) ,
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title : _ _ (
'{{title}}Product{{/title}} {{rule /}} {{filter /}}' ,
'woocommerce-admin'
) ,
filter : _ _ ( 'Select product' , 'woocommerce-admin' ) ,
2018-12-17 20:50:45 +00:00
} ,
2020-02-14 02:23:21 +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 */
label : _x (
'Includes' ,
'products' ,
'woocommerce-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' ,
'woocommerce-admin'
) ,
} ,
] ,
input : {
component : 'Search' ,
type : 'products' ,
getLabels : getProductLabels ,
2018-12-17 20:50:45 +00:00
} ,
} ,
2020-02-14 02:23:21 +00:00
customer : {
labels : {
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'
) ,
/* translators: A sentence describing a customer username filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title : _ _ (
'{{title}}Username{{/title}} {{rule /}} {{filter /}}' ,
'woocommerce-admin'
) ,
filter : _ _ (
'Select customer username' ,
'woocommerce-admin'
) ,
2018-12-22 00:40:41 +00:00
} ,
2020-02-14 02:23:21 +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 */
label : _x (
'Includes' ,
'customer usernames' ,
'woocommerce-admin'
) ,
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to customer usernames excluding a given username(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label : _x (
'Excludes' ,
'customer usernames' ,
'woocommerce-admin'
) ,
} ,
] ,
input : {
component : 'Search' ,
type : 'usernames' ,
getLabels : getCustomerLabels ,
2018-12-22 00:40:41 +00:00
} ,
} ,
2020-02-14 02:23:21 +00:00
order : {
labels : {
2020-03-10 08:53:01 +00:00
add : _ _ ( 'Order #' , 'woocommerce-admin' ) ,
2020-02-14 02:23:21 +00:00
placeholder : _ _ (
'Search order number' ,
'woocommerce-admin'
) ,
remove : _ _ (
'Remove order number filter' ,
'woocommerce-admin'
) ,
rule : _ _ (
'Select a order number filter match' ,
'woocommerce-admin'
) ,
/* translators: A sentence describing a order number filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title : _ _ (
2020-03-10 08:53:01 +00:00
'{{title}}Order #{{/title}} {{rule /}} {{filter /}}' ,
2020-02-14 02:23:21 +00:00
'woocommerce-admin'
) ,
filter : _ _ ( 'Select order number' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
2020-02-14 02:23:21 +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 */
label : _x (
'Includes' ,
'order numbers' ,
'woocommerce-admin'
) ,
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to order numbers excluding a given order(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label : _x (
'Excludes' ,
'order numbers' ,
'woocommerce-admin'
) ,
} ,
] ,
input : {
component : 'Search' ,
type : 'orders' ,
getLabels : async ( value ) => {
const orderIds = value . split ( ',' ) ;
return await orderIds . map ( ( orderId ) => ( {
id : orderId ,
label : '#' + orderId ,
} ) ) ;
} ,
2019-01-24 09:35:27 +00:00
} ,
2018-12-22 00:40:41 +00:00
} ,
2020-02-14 02:23:21 +00:00
ip _address : {
labels : {
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'
) ,
/* translators: A sentence describing a order number filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title : _ _ (
'{{title}}IP Address{{/title}} {{rule /}} {{filter /}}' ,
'woocommerce-admin'
) ,
filter : _ _ ( 'Select IP address' , 'woocommerce-admin' ) ,
2018-12-22 00:40:41 +00:00
} ,
2020-02-14 02:23:21 +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 */
label : _x (
'Includes' ,
'IP addresses' ,
'woocommerce-admin'
) ,
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to IP addresses excluding a given address(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
label : _x (
'Excludes' ,
'IP addresses' ,
'woocommerce-admin'
) ,
} ,
] ,
input : {
component : 'Search' ,
type : 'downloadIps' ,
getLabels : async ( value ) => {
const ips = value . split ( ',' ) ;
return await ips . map ( ( ip ) => {
return {
id : ip ,
label : ip ,
} ;
} ) ;
} ,
2018-12-22 00:40:41 +00:00
} ,
} ,
} ,
2020-02-14 02:23:21 +00:00
}
) ;
2018-12-17 20:50:45 +00:00
/*eslint-enable max-len*/