wp-calypso icon indicating copy to clipboard operation
wp-calypso copied to clipboard

A4A > Reports: Handle redirection based on report data

Open yashwin opened this issue 6 months ago • 4 comments

Resolves https://linear.app/a8c/issue/A4A-1133/reports-landing-redirect-based-on-the-reports-data

Proposed Changes

This PR handles the redirection on the reports page.

If there are reports, redirect to /reports/dashboard If there are no reports, redirect to /reports/overview

We have also updated how the useFetchAllManagedSites hook works:

  • Make the second fetch only if there are sites and it is not fetching. This is to prevent unnecessary extra requests being made.
  • Set loading if there are no sites and it is fetching. This is to prevent displaying No sites while the request is still in progress.
  • Set loading if the first fetch or second fetch is loading. We are earlier considering only the second fetch.

Why are these changes being made?

To redirect based on the report data

Testing Instructions

  • Open the A4A live link
  • Click the Reports menu > Verify you are redirected to the Overview page
  • Click the Build a new report button > Go ahead and create a report > Note: the data isn't formatted correctly. It is being fixed in another PR.
  • Go to Overview > Click the Reports menu > Verify that you are redirected to the Dashboard page.
  • Go to Migrations > Commissions > Click the Tag sites for commissions button > Verify there is no regression and the sites load
  • Go to WooPayments > Click the Add WooPayments to site button > Verify there is no regression and the sites load.

Pre-merge Checklist

  • [x] Has the general commit checklist been followed? (PCYsg-hS-p2)
  • [ ] Have you written new tests for your changes?
  • [ ] Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • [x] Have you checked for TypeScript, React or other console errors?
  • [ ] Have you tested accessibility for your changes? Ensure the feature remains usable with various user agents (e.g., browsers), interfaces (e.g., keyboard navigation), and assistive technologies (e.g., screen readers) (PCYsg-S3g-p2).
  • [ ] Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • [ ] Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • [ ] For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • [ ] For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

yashwin avatar Jun 16 '25 06:06 yashwin

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug update/a4a/reports/handle-redirection on your sandbox.

matticbot avatar Jun 16 '25 06:06 matticbot

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~300 bytes added 📈 [gzipped])

name                                parsed_size           gzip_size
a8c-for-agencies-reports                 +233 B  (+0.0%)     +132 B  (+0.0%)
a8c-for-agencies-woopayments             +104 B  (+0.0%)      +59 B  (+0.0%)
a8c-for-agencies-migrations              +104 B  (+0.0%)      +62 B  (+0.0%)
a8c-for-agencies-team                     -24 B  (-0.0%)       +6 B  (+0.0%)
a8c-for-agencies-settings                 -24 B  (-0.0%)       +8 B  (+0.0%)
a8c-for-agencies-referrals                -24 B  (-0.0%)       +6 B  (+0.0%)
a8c-for-agencies-purchases                -24 B  (-0.0%)       +7 B  (+0.0%)
a8c-for-agencies-plugins                  -24 B  (-0.0%)       +8 B  (+0.0%)
a8c-for-agencies-partner-directory        -24 B  (-0.0%)      +20 B  (+0.0%)
a8c-for-agencies-feedback                 -24 B  (-0.0%)       +8 B  (+0.0%)
a8c-for-agencies-client                   -24 B  (-0.0%)       +6 B  (+0.0%)
a8c-for-agencies-agency-tier              -24 B  (-0.0%)       +8 B  (+0.0%)
a8c-for-agencies                          -24 B  (-0.0%)       +9 B  (+0.0%)
a8c-for-agencies-sites                    -16 B  (-0.0%)      +13 B  (+0.0%)
a8c-for-agencies-overview                 -16 B  (-0.0%)      +13 B  (+0.0%)
a8c-for-agencies-marketplace              -16 B  (-0.0%)      +15 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

matticbot avatar Jun 16 '25 06:06 matticbot

Maybe I'm missing something, but the Report menu is not displayed... And if I paste the URL, it doesn't work either.

cleacos avatar Jun 16 '25 22:06 cleacos

Maybe I'm missing something, but the Report menu is not displayed... And if I paste the URL, it doesn't work either.

I'm curious if you have the latest trunk and have tested it using the live link. If you are testing it locally, you'll have to restart the server.

yashwin avatar Jun 23 '25 04:06 yashwin