Premium Analytics: Authors widget follow-ups#50078
Conversation
|
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! |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
There was a problem hiding this comment.
Pull request overview
Follow-up fixes for the Premium Analytics Authors widget to ensure it responds to dashboard date range changes, improves labeling for unnamed authors, and tightens typing/styling consistency.
Changes:
- Adjust the Authors widget render flow to avoid stale
reportParamsoverriding the live URL date range. - Localize the “Untracked Authors” sentinel coming from the Stats sanitizer, with unit test coverage.
- Introduce a shared
AuthorsAttributestype and correct the widget example attribute type; tweak empty-state centering styles.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/premium-analytics/widgets/authors/widget.ts | Adds exported AuthorsAttributes and fixes example.attributes.max to a number. |
| projects/packages/premium-analytics/widgets/authors/render.tsx | Changes how WidgetRoot is instantiated and composes render-time attribute types. |
| projects/packages/premium-analytics/widgets/authors/build-top-authors-data.ts | Localizes the untracked-authors sentinel/empty label via getAuthorLabel. |
| projects/packages/premium-analytics/widgets/authors/tests/build-top-authors-data.test.ts | Adds a test ensuring the sentinel label is localized. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-empty-state/chart-empty-state.module.scss | Adds margin-inline: auto for horizontal centering. |
| projects/packages/premium-analytics/changelog/update-pa-authors-widget-followups | Adds a changelog entry describing the fixes. |
…ract Reverts the attributes drop: the dashboard does not inject reportParams into attributes (so the date-range URL still drives the query), and passing attributes is required by the widget render contract and for the Storybook WidgetDashboardWithWidget story.
dognose24
left a comment
There was a problem hiding this comment.
Thanks for the follow-up fixes. This lines up with the Locations/Devices widget direction by keeping the render attributes passed into WidgetRoot and letting WidgetRoot handle the report params fallback. I left one non-blocking wording nit on the comment, but the implementation looks good to me.
Fixes WOOA7S-1495
Proposed changes
Follow-ups to the Authors widget added in #49570:
render.tsxno longer passesattributesintoWidgetRoot. The host injects areportParamsinto the widget'sattributes, andWidgetRootwould prefer that stale shadow copy over the live URL search params the date picker writes — so the date picker never reached the query. Dropping the prop letsWidgetRootresolve report params from the URL the same way the other Stats widgets do. The widget's ownmaxattribute is forwarded to the inner component instead."Untracked Authors"sentinel for authors with no name.getAuthorLabelnow matches that sentinel (and any empty label) and returns the localized__( 'Untracked authors' )string. Added a test covering this.AuthorsAttributestype inwidget.tsand composed the render-only shape (AuthorsRenderAttributes) from it plusPartial<ReportParamsFieldAttributes>, instead of redeclaring an ad-hoc inline type. Also corrected theexampleattributemaxfrom the string'7'to the number7.margin-inline: autoso the empty state centers horizontally.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
pnpm --filter ... testor runbuild-top-authors-data.test.tsto confirm the untracked-authors localization test passes.