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
2022-02-11 14:38:38 +00:00
/ * *
* @ typedef { import ( '../index.js' ) . chart } chart
* /
/ * *
* Downloads Report charts filter .
*
* @ filter woocommerce _admin _downloads _report _charts
* @ param { Array . < chart > } charts Report charts .
* /
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' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Downloads' , 'woocommerce' ) ,
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
2022-02-11 14:38:38 +00:00
/ * *
* @ typedef { import ( '../index.js' ) . filter } filter
* /
/ * *
* Downloads Report Filters .
*
* @ filter woocommerce _admin _downloads _report _filters
* @ param { Array . < filter > } filters Report filters .
* /
2019-08-23 16:41:42 +00:00
export const filters = applyFilters ( DOWLOADS _REPORT _FILTERS _FILTER , [
2018-12-17 20:50:45 +00:00
{
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Show' , 'woocommerce' ) ,
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 : [
2022-03-30 09:00:04 +00:00
{ label : _ _ ( 'All downloads' , 'woocommerce' ) , value : 'all' } ,
2020-02-14 02:23:21 +00:00
{
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Advanced filters' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
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*/
2022-02-11 14:38:38 +00:00
/ * *
* Downloads Report Advanced Filters .
*
* @ filter woocommerce _admin _downloads _report _advanced _filters
2022-03-18 11:45:14 +00:00
* @ param { Object } advancedFilters Report Advanced Filters .
* @ param { string } advancedFilters . title Interpolated component string for Advanced Filters title .
2022-02-11 14:38:38 +00:00
* @ param { Object } advancedFilters . filters An object specifying a report ' s Advanced Filters .
* /
2020-02-14 02:23:21 +00:00
export const advancedFilters = applyFilters (
DOWLOADS _REPORT _ADVANCED _FILTERS _FILTER ,
{
title : _x (
2023-04-26 10:58:14 +00:00
'Downloads match <select/> filters' ,
2020-02-14 02:23:21 +00:00
'A sentence describing filters for Downloads. See screen shot for context: https://cloudup.com/ccxhyH2mEDg' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
filters : {
product : {
labels : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Product' , 'woocommerce' ) ,
placeholder : _ _ ( 'Search' , 'woocommerce' ) ,
remove : _ _ ( 'Remove product filter' , 'woocommerce' ) ,
rule : _ _ ( 'Select a product filter match' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title : _ _ (
2023-04-26 10:58:14 +00:00
'<title>Product</title> <rule/> <filter/>' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select product' , 'woocommerce' ) ,
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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Includes' , 'products' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to products excluding a products(s). Screenshot for context: https://cloudup.com/ccxhyH2mEDg */
2022-03-30 09:00:04 +00:00
label : _x ( 'Excludes' , 'products' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
] ,
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 : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Username' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
placeholder : _ _ (
'Search customer username' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
remove : _ _ (
'Remove customer username filter' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
rule : _ _ (
'Select a customer username filter match' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
/* translators: A sentence describing a customer username filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
title : _ _ (
2023-04-26 10:58:14 +00:00
'<title>Username</title> <rule/> <filter />' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select customer username' , 'woocommerce' ) ,
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' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +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 */
label : _x (
'Excludes' ,
'customer usernames' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
} ,
] ,
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 : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Order #' , 'woocommerce' ) ,
placeholder : _ _ ( 'Search order number' , 'woocommerce' ) ,
remove : _ _ ( 'Remove order number filter' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
rule : _ _ (
2024-08-23 17:26:09 +00:00
'Select an order number filter match' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2024-08-23 17:26:09 +00:00
/* translators: A sentence describing an order number filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
2020-02-14 02:23:21 +00:00
title : _ _ (
2023-04-26 10:58:14 +00:00
'<title>Order #</title> <rule/> <filter/>' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select order number' , 'woocommerce' ) ,
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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Includes' , 'order numbers' , 'woocommerce' ) ,
2020-02-14 02:23:21 +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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Excludes' , 'order numbers' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
] ,
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 : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'IP Address' , 'woocommerce' ) ,
placeholder : _ _ ( 'Search IP address' , 'woocommerce' ) ,
remove : _ _ ( 'Remove IP address filter' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
rule : _ _ (
'Select an IP address filter match' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2024-08-23 17:26:09 +00:00
/* translators: A sentence describing an order number filter. See screen shot for context: https://cloudup.com/ccxhyH2mEDg */
2020-02-14 02:23:21 +00:00
title : _ _ (
2023-04-26 10:58:14 +00:00
'<title>IP Address</title> <rule/> <filter/>' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select IP address' , 'woocommerce' ) ,
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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Includes' , 'IP addresses' , 'woocommerce' ) ,
2020-02-14 02:23:21 +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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Excludes' , 'IP addresses' , 'woocommerce' ) ,
2020-02-14 02:23:21 +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-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*/