Skip to content

Dashboard v2: Add the ability to delete a site #103764

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 12 commits into from
May 29, 2025

Conversation

arthur791004
Copy link
Contributor

Part of DOTCOM-13249

Proposed Changes

This PR implements the option to delete a site via the modal component SiteDeleteModal. The action is visible if the site is not a staging site.

image

The SiteDeleteModal has following states:

  1. You're able to delete the site
    image
  2. The site has active purchases
    image
  3. The site is reverting to a simple site
    image
  4. P2 Hub
    image
  5. Trial site
    image

Why are these changes being made?

  • Hosting Dashboard v2 implementation.

Testing Instructions

  • Head to /v2/sites/:siteSlug/settings
  • Ensure that the Delete Site action is available, and it works as described above.

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)?

Copy link

github-actions bot commented May 28, 2025

@matticbot
Copy link
Contributor

matticbot commented May 28, 2025

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

App Entrypoints (~123 bytes added 📈 [gzipped])

name                    parsed_size           gzip_size
entry-dashboard-dotcom       +421 B  (+0.0%)     +123 B  (+0.0%)
entry-dashboard-a4a          +421 B  (+0.0%)     +123 B  (+0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~220 bytes added 📈 [gzipped])

name           parsed_size           gzip_size
site-settings       +421 B  (+0.0%)     +111 B  (+0.0%)
hosting             +421 B  (+0.0%)     +109 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
Copy link
Contributor

matticbot commented May 28, 2025

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

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

  • blaze-dashboard
  • help-center
  • odyssey-stats

To test WordPress.com changes, run install-plugin.sh $pluginSlug feat/dashboard-v2-delete-site on your sandbox.

@arthur791004 arthur791004 changed the title Feat/dashboard v2 delete site Dashboard v2: Add the ability to delete a site May 28, 2025
@arthur791004 arthur791004 force-pushed the feat/dashboard-v2-delete-site branch from 12b2ca0 to 0c29ed3 Compare May 28, 2025 10:03
@arthur791004 arthur791004 marked this pull request as ready for review May 28, 2025 10:52
@arthur791004 arthur791004 requested review from youknowriad and a team as code owners May 28, 2025 10:52
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 28, 2025
@arthur791004 arthur791004 self-assigned this May 28, 2025
export default function DangerZone( { site }: { site: Site } ) {
const canTransferSite = useCanTransferSite( { site } );

const actions = [
canTransferSite && <SiteTransferAction key="transfer-site" site={ site } />,
<SiteLeaveAction key="leave-site" site={ site } />,
showSiteDeleteAction( site ) && <SiteDeleteAction key="delete-site" site={ site } />,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be canDeleteSite( site ) from site-delete-modal; why do we have two different checks 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the staging site, we don't show the "Delete site" on the Settings screen. Instead, you should go to the production site to manage your staging site. As a result, we need this to determine whether to show the action

};

const canDeleteSite = ( site: Site ) =>
( site.is_wpcom_atomic || ! site.jetpack ) && ! site.is_vip && ! site.options?.p2_hub_blog_id;
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's existing code but I wonder what || ! site.jetpack is doing here. Seems not used in other logic in dashboard v2...

Copy link
Contributor Author

@arthur791004 arthur791004 May 29, 2025

Choose a reason for hiding this comment

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

I think it's self-hosted jetpack sites and we cannot delete those sites on our end.

};

return (
<Modal title={ __( 'Delete site' ) } size="medium" onRequestClose={ onClose }>
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't create new modals in #103723 because I thought maybe we could get transitions added to the modal, and we would have this multiple pop-up experience where the user has to watch it close and reopen. Maybe that's a conspiracy that I don't need to think about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done by 137245e.

Copy link
Contributor

@taipeicoder taipeicoder left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@arthur791004 arthur791004 force-pushed the feat/dashboard-v2-delete-site branch 2 times, most recently from 137245e to 3f83570 Compare May 29, 2025 08:13
Base automatically changed from add/DOTCOM-13259-site-leave to trunk May 29, 2025 08:24
@arthur791004 arthur791004 force-pushed the feat/dashboard-v2-delete-site branch from 3f83570 to 17dfb93 Compare May 29, 2025 08:41
@arthur791004 arthur791004 merged commit edbfa46 into trunk May 29, 2025
11 checks passed
@arthur791004 arthur791004 deleted the feat/dashboard-v2-delete-site branch May 29, 2025 11:20
@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 29, 2025
@a8ci18n
Copy link

a8ci18n commented May 29, 2025

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/17524451

Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday.

Thank you @arthur791004 for including a screenshot in the description! This is really helpful for our translators.

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.

6 participants