Skip to content

Stats: Add a "View in new tab" row action to the Posts & pages and Emails reports - #54058

Merged
dognose24 merged 17 commits into
trunkfrom
add/stats-report-rows-view-live-action
Oct 28, 2026
Merged

dognose24 merged 17 commits into
trunkfrom
add/stats-report-rows-view-live-action

Conversation

@dognose24

@dognose24 dognose24 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Part of STATS-552. Follows #53996, which added the "View" action to widget rows.

Proposed changes

Classic Stats let people open the live post from any row of a report. In Stats v2 the Posts & pages and Emails reports link each row's title to its stats detail page only, so reaching the live post takes a second click from there.

This PR gives those two report tables a DataViews row action, View in new tab, that opens the row's public URL in a new tab. Design asked for this over an icon beside the title (STATS-552): the Referrers report already keeps its row actions in DataViews' actions column, and an arrow next to a title that stays in the dashboard reads like the new-tab marker a linked-out title carries.

  • createViewLiveAction() builds the action once for both reports. It sits in the row's ⋮ actions menu, where the Referrers report keeps "Mark as spam…", so the tables offer their actions in one place.
  • Which rows get it is decided by toViewLiveUrl() from Stats: Add a "View" action that opens the live post from every widget row #53996, so the reports share the widgets' one gate: a title that opens a detail page the reader can reach, and a URL with an http(s) scheme. The homepage row, the Archives tab and rows that link out from their title get no action, as before.
  • The Videos report gets no action for now. Its summary endpoint (complete_stats=1) returns no URL for a video, and DataViews still renders the sticky Actions column when no row is eligible, so an empty column would cover Retention rate in a narrow window. Once the endpoint sends the video's permalink (not the wp-admin/media.php edit link the non-summary response carries), the Videos page can pass the same action. STATS-567 tracks that endpoint change.

Related product discussion/links

  • Linear: STATS-552
  • Linear: STATS-567 (the stats/video-plays URL the Videos report waits on)

Does this pull request change what data or activity we track or use?

No.

Screenshots

Posts & pages, with a row's ⋮ menu open: "View in new tab" opens the live post, the title still opens its stats.

Posts & pages report with the first row's actions menu open, offering View in new tab

Testing instructions

On a Jetpack site with Premium Analytics, open the Stats dashboard.

  1. Open Posts & pages (Traffic › Top posts & pages › View all). Open a row's ⋮ menu: it offers View in new tab. Choose it: the live post opens in a new tab. The title still opens the post's stats page.
  2. Tab through the table with the keyboard: the ⋮ button is a Tab stop, and Enter opens the menu.
  3. The homepage row and the Archives tab have no ⋮ menu; their titles already link out.
  4. Repeat on the Emails report.
  5. A row for a private or draft post has no action.
  6. The Videos report has no Actions column: narrow the window until the table scrolls sideways and the last column, Retention rate, stays uncovered.

🤖 Generated with Claude Code

dognose24 and others added 2 commits October 23, 2026 05:22
… row

Classic Stats gave each post row two ways in: the title opened the post's
stats and a "View" action opened the live post. Stats v2 rows with a post
ID opened the stats page only. `ViewLiveLink` is the trailing action, and
`LeaderboardRow` renders it beside the title whenever a row has both a
detail page and a public URL; `MetricList` takes it as a row `action` for
the Emails widget. It shows on hover and focus, and stays visible where
there is no hover.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Resolves the conflicts with #54017, which gates post detail links on
`isPostDetailAvailable()` and puts post-row media inside the title link.

- Changelog: move the plugin entry from wpcomsh, which does not bundle
  Premium Analytics, to plugins/jetpack and plugins/premium-analytics.
- Emails: show the "View" action only beside a title that opens the
  email's stats, so a row without a post ID keeps one link and a row
  without a URL leaves no gap.
- Leaderboard rows: keep the `title` tooltip on the title link, so the
  arrow shows only "View". A reader who cannot open post details gets the
  title linked out with no arrow, via the shared `toPostDetailId()`.
- Metric list: scope the label link styles to `.labelText`, so the arrow
  keeps the toolkit colour.
- Docs: update `LeaderboardPostLabel` and the chart-leaderboard README.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Premium Analytics plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/stats-report-rows-view-live-action branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/stats-report-rows-view-live-action

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@dognose24
dognose24 requested a review from chihsuan October 23, 2026 16:22
@jp-launch-control

jp-launch-control Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/routes/reports/emails/page.tsx 11/11 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/routes/reports/posts/page.tsx 28/29 (96.55%) 0.40% 0 💚

1 file is newly checked for coverage.

File Coverage
projects/packages/premium-analytics/routes/reports/view-live-action.ts 6/6 (100.00%) 💚

Full summary · PHP report · JS report

…email row in the reports

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dognose24
dognose24 force-pushed the add/stats-report-rows-view-live-action branch from b203605 to f33a383 Compare October 23, 2026 17:06
@dognose24 dognose24 changed the title Stats: Add a "View" row action that opens the live post from the Posts & pages, Videos and Emails reports Stats: Add a "View" action beside the title of every post, video and email row in the reports Oct 23, 2026
dognose24 and others added 3 commits October 24, 2026 01:39
…rline

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…nk' into add/stats-report-rows-view-live-action
…and log the change against the plugins that ship it

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dognose24
dognose24 force-pushed the add/stats-report-rows-view-live-action branch from 6e924e8 to 160133b Compare October 23, 2026 18:18
@dognose24 dognose24 added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests and removed [Status] In Progress [Plugin] Wpcomsh labels Oct 23, 2026
@github-actions github-actions Bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics labels Oct 23, 2026

@Nikschavan Nikschavan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for carrying the "View" action over to the reports. I left three notes inline. The one about the Posts gate test is the one I would like to see addressed before this merges, and the other two are fine as follow-ups once #53996 settles.

/>
);

if ( isHomepage || toPostDetailId( item.id ) === undefined ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gate can be replaced with if ( false ) and the posts suite stays green. The homepage fixture has link: null and id: 0, so the new toHaveLength( 1 ) in fields.test.tsx#L187 holds with or without it. The case this commit is for, a reader who cannot open post details, is not reachable in the file, because isPostDetailAvailable is mocked to true at L19. A row with an ID and a public URL, rendered with that mock returning false and expected to show one link, would cover it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in b393dad: the gate moved into ReportTitleCell, which asks toViewLiveUrl() from #53996, and the Posts suite now renders a row with both an ID and a link for a reader who cannot open post details and expects a single link. Removing the gate fails that test with two links, and if ( false ) fails the "offers the live post" test beside it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gone with 191bec8: the reports no longer render a title-cell link, so this gate and its fixture are out. The row action is gated by toViewLiveUrl() alone, and the Posts page test asserts the homepage row is not eligible.

ReportThumbnail,
REPORT_TITLE_LINK_CLASS_NAMES,
ReportTitleCell,
type ReportTitleCellProps,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing outside the toolkit imports ReportTitleCellProps; the three reports only render ReportTitleCell. The package's AGENTS.md asks for root exports only when an outside import needs them, types included. Is there a consumer planned that needs the props type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped in b393dad. Only ReportTitleCell leaves the root now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReportTitleCell is gone as of 191bec8, along with its props type and the toDetailId export, so nothing is left to narrow.

>
{ title }
</PostDetailLink>
<ReportTitleCell liveUrl={ typeof item.link === 'string' ? item.link : null } label={ title }>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each report chooses its own "View" gate: Posts checks toPostDetailId() at posts/config/fields.tsx#L82, Videos checks toDetailId() at videos/config/fields.tsx#L83, and this one checks only for a missing ID at L67, while the Emails widget uses toPostDetailId(). If #53996 gains the single helper for the live URL, ReportTitleCell could take the row's ID and URL and call it, so the three reports and the widgets cannot disagree and toDetailId would not need a root export. Fine as a follow-up after the parent settles.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought: could PostTitleLink / VideoTitleLink render "View" themselves, behind a prop? They already decide the detail link, and the route gate drifted once (160133b).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b393dad along those lines: ReportTitleCell takes the row's content kind, ID and public URL and calls toViewLiveUrl(), so the three reports and the widgets share one rule and toDetailId is no longer a root export.

@chihsuan I kept the action in the cell rather than behind a prop on PostTitleLink / VideoTitleLink: the Emails report renders PostDetailLink, not PostTitleLink, and the widgets place the action from the leaderboard row, so the cell is the one place every report goes through.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in 191bec8 the way you suggested: the three reports now hand toViewLiveUrl() the row kind, ID and URL and pass the result to one createViewLiveAction(), so there is a single gate shared with the widgets and no per-report copy.

dognose24 and others added 2 commits October 27, 2026 10:54
# Conflicts:
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/index.ts
… out of a row

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work bringing "View" to the reports! @dognose24 Hover and title links work well on my test site. 👍 A few inline notes below.

Comment on lines +115 to +122
<InternalLink
to="/video/$videoId"
params={ { videoId: String( videoId ) } }
search={ getVideoDetailSearch }
ariaLabel={ getVideoTitle( item ) }
>
{ thumbnail }
</InternalLink>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we check the poster with a mouse? Clicking it does nothing, since DataViews' ::after overlay covers the link (what #53011 fixed). Its focus ring is also clipped.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. On trunk DataViews rendered the row link itself, so the anchor was the media wrapper and the overlay sat on it. With the title now carrying two links, the poster link renders inside the wrapper, under DataViews' ::after.

Fixed in ed6ec80 in the records table's stylesheet: the overlay gets pointer-events: none, and the link fills the wrapper and draws its focus ring inset, as @wordpress/ui does in its own clipped containers. Tests, lint and types pass; I have not clicked it on a live site yet, so a second look there is welcome.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This went away with the approach: design asked for a DataViews row action instead of a link beside the title (191bec8), so the Videos report keeps the row link it had on trunk and the poster is back inside it, with no overlay to fight.

renderVideosField( 'poster', video );

const link = screen.getByRole( 'link', { name: 'Launch video' } );
expect( getMockRouteLinkUrl( link ).pathname ).toBe( '/video/12' );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this assert the date window too? Removing search from VideoPoster keeps the suite green.

Suggested change
expect( getMockRouteLinkUrl( link ).pathname ).toBe( '/video/12' );
const url = getMockRouteLinkUrl( link );
expect( url.pathname ).toBe( '/video/12' );
expect( Object.fromEntries( url.searchParams ) ).toEqual( {
from: '2026-06-01',
to: '2026-06-16',
interval: 'day',
ref: 'videos',
} );

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in ed6ec80, thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The poster link and this test are gone in 191bec8; the Videos report keeps its trunk row link, whose date window is covered by the existing page test.

}

return (
<ReportTitleCell liveUrl={ item.link } label={ title }>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we fall back to Untitled here, like Top posts? An untitled post names this arrow View "" in a new tab.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ed6ec80: the Posts report falls back to Untitled as Top posts does, with a test that the title and its "View" action both carry it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer applies: the row action is labelled "View in new tab" for every row (191bec8), so an untitled post has nothing to name. The Posts report title itself is unchanged from trunk.

dognose24 and others added 4 commits October 27, 2026 11:36
`toViewLiveUrl()` returns the live URL a row's "View" action opens, or
undefined when the row's title already links out or the URL is unsafe, so
the leaderboard, the Emails widget and the link itself no longer each spell
the rule. `toPostDetailId` goes back to being internal to the toolkit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`ReportTitleCell` now takes the row's content kind, ID and public URL and
asks `toViewLiveUrl()` whether the row gets the action, so the Posts, Videos
and Emails reports share one gate with the widgets instead of each writing
their own. The Posts gate is covered for a reader who cannot open post
details.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ed post in its "View" action

DataViews draws the media border on an overlay above the cell, which
swallowed clicks on the poster link the Videos report renders inside the
wrapper and clipped its focus ring. The Posts report now names an untitled
post "Untitled", as Top posts does, so its "View" action no longer reads
`View ""`, and the poster test asserts the date window the link carries.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
chihsuan
chihsuan previously approved these changes Oct 27, 2026

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! @dognose24 LGTM 🚀 Just one small nit inline.

fallbackIcon={ videoIcon }
/>
);
const videoId = toDetailId( item.id );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could the poster reuse VideoTitleLink with the thumbnail as children, like LeaderboardRow does? That way the poster and title share one detail-page check, and toDetailId could stay internal. It's still exported from the root index.ts, by the way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a55e530: the poster now renders VideoTitleLink around the thumbnail, so it follows the title into the detail page, or out to the live video on rows without one, and toDetailId is no longer exported from the toolkit. One thing to note: with the thumbnail decorative, the outbound marker alone would have named the external link, so the poster carries a visually hidden copy of the title as the standard image-link pattern.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by 191bec8: the poster no longer carries its own link, so there is nothing to share with VideoTitleLink, and toDetailId is no longer exported.

The poster now renders `VideoTitleLink` around the thumbnail, as the
leaderboard rows do, so the poster and the title share one detail-page
check and follow each other to the live video on rows without one. That
leaves `toDetailId` with no caller outside widgets-toolkit, so it is no
longer exported.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Base automatically changed from add/stats-post-rows-view-live-link to trunk October 27, 2026 17:00
@dognose24
dognose24 dismissed chihsuan’s stale review October 27, 2026 17:00

The base branch was changed.

@github-actions github-actions Bot added the Docs label Oct 27, 2026
dognose24 and others added 2 commits October 28, 2026 01:03
# Conflicts:
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/__tests__/leaderboard-row.test.tsx
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/chart-leaderboard/leaderboard-row.tsx
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/view-live-link/view-live-link.module.scss
#	projects/packages/premium-analytics/packages/widgets-toolkit/src/components/view-live-link/view-live-link.tsx
Design asked for the reports to keep row actions in DataViews' actions
column rather than beside the title, where the arrow read like the new-tab
marker a linked-out title carries. The three reports now pass a primary
"View in new tab" action that opens the row's public URL, gated by
`toViewLiveUrl()` so they share the widgets' one rule. The report title
cell, the poster link and the toolkit exports that only served them go.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dognose24 dognose24 changed the title Stats: Add a "View" action beside the title of every post, video and email row in the reports Stats: Add a "View in new tab" row action to the Posts & pages, Videos and Emails reports Oct 27, 2026
@dognose24
dognose24 requested a review from chihsuan October 27, 2026 17:05
A primary action draws its label on the row, which crowds the metric
columns. The action now lives in the row's actions menu, where the
Referrers report keeps "Mark as spam…".

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dognose24

Copy link
Copy Markdown
Contributor Author

Heads-up for a fresh look: this PR changed approach after design feedback on STATS-552.

  • The "View" link beside the title (ReportTitleCell, the poster link, the hover arrow) is gone. Design wants the report tables to keep row actions in DataViews' actions column, where the Referrers report already has "Mark as spam…", and an arrow next to a title that stays in the dashboard read like the new-tab marker a linked-out title carries.
  • The three reports now pass one createViewLiveAction(): a View in new tab entry in each row's ⋮ menu, gated by toViewLiveUrl() from Stats: Add a "View" action that opens the live post from every widget row #53996 so widgets and reports share the one rule. On Videos no row gets it yet, since the complete_stats endpoint returns no video URL.
  • Stats: Add a "View" action that opens the live post from every widget row #53996 has merged, so this now targets trunk; the diff is 11 files, all additions. The earlier threads are answered inline; everything they pointed at has been removed.

The description and testing instructions are rewritten for the new shape.

@dognose24
dognose24 requested a review from a team October 27, 2026 17:35

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reworking this around the row menu! @dognose24 I tried Posts & pages and Emails, and View in new tab opens the live post nicely. 👍 I left a few inline notes, mostly about the Videos table.

isFetching={ records.isFetching }
initialView={ RECORDS_VIEW }
searchLabel={ __( 'Search videos', 'jetpack-premium-analytics-pkg' ) }
actions={ actions }

@chihsuan chihsuan Oct 28, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we leave actions off the Videos table until the endpoint sends a video URL? DataViews still renders the sticky Actions column when no row is eligible, so it stays empty, and in a narrower window it covers Retention rate.

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. Done in 1a909e5: the Videos page is back to trunk, with no actions prop, so no sticky column. The PR title, description and changelogs now name only Posts & pages and Emails, and the testing instructions include a narrow-window check that Retention rate stays uncovered.

const actions = useMemo(
() => [
createViewLiveAction< StatsVideoPlaysComparisonItem >( video =>
toViewLiveUrl( 'video', video.id, video.link )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads-up rather than a change request: without complete_stats, the endpoint's video url is the wp-admin/media.php?action=edit link, not the public page. When the summary gains a URL, could we make sure it's the permalink? The Storybook mock also sends url here, so stories show an action production won't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, and recorded in the PR description so it is there when the endpoint changes: the Videos page should only pass the action once the summary sends the permalink, not the media.php edit link. I left the Storybook mock alone for now since the page no longer reads url.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened STATS-567 for the endpoint: both shapes of stats/video-plays should send the public permalink as url. The PR description links it.

mockEmailSummary();

render( <EmailsReportPage /> );
await userEvent.click( screen.getByRole( 'button', { name: 'Actions' } ) );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should this test use fake timers? findByRole polls like waitFor, and the package AGENTS.md asks for jest.useFakeTimers() with userEvent.setup( { advanceTimers: jest.advanceTimersByTime } ) there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that is what the package AGENTS.md asks for. The Emails test now runs on jest.useFakeTimers() with userEvent.setup( { advanceTimers: jest.advanceTimersByTime } ) (1a909e5).

Comment on lines +151 to +159
expect(
action?.isEligible?.( {
id: 0,
label: 'Home page',
views: 3,
link: 'https://example.com/',
type: 'homepage',
} )
).toBe( false );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would it be worth dropping the homepage case here? The page has no homepage logic of its own, so this only fails if toViewLiveUrl() regresses, which view-live-url.test.ts already covers. Same for the id: undefined case in the Videos test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The homepage case is gone from the Posts test, which now only checks that the page wires the action in and that a plain row is eligible; the Videos test went away with the action (1a909e5).

…sends a video URL

DataViews renders the sticky Actions column even when no row is eligible, so
an empty one covered Retention rate in a narrow window. The Posts and Emails
page tests now leave `toViewLiveUrl()`'s own cases to its unit test, and the
Emails one drives the menu on fake timers.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dognose24 dognose24 changed the title Stats: Add a "View in new tab" row action to the Posts & pages, Videos and Emails reports Stats: Add a "View in new tab" row action to the Posts & pages and Emails reports Oct 28, 2026
@dognose24
dognose24 requested a review from chihsuan October 28, 2026 05:24

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@dognose24
dognose24 merged commit 2545c34 into trunk Oct 28, 2026
132 of 133 checks passed
@dognose24
dognose24 deleted the add/stats-report-rows-view-live-action branch October 28, 2026 15:07
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants