Skip to content

Premium Analytics: badge the Earnings History widget statuses - #52565

Open
dognose24 wants to merge 8 commits into
trunkfrom
update/premium-analytics-earnings-status-badges
Open

dognose24 wants to merge 8 commits into
trunkfrom
update/premium-analytics-earnings-status-badges

Conversation

@dognose24

@dognose24 dognose24 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Part of WOOA7S-2160

Proposed changes

Eder's design pass on the Earnings History widget (p1790006682602199-slack-C06FSDTSN82): badges everywhere the payment status shows, and the pending explanation outside the badge.

  • The Earnings History widget shows each period's payment status as a badge, the same EarningsStatusBadge the Earnings report has used since Premium Analytics: show sponsored content and adjustment earnings on the Earnings history report #52437: Paid green, Unpaid red, Pending orange. The plain-text EarningsStatusLabel had no other caller and is gone.
  • The two pending statuses read Pending instead of Pending (Missing Tax Info) / Pending (Invalid PayPal), on the widget and the report alike. The reason moves into an info icon before the badge: the same click-open popover as the widget header's own info icon, titled with the reason (Missing tax info) over the full explanation. It is a button, so the keyboard reaches it.
  • The report's Status filter offers Pending once, covering both codes, since they now share a label.
  • The CSV export keeps the reason: Pending (Missing tax info).
  • Amounts stay neutral everywhere: the widget no longer colours a negative amount red. Colour now belongs to the status badge alone, as on the report, where the adjustment rows with negative amounts actually live. Polaris does the same: minus before the currency symbol, no colour.

Not in this PR: the adjustments badge in the widget footer (#52526).

Widget before Widget after
截圖 2026-09-21 下午4 26 25 截圖 2026-09-22 下午2 41 58

Related product discussion/links

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

No.

Testing instructions

Use a site with WordAds earnings, or the local zz-tmp-pa-wordads-mock.php mu-plugin, whose payload has Unpaid, Paid and one Pending (code 3) row.

  • Open Stats → Ads. In Earnings History, confirm every status is a badge: Unpaid red, Paid green, the pending row orange and reading just Pending, with an info icon before it. Click the icon: a popover titled Missing tax info shows the "Payment is pending due to missing information…" explanation. Tab to it and press Enter: same. Hovering alone does nothing, as with the widget header's icon.
  • Open the Earnings history report. Confirm the same badges and icon in the Status column, and that the row no longer wraps.
  • Open the Status filter. Confirm the options are Unpaid, Paid and Pending, once each; pick Pending and confirm the pending row is the one left.
  • Download the CSV. Confirm the pending row's status reads Pending (Missing tax info).
  • On the report's Adjustments history tab, confirm -$2.50 reads in the neutral text colour with its minus sign, as before.
  • jp test js packages/premium-analytics passes.

🤖 Generated with Claude Code

Per Eder's design pass: the widget's payment status is a badge as on the
report, and the two pending statuses read "Pending" with their reason in
an info icon beside the badge, on both surfaces. The report's Status filter
offers Pending once for both codes, and the CSV keeps the reason.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dognose24
dognose24 requested a review from a team as a code owner September 21, 2026 17:21
@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. labels Sep 21, 2026
@dognose24 dognose24 self-assigned this Sep 21, 2026
@github-actions

github-actions Bot commented Sep 21, 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 or WordPress.com Site Helper), and enable the update/premium-analytics-earnings-status-badges branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/premium-analytics-earnings-status-badges
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/premium-analytics-earnings-status-badges

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

@github-actions github-actions Bot added [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh labels Sep 21, 2026
@github-actions

github-actions Bot commented Sep 21, 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:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

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


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

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.

The status badge carries the colour now; a negative amount reads with its
minus sign in the normal text colour, as on the report.

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

jp-launch-control Bot commented Sep 21, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/wordads-earnings-history/fields.tsx 29/29 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/routes/reports/earnings/page.tsx 26/26 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

dognose24 and others added 6 commits September 22, 2026 01:45
An inline-flex wrapper blockified the badge, so a pending row's badge came
out taller than the bare badges around it. The wrapper stays inline and
only the info icon is an inline-level box.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every status now sits in the same inline-flex wrapper, which blockifies the
badge so it takes its line height plus padding, as the design draws it,
rather than painting over a shorter line box. The pending row's icon
shares that wrapper.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The info icon is the design system Popover the report chart help uses,
which opens on a short hover, a click, or the keyboard. The components
Tooltip waited on a long hover and ignored clicks.

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

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The popover title is heading-sized and stays hidden, as in the widget
header's tip; the reason opens the description instead.

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.

Thanks for the design pass! @dognose24 Tested well. 👍

I left a few inline notes, mostly around reusing the existing info tip and the tests.

Comment on lines +176 to +189
<Popover.Root modal="trap-focus">
<Popover.Trigger aria-label={ detail } className={ styles.info }>
<Icon icon={ info } size={ 16 } />
</Popover.Trigger>
<Popover.Popup className={ styles.popup }>
<Popover.Arrow />
<VisuallyHidden render={ <Popover.Title /> }>{ detail }</VisuallyHidden>
<Popover.Description>
<span className={ styles.reason }>{ detail }</span>
{ tooltip }
</Popover.Description>
</Popover.Popup>
</Popover.Root>
<Badge intent={ intent }>{ label }</Badge>

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 reuse ReportChartHelp here instead of a second info tip? I noticed this one repeats its trigger reset and popup width with a different icon size (16 vs 20), so the two may drift as they get tweaked.

// The same click-open tip as the widget header's info icon.
return (
<span className={ styles.root }>
<Popover.Root modal="trap-focus">

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.

I wonder if modal="trap-focus" does anything here. Without a Popover.Close, base-ui treats the popup as non-modal, so Tab moves straight out and closes it. Should we drop modal, or add a hidden Close so the trap is real?

@@ -0,0 +1,30 @@
/* Inline-flex blockifies the badge, so it stands its full line height plus
* padding, as in the design, and every status comes out the same height. */
.root {

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 .root and .reason be Stack and Text variant="heading-sm" from externals? With the tip shared, this stylesheet may not need to exist.

// row keeps its reason, which the table shows in an icon.
getValue: row => {
const { label, detail } = getEarningsStatus( row.status );
return detail ? `${ label } (${ detail })` : label;

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 this go through sprintf like build-csv.ts does for %s (Previous Period)? The parentheses and order are fixed here, so some locales can't translate the export string.

getValue: row => getEarningsStatus( row.status ).label,
// The numeric code says nothing to a reader of the export; a pending
// row keeps its reason, which the table shows in an icon.
getValue: row => {

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.

Worth a pending row in report-csv-exports.test.tsx? The Earnings history case only has Unpaid and Paid, so this branch never runs there.

render( <EarningsStatusBadge status={ 3 } /> );

expect( screen.getByText( 'Pending' ) ).not.toHaveAttribute( 'tabindex' );
expect( screen.getByRole( 'button', { name: 'Missing tax info' } ) ).toBeInTheDocument();

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 this also click the trigger and check the explanation, like report-chart-section.test.tsx does? Right now the description could be emptied without a test going red.

Comment on lines +19 to 23
it( 'keeps the pending reason beside the label, not in it', () => {
expect( getEarningsStatus( 3 ).detail ).toBe( 'Missing tax info' );
expect( getEarningsStatus( 4 ).detail ).toBe( 'Invalid PayPal' );
expect( getEarningsStatus( 0 ).detail ).toBeUndefined();
} );

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 one go? It reads the constant back from the map, and the badge test below already covers the reason.

<EarningsStatusLabel status={ row.status } />
<span className={ styles.amount }>{ formatMetricValue( row.amount, 'currency' ) }</span>
<span className={ styles.status }>
<EarningsStatusBadge status={ row.status } />

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.

Worth a list test with a pending row? earnings-history-list.test.tsx never asserts the status cell, so swapping the badge out would stay green.

Comment on lines 41 to 42
* WordAds payment statuses by code, ported verbatim from the Jetpack Stats WordAds
* `getStatus` map (wp-calypso client/my-sites/stats/wordads/earnings.jsx).

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: Still verbatim? The pending labels now differ from Calypso's.

Suggested change
* WordAds payment statuses by code, ported verbatim from the Jetpack Stats WordAds
* `getStatus` map (wp-calypso client/my-sites/stats/wordads/earnings.jsx).
* WordAds payment statuses by code, adapted from the Jetpack Stats WordAds
* `getStatus` map (wp-calypso client/my-sites/stats/wordads/earnings.jsx),

Significance: patch
Type: changed

Ads: Show payment status as a badge in the Earnings History widget, and shorten the pending statuses to one word with the reason beside them.

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: Worth a clause that negative amounts on the widget are no longer red? #52389's entry announced the red, so readers may look for it leaving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 [Plugin] Wpcomsh [Status] Needs Review This PR is ready for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants