-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove browser based CSV export, default to async server-side export #9986
base: develop
Are you sure you want to change the base?
Changes from 10 commits
30ad58b
9f7787b
829aa3e
6f75ab6
0c8a7a4
5e9916f
fc798ce
3b0a867
1f054fd
248f47e
f974606
0ba8731
87ad001
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: update | ||
|
||
Remove browser based CSV export, use async CSV export for Disputes, DPayouts and Transactions. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,6 @@ import { __, _n, sprintf } from '@wordpress/i18n'; | |
import moment from 'moment'; | ||
import { TableCard, Link } from '@woocommerce/components'; | ||
import { onQueryChange, getQuery } from '@woocommerce/navigation'; | ||
import { | ||
downloadCSVFile, | ||
generateCSVDataFromTable, | ||
generateCSVFileName, | ||
} from '@woocommerce/csv-export'; | ||
import apiFetch from '@wordpress/api-fetch'; | ||
import { useDispatch } from '@wordpress/data'; | ||
import { parseInt } from 'lodash'; | ||
|
@@ -221,8 +216,6 @@ export const DepositsList = (): JSX.Element => { | |
depositsSummary.store_currencies || | ||
( isCurrencyFiltered ? [ getQuery().store_currency_is ] : [] ); | ||
|
||
const title = __( 'Payouts', 'woocommerce-payments' ); | ||
|
||
const downloadable = !! rows.length; | ||
|
||
const endpointExport = async ( language: string ) => { | ||
|
@@ -312,48 +305,11 @@ export const DepositsList = (): JSX.Element => { | |
|
||
const onDownload = async () => { | ||
setIsDownloading( true ); | ||
const downloadType = totalRows > rows.length ? 'endpoint' : 'browser'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this – the name |
||
|
||
if ( 'endpoint' === downloadType ) { | ||
if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { | ||
setCSVExportModalOpen( true ); | ||
} else { | ||
endpointExport( '' ); | ||
} | ||
if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { | ||
setCSVExportModalOpen( true ); | ||
} else { | ||
const params = getQuery(); | ||
|
||
const csvColumns = [ | ||
{ | ||
...columns[ 0 ], | ||
label: __( 'Payout Id', 'woocommerce-payments' ), | ||
}, | ||
...columns.slice( 1 ), | ||
]; | ||
|
||
const csvRows = rows.map( ( row ) => [ | ||
row[ 0 ], | ||
{ | ||
...row[ 1 ], | ||
value: dateI18n( | ||
'Y-m-d', | ||
moment.utc( row[ 1 ].value ).toISOString(), | ||
true | ||
), | ||
}, | ||
...row.slice( 2 ), | ||
] ); | ||
|
||
downloadCSVFile( | ||
generateCSVFileName( title, params ), | ||
generateCSVDataFromTable( csvColumns, csvRows ) | ||
); | ||
|
||
recordEvent( 'wcpay_deposits_download', { | ||
exported_deposits: rows.length, | ||
total_deposits: depositsSummary.count, | ||
download_type: 'browser', | ||
} ); | ||
Comment on lines
-346
to
-350
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we deprecate this track event and create a new one, or should we continue using this with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should keep the existing tracks events, but update the tracks event information noting that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, the user intention is not changing, so we should ideally keep the existing events. We should have events for the key user actions, and ideally all events will be triggered in front-end code, close to the action happening. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll comment on the specifics of all the tracks events in my review comment. |
||
endpointExport( '' ); | ||
} | ||
|
||
setIsDownloading( false ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,6 @@ import moment from 'moment'; | |
import { Button } from '@wordpress/components'; | ||
import { TableCard, Link } from '@woocommerce/components'; | ||
import { onQueryChange, getQuery, getHistory } from '@woocommerce/navigation'; | ||
import { | ||
downloadCSVFile, | ||
generateCSVDataFromTable, | ||
generateCSVFileName, | ||
} from '@woocommerce/csv-export'; | ||
import classNames from 'classnames'; | ||
import apiFetch from '@wordpress/api-fetch'; | ||
import { useDispatch } from '@wordpress/data'; | ||
|
@@ -43,7 +38,6 @@ import { | |
} from 'multi-currency/interface/functions'; | ||
import DisputesFilters from './filters'; | ||
import DownloadButton from 'components/download-button'; | ||
import disputeStatusMapping from 'components/dispute-status-chip/mappings'; | ||
import { CachedDispute, DisputesTableHeader } from 'wcpay/types/disputes'; | ||
import { getDisputesCSV } from 'wcpay/data/disputes/resolvers'; | ||
import { | ||
|
@@ -444,71 +438,11 @@ export const DisputesList = (): JSX.Element => { | |
|
||
const onDownload = async () => { | ||
setIsDownloading( true ); | ||
const title = __( 'Disputes', 'woocommerce-payments' ); | ||
const downloadType = totalRows > rows.length ? 'endpoint' : 'browser'; | ||
|
||
if ( 'endpoint' === downloadType ) { | ||
if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { | ||
setCSVExportModalOpen( true ); | ||
} else { | ||
endpointExport( '' ); | ||
} | ||
|
||
if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) { | ||
setCSVExportModalOpen( true ); | ||
} else { | ||
const csvColumns = [ | ||
{ | ||
...headers[ 0 ], | ||
label: __( 'Dispute Id', 'woocommerce-payments' ), | ||
}, | ||
...headers.slice( 1, -1 ), // Remove details (position 0) and action (last position) column headers. | ||
]; | ||
|
||
const csvRows = rows.map( ( row ) => { | ||
return [ | ||
...row.slice( 0, 3 ), // Amount, Currency, Status. | ||
{ | ||
// Reason. | ||
...row[ 3 ], | ||
value: | ||
disputeStatusMapping[ row[ 3 ].value ?? '' ] | ||
.message, | ||
}, | ||
{ | ||
// Source. | ||
...row[ 4 ], | ||
value: formatStringValue( | ||
( row[ 4 ].value ?? '' ).toString() | ||
), | ||
}, | ||
...row.slice( 5, 10 ), // Order #, Customer, Email, Country. | ||
{ | ||
// Disputed On. | ||
...row[ 10 ], | ||
value: dateI18n( | ||
'Y-m-d', | ||
moment( row[ 10 ].value ).toISOString() | ||
), | ||
}, | ||
{ | ||
// Respond by. | ||
...row[ 11 ], | ||
value: dateI18n( | ||
'Y-m-d / g:iA', | ||
moment( row[ 11 ].value ).toISOString() | ||
), | ||
}, | ||
]; | ||
} ); | ||
|
||
downloadCSVFile( | ||
generateCSVFileName( title, getQuery() ), | ||
generateCSVDataFromTable( csvColumns, csvRows ) | ||
); | ||
|
||
recordEvent( 'wcpay_disputes_download', { | ||
exported_disputes: csvRows.length, | ||
total_disputes: disputesSummary.count, | ||
download_type: 'browser', | ||
} ); | ||
Comment on lines
-511
to
-515
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we deprecate this track event and create a new one, or should we continue using this with |
||
endpointExport( '' ); | ||
} | ||
|
||
setIsDownloading( false ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be clearer to word this positively, the negative wording assumes/requires context to understand.
Something like this: