Skip to content

A4A: Add loading indicator when removing site. #103284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2025

Conversation

jkguidaven
Copy link
Contributor

@jkguidaven jkguidaven commented May 9, 2025

The current 'Remove site' experience is somewhat broken, lacking any indication that the dashboard is processing the request. This PR introduces an isBusy state on the button to show that the site is loading.

Screen.Recording.2025-05-09.at.7.24.59.PM.mov

Closes https://linear.app/a8c/issue/A4A-793/show-a-loading-indicator-when-the-remove-site-request-is-in-progress

Proposed Changes

  • Pass the isPending state to the button to display the busy indicator. The isPending state should not depend on the mutation state; instead, it uses a custom state due to a one-second delay for refetching sites after a site has been removed.
  • Fix styling so there is proper spacing around the action and message elements.
  • Extra: I refactored the component for better readability, as the double-nested callback can be confusing. This also resolves a linting problem related to the component's display name.

Why are these changes being made?

  • This improves user experience

Testing Instructions

  • Use the A4A live link and navigate to /sites.
  • Remove a site.
  • Confirm that the modal shows a busy button when the request is being sent.

Pre-merge Checklist

  • 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)?
  • Have you checked for TypeScript, React or other console errors?
  • 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)?

@jkguidaven jkguidaven requested review from a team and Copilot May 9, 2025 11:16
@jkguidaven jkguidaven self-assigned this May 9, 2025
@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels May 9, 2025
Copy link

github-actions bot commented May 9, 2025

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the user experience when removing a site by adding a loading indicator and refactoring the modal component for better readability. Key changes include:

  • Introducing the isPending state to manage the busy indicator on the remove site button.
  • Refactoring the component structure to separate type definitions and the main component.
  • Ensuring the busy state is updated via both the onSuccess and onSettled callbacks.

Comment on lines 59 to 65
setIsPending( false );
} );
}, 1000 );
},
onSettled: () => {
setIsPending( false );
Copy link
Preview

Copilot AI May 9, 2025

Choose a reason for hiding this comment

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

The isPending state is set to false in both the onSuccess callback (inside the setTimeout) and the onSettled callback; consider centralizing state cleanup to avoid redundancy.

Suggested change
setIsPending( false );
} );
}, 1000 );
},
onSettled: () => {
setIsPending( false );
} );
}, 1000 );
},
onSettled: () => {
// Ensure state cleanup after the delay.
setTimeout( () => {
setIsPending( false );
}, 1000 );

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't do this because a refetch adds another delay on top of the 1 second.

@matticbot
Copy link
Contributor

matticbot commented May 9, 2025

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

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

  • help-center
  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/a4a/scrolling-bug-on-hosting-page on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented May 9, 2025

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

Sections (~104 bytes added 📈 [gzipped])

name                    parsed_size           gzip_size
a8c-for-agencies-sites       +277 B  (+0.0%)     +104 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.

@jkguidaven jkguidaven marked this pull request as ready for review May 9, 2025 11:27
Copy link
Contributor

@tiagonoronha tiagonoronha left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@jkguidaven jkguidaven force-pushed the fix/a4a/scrolling-bug-on-hosting-page branch from 1722a20 to 7874bbf Compare May 22, 2025 11:40
@jkguidaven jkguidaven merged commit 2c09c1a into trunk May 22, 2025
11 checks passed
@jkguidaven jkguidaven deleted the fix/a4a/scrolling-bug-on-hosting-page branch May 22, 2025 12:59
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants