Premium Analytics: add date range picker to the dashboard#49572
Premium Analytics: add date range picker to the dashboard#49572Nikschavan wants to merge 9 commits into
Conversation
Private, source-consumed copy of @wordpress/grid until core publishes it.
Private, source-consumed copy of @wordpress/widget-primitives until core publishes it.
Private, source-consumed dashboard engine; depends on jetpack-widget-primitives and jetpack-grid.
Renders the WidgetDashboard engine via wp-build, bundling the grid/primitives/dashboard packages.
useWidgetTypes drives discovery via /wp/v2/widget-modules; hello-world builds as a lazy-loaded script module.
Hook the page boot-dependencies filter so widget modules reach the import map; move the endpoint to the jetpack/v4 namespace.
@wordpress/grid and widget-primitives references in widget-dashboard JSDoc/comments/README, per the faithful-source sync policy.
Stages from/to and comparison params via useStagedSearch and commits them to URL search params so widgets re-fetch on apply. Fixes the widget-root default search source to the page root.
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Pull request overview
Ports the Premium Analytics dashboard to support a shared date range picker (with comparison), syncing date state through URL search params so all widgets resolve consistent report parameters.
Changes:
- Render
DateFiltersPanelin the Premium Analytics dashboard route and wire it to staged URL search params with an Apply/Cancel flow. - Update widgets-toolkit
WidgetRootto default its search param source to/(the Premium Analytics dashboard route). - Add/adjust internal package dependencies and lockfile entries to ensure route bundling can resolve shared packages.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/premium-analytics/routes/dashboard/stage.tsx | Adds the date range + comparison UI and stages/commits selected values to URL search params. |
| projects/packages/premium-analytics/routes/dashboard/package.json | Adds required internal deps and date-fns for the dashboard route bundle. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/widget-root/widget-root.tsx | Changes default search-param source route to / for report param normalization. |
| projects/packages/premium-analytics/package.json | Adds link:packages/* deps so wp-build can resolve internal packages for the route bundle. |
| projects/packages/premium-analytics/changelog/add-pa-date-range-picker | Changelog entry for the new dashboard date range picker. |
| pnpm-lock.yaml | Lockfile updates for the new link dependencies. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
| const range = useMemo( () => { | ||
| return { | ||
| from: effective.from ? localTZDate( effective.from ) : undefined, | ||
| to: effective.to ? localTZDate( effective.to ) : undefined, | ||
| }; |
| const onComparisonChange = useCallback( | ||
| ( nextComparisonRange: DateRange | undefined, nextComparisonPresetId?: ComparisonPresetId ) => { | ||
| stage( { | ||
| compare_from: encodeDateToSearchParam( nextComparisonRange?.from ), | ||
| compare_to: encodeDateToSearchParam( nextComparisonRange?.to ), | ||
| compare_preset: nextComparisonPresetId ?? undefined, | ||
| comp: nextComparisonRange ? '1' : undefined, | ||
| } ); | ||
|
|
||
| commit(); | ||
| }, | ||
| [ stage, commit ] |
| */ | ||
| stage( { | ||
| from: encodeDateToSearchParam( nextRange.from ), | ||
| to: encodeDateToSearchParam( endOfDay( nextRange.to ) ), |
d060b2d to
5bb6dd9
Compare
Fixes #
Proposed changes
Ports the date range picker from the next-woocommerce-analytics dashboard into the Premium Analytics dashboard, syncing the selected range to URL search params so every widget picks it up.
DateFiltersPanel(already vendored inpackages/ui) at the top of the dashboard, wired touseStagedSearchfrom@jetpack-premium-analytics/routing. Date range and preset edits are staged locally and committed atomically to the URL search params on Apply (from,to,preset); thetodate is adjusted to end-of-day since the calendar component returns midnight. Comparison changes (compare_from,compare_to,compare_preset,comp) commit immediately, matching the original dashboard behavior.WidgetRoot's default search source at/(the premium-analytics dashboard route) instead of the WooCommerce Analytics route path, so widgets resolve their report params from the dashboard URL vianormalizeReportParams. No widget changes needed — they already read params throughuseWidgetRootContext().link:packages/*deps for thedata/datetime/formatters/routing/uiinternal packages so wp-build can resolve them from the route bundle; documents the new deps in the dashboard route's package.json; updatespnpm-lock.yamlaccordingly.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
from,toandpresetsearch params inside thepparam) and widgets re-fetch for the new range.compare_from/compare_to/compare_preset/compparams commit immediately without pressing Apply.