Repository navigation
Premium Analytics: Describe widget CSV downloads as action objects - #53013
Conversation
f0013fe to
6636bb5
Compare
…etch failure test
…-csv-exporters # Conflicts: # projects/packages/premium-analytics/packages/data/src/index.ts # projects/packages/premium-analytics/packages/data/src/queries/__tests__/fetch-stats-report-rows.test.ts # projects/packages/premium-analytics/packages/data/src/queries/fetch-stats-report-rows.ts # projects/packages/premium-analytics/packages/widgets-toolkit/src/index.ts # projects/packages/premium-analytics/packages/widgets-toolkit/src/report-exports/index.ts
Nikschavan
left a comment
There was a problem hiding this comment.
Thank you, the changes look good. I left one question inline about keeping the failure snackbar in parity with upstream.
What I checked: the Top pages and Top referrers download buttons still save their CSVs. I also forced a save failure by making URL.createObjectURL throw. The dismissible snackbar showed, and the button became available again. Blocking stats/top-posts in DevTools did not produce a failure for me, because the download reused the data that was already loaded and sent no request.
| id: string; | ||
| label: string; | ||
| icon: ReactElement; | ||
| /** Never rejects: the dashboard's action runner reports no failure, so this shows the snackbar. */ |
There was a problem hiding this comment.
This action copies the shape of the upstream WidgetCallbackAction and goes one step further: useDownloadWithErrorNotice shows a snackbar when the download fails. Upstream does not have that yet: useRunActions only logs a failed action with console.error, and its comment notes that hosts have no notices capability yet. The snackbar is a useful addition, so is there an upstream issue for it, to keep the two in parity?
There was a problem hiding this comment.
No dedicated issue yet, but WordPress/gutenberg#83877 lists it as a follow-up. Once hosts get notices, we can drop ours and let the callback reject.
|
Good catch, I updated the failed-download steps to force the failure from the console instead. |
…om-more-widgets' into uni-823-native-widget-action-prep # Conflicts: # projects/packages/premium-analytics/packages/widgets-toolkit/src/components/download-csv/exporter-csv-download-button.tsx
001bce1 to
dbc8185
Compare
…om-more-widgets' into uni-823-native-widget-action-prep # Conflicts: # projects/packages/premium-analytics/packages/data/src/queries/__tests__/fetch-stats-report-rows.test.ts # projects/packages/premium-analytics/packages/widgets-toolkit/src/components/download-csv/exporter-csv-download-button.tsx # projects/packages/premium-analytics/packages/widgets-toolkit/src/report-exports/__tests__/hierarchy-reports.test.ts # projects/packages/premium-analytics/packages/widgets-toolkit/src/report-exports/clicks.ts # projects/packages/premium-analytics/routes/reports/authors/page.test.tsx # projects/packages/premium-analytics/routes/reports/videos/page.test.tsx # projects/packages/premium-analytics/tests/js/widget-report-csv-parity.test.tsx # projects/packages/premium-analytics/widgets/test-utils.tsx # projects/packages/premium-analytics/widgets/top-posts/__tests__/top-posts.test.tsx
…t-action-prep # Conflicts: # projects/packages/premium-analytics/packages/widgets-toolkit/src/components/download-csv/exporter-csv-download-button.tsx # projects/packages/premium-analytics/tests/js/widget-report-csv-parity.test.tsx # projects/packages/premium-analytics/widgets/test-utils.tsx # projects/packages/premium-analytics/widgets/top-posts/__tests__/top-posts.test.tsx

Part of UNI-823
Proposed changes
Prepare the widgets' Download CSV action for the dashboard's native widget footer. Nothing changes on screen.
The existing download buttons render these actions, so no widget changes. Moving widget footers onto the native one waits for the Gutenberg change to land.
Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Setup
jp build plugins/jetpack --deps.wp-admin/admin.php?page=jetpack-premium-analytics-wp-admin.Card downloads
Failed download
URL.createObjectURL = () => { throw new Error( 'Test failure' ); };, then click the Top pages download button.