Use downloadable prop in Products report table (https://github.com/woocommerce/woocommerce-admin/pull/668)
This commit is contained in:
parent
d770e9a7e0
commit
2cce4e90c5
|
@ -10,23 +10,11 @@ import { map, orderBy } from 'lodash';
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import { Card, Link, TableCard, TablePlaceholder } from '@woocommerce/components';
|
import { Card, Link, TableCard, TablePlaceholder } from '@woocommerce/components';
|
||||||
import { downloadCSVFile, generateCSVDataFromTable, generateCSVFileName } from 'lib/csv';
|
|
||||||
import { formatCurrency, getCurrencyFormatDecimal } from 'lib/currency';
|
import { formatCurrency, getCurrencyFormatDecimal } from 'lib/currency';
|
||||||
import { onQueryChange } from 'lib/nav-utils';
|
import { onQueryChange } from 'lib/nav-utils';
|
||||||
import ReportError from 'analytics/components/report-error';
|
import ReportError from 'analytics/components/report-error';
|
||||||
|
|
||||||
export default class ProductsReportTable extends Component {
|
export default class ProductsReportTable extends Component {
|
||||||
onDownload( headers, rows, query ) {
|
|
||||||
// @TODO The current implementation only downloads the contents displayed in the table.
|
|
||||||
// Another solution is required when the data set is larger (see #311).
|
|
||||||
return () => {
|
|
||||||
downloadCSVFile(
|
|
||||||
generateCSVFileName( 'products', query ),
|
|
||||||
generateCSVDataFromTable( headers, rows )
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
getHeadersContent() {
|
getHeadersContent() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
@ -167,7 +155,7 @@ export default class ProductsReportTable extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderTable( tableQuery ) {
|
renderTable( tableQuery ) {
|
||||||
const { products, query, totalRows } = this.props;
|
const { products, totalRows } = this.props;
|
||||||
|
|
||||||
const rowsPerPage = parseInt( tableQuery.per_page ) || 25;
|
const rowsPerPage = parseInt( tableQuery.per_page ) || 25;
|
||||||
const orderedProducts = orderBy( products, tableQuery.orderby, tableQuery.order );
|
const orderedProducts = orderBy( products, tableQuery.orderby, tableQuery.order );
|
||||||
|
@ -189,10 +177,10 @@ export default class ProductsReportTable extends Component {
|
||||||
labels={ labels }
|
labels={ labels }
|
||||||
ids={ orderedProducts.map( p => p.product_id ) }
|
ids={ orderedProducts.map( p => p.product_id ) }
|
||||||
compareBy={ 'product' }
|
compareBy={ 'product' }
|
||||||
onClickDownload={ this.onDownload( headers, rows, query ) }
|
|
||||||
onQueryChange={ onQueryChange }
|
onQueryChange={ onQueryChange }
|
||||||
query={ tableQuery }
|
query={ tableQuery }
|
||||||
summary={ null } // @TODO
|
summary={ null } // @TODO
|
||||||
|
downloadable
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue