Repository navigation
Premium Analytics: link widget titles to detail pages - #50919
Conversation
|
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! |
Code Coverage SummaryCoverage changed in 8 files. Only the first 5 are listed here.
2 files are newly checked for coverage.
|
48f520f to
aae6a49
Compare
chihsuan
left a comment
There was a problem hiding this comment.
Nice work here! I just added two questions. Please see inline comments.
aae6a49 to
21e30e4
Compare
There was a problem hiding this comment.
Pull request overview
Updates Premium Analytics widgets so post/page/newsletter titles navigate via in-app detail routes (preserving the active report date range), with safe public-URL (or plain-text) fallbacks for rows that can’t resolve to a detail page.
Changes:
- Introduce a shared
LeaderboardPostLabelwrapper aroundPostTitleLinkto standardize linked leaderboard-row labels and preserve report window params. - Update multiple widgets (Authors, Comments, Emails, Latest post, UTM Insights) to use internal detail routing where possible, with external/plain fallbacks.
- Add/expand Jest coverage and Storybook router/context setup for the updated navigation behavior.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/packages/premium-analytics/widgets/utm-insights/use-utm-insights.ts | Add postId to UTM drill-down child rows for internal detail routing. |
| projects/packages/premium-analytics/widgets/utm-insights/style.module.css | Adjust label layout; add inset class for post-label padding alignment. |
| projects/packages/premium-analytics/widgets/utm-insights/render.tsx | Render drilled-in post rows with LeaderboardPostLabel (internal routing + window carry). |
| projects/packages/premium-analytics/widgets/utm-insights/tests/utm-insights.test.tsx | Add navigation regression tests for internal vs fallback linking. |
| projects/packages/premium-analytics/widgets/utm-insights/tests/use-utm-insights.test.tsx | New hook unit test for mapping child post IDs/URLs. |
| projects/packages/premium-analytics/widgets/latest-post/style.module.css | Ensure title link color override wins deterministically via :any-link. |
| projects/packages/premium-analytics/widgets/latest-post/stories/latest-post-widget.stories.tsx | Add Storybook router decorator for internal links. |
| projects/packages/premium-analytics/widgets/latest-post/render.tsx | Swap published-post outbound link for internal post detail link + date-range carry. |
| projects/packages/premium-analytics/widgets/latest-post/package.json | Add routing package dependency for report-window param picking. |
| projects/packages/premium-analytics/widgets/latest-post/tests/latest-post-card.test.tsx | Update tests for internal detail routing + window carry + fallbacks. |
| projects/packages/premium-analytics/widgets/emails/style.module.css | Remove obsolete custom label styling now handled by shared label component. |
| projects/packages/premium-analytics/widgets/emails/stories/emails-widget.stories.tsx | Wrap presentational stories with WidgetRoot + router to support internal links. |
| projects/packages/premium-analytics/widgets/emails/render.tsx | Use LeaderboardPostLabel for newsletter titles and open the metric-matching detail tab. |
| projects/packages/premium-analytics/widgets/emails/tests/emails.test.tsx | New tests for metric→section routing and API row mapping into detail links. |
| projects/packages/premium-analytics/widgets/comments/use-comment-views.ts | Capture post IDs for posts view to enable internal detail navigation. |
| projects/packages/premium-analytics/widgets/comments/render.tsx | Render post rows via LeaderboardPostLabel instead of outbound permalink actions. |
| projects/packages/premium-analytics/widgets/comments/tests/comments.test.tsx | Add regression test asserting in-app navigation for post rows. |
| projects/packages/premium-analytics/widgets/authors/render.tsx | Render drilled-down post rows via LeaderboardPostLabel. |
| projects/packages/premium-analytics/widgets/authors/build-top-authors-data.ts | Preserve post ID separately from row ID for internal detail routes. |
| projects/packages/premium-analytics/widgets/authors/tests/build-top-authors-data.test.ts | Update expectations to include mapped postId. |
| projects/packages/premium-analytics/widgets/authors/tests/authors.test.tsx | Add regression test for drilled-down post internal navigation. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/index.ts | Re-export new shared leaderboard label component/types. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/post-title-link/post-title-link.tsx | Add default link styling (via module + clsx) while preserving caller overrides. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/post-title-link/post-title-link.module.scss | New default link styling to avoid wp-admin “admin blue” overrides. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/leaderboard-post-label/leaderboard-post-label.tsx | New shared component: row chrome + report-window carry + optional detail tab section. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/leaderboard-post-label/leaderboard-post-label.module.scss | New styles for compact vs overlay variants and ellipsis behavior. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/leaderboard-post-label/index.ts | New barrel export for the component/types. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/leaderboard-post-label/tests/leaderboard-post-label.test.tsx | New unit tests for internal routing, section param, and safe fallback behavior. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/index.ts | Export LeaderboardPostLabel from components index. |
| projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-row.tsx | Document why post/page/email labels should use LeaderboardPostLabel (no nested anchors in button rows). |
| projects/packages/premium-analytics/changelog/fix-widget-post-detail-links | Changelog entry for the user-facing navigation change. |
| } ); | ||
| return selectedAuthor.posts.map( post => ( { | ||
| id: post.id, | ||
| label: <LeaderboardPostLabel id={ post.postId } label={ post.title } link={ post.link } />, |
There was a problem hiding this comment.
withOverlayLabel only pre-blends the bar fill colour — it sets no row height. The variant tracks the sibling rows in the same widget, and the top-level author rows here come from buildLeaderboardRow, which renders the shared 36px row. So compact is what keeps the drilled-in posts aligned with the authors above them; overlay is what would make them taller than their siblings.
| action: href ? { kind: 'link', href } : { kind: 'static' }, | ||
| } ); | ||
| return { | ||
| label: <LeaderboardPostLabel id={ row.postId } label={ row.label } link={ row.link } />, |
There was a problem hiding this comment.
Same as the Authors thread — the authors view of this widget renders through buildLeaderboardRow at the shared 36px height, so the posts view matches it at compact. Emails and UTM Insights use overlay because their sibling rows carry padding-block instead.
Adds a postLink action kind to LeaderboardRow, so post titles reuse the shared row chrome instead of a parallel component. LeaderboardPostLabel now only resolves the report window. The row height variant moves to LeaderboardRow. PostTitleLink renders its router link through the design system link, which supplies the unstyled anchor treatment and the unlayered wp-admin guard. Both component stylesheets are dropped.
Trunk split the Comments widget into two, which dropped this branch's change to the posts view. Ports it onto most-commented-posts: rows render through LeaderboardPostLabel, so a row with a post ID opens the detail page and only a row without one falls back to the permalink.
2372cc7 to
090abac
Compare
chihsuan
left a comment
There was a problem hiding this comment.
Thanks @Nikschavan Looks good and tested well! 🚢
One small thing, could you update chart-leaderboard/README.md before merging? Thanks!
Covers the new postLink action kind, LeaderboardPostLabel as the widget-level entry point, and the variant and className row props. States that the variant follows the sibling rows in the widget, not the chart's withOverlayLabel prop, which only tints the bar fill.
Fixes WOOA7S-1831
Proposed changes
Widgets with detail page links
Rows without a post ID keep a safe public link, or plain text when no safe URL exists.
Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
git diff --check.