Use downloadable prop in Products report table (https://github.com/woocommerce/woocommerce-admin/pull/668)

This commit is contained in:
Albert Juhé Lluveras 2018-10-24 16:25:53 +02:00 committed by GitHub
parent d770e9a7e0
commit 2cce4e90c5
1 changed files with 2 additions and 14 deletions

View File

@ -10,23 +10,11 @@ import { map, orderBy } from 'lodash';
* Internal dependencies
*/
import { Card, Link, TableCard, TablePlaceholder } from '@woocommerce/components';
import { downloadCSVFile, generateCSVDataFromTable, generateCSVFileName } from 'lib/csv';
import { formatCurrency, getCurrencyFormatDecimal } from 'lib/currency';
import { onQueryChange } from 'lib/nav-utils';
import ReportError from 'analytics/components/report-error';
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() {
return [
{
@ -167,7 +155,7 @@ export default class ProductsReportTable extends Component {
}
renderTable( tableQuery ) {
const { products, query, totalRows } = this.props;
const { products, totalRows } = this.props;
const rowsPerPage = parseInt( tableQuery.per_page ) || 25;
const orderedProducts = orderBy( products, tableQuery.orderby, tableQuery.order );
@ -189,10 +177,10 @@ export default class ProductsReportTable extends Component {
labels={ labels }
ids={ orderedProducts.map( p => p.product_id ) }
compareBy={ 'product' }
onClickDownload={ this.onDownload( headers, rows, query ) }
onQueryChange={ onQueryChange }
query={ tableQuery }
summary={ null } // @TODO
downloadable
/>
);
}