Skip to content

Use the OS native dialog to confirm a site deletion - #27

Merged
jeroenpf merged 4 commits into
trunkfrom
fix/use-native-dialog-to-confirm-site-deletion
Apr 29, 2024
Merged

Use the OS native dialog to confirm a site deletion#27
jeroenpf merged 4 commits into
trunkfrom
fix/use-native-dialog-to-confirm-site-deletion

Conversation

@jeroenpf

Copy link
Copy Markdown
Contributor

Related to https://github.com/Automattic/dotcom-forge/issues/6672

Proposed Changes

  • Replace the WordPress modal component with a OS native dialog to confirm the deletion of a site.
  • Fix small bug in onDeleteSite where when newSites is empty, we try to access index 0 which causes an error.

Testing Instructions

  • Create a site
  • Go to the site settings and click on 'Delete site' at the bottom of the settings page.
  • Ensure that a system native dialog appears.
    • Try to cancel and ensure the site is not deleted
    • Click on Delete site and confirm the site is deleted but the files are not.
    • Click on delete site and check "Delete site files from my computer" and ensure that the files are deleted.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@jeroenpf
jeroenpf requested a review from a team April 25, 2024 08:40
@jeroenpf jeroenpf self-assigned this Apr 25, 2024
@matt-west

Copy link
Copy Markdown
Contributor

Looks good and works as expected. Thanks @jeroenpf!

Screenshot 2024-04-25 at 17 21 28
@SiobhyB
SiobhyB self-requested a review April 25, 2024 21:43

@SiobhyB SiobhyB left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've added a couple of comments around error handling for your consideration, but the overall flow works as expected for me!

Comment thread src/components/delete-site.tsx Outdated
setNeedsConfirmation( false );
await deleteSite( selectedSite.id, checkboxChecked );
} catch ( e ) {
/* empty */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should we display an error message if deletion fails? We could use a similar error to this one we display when updating a site fails.

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.

Thanks for the review! I've added error handling as per your suggestion.


const DeleteSite = () => {
const { __ } = useI18n();
const { selectedSite, deleteSite, isDeleting, deleteError } = useSiteDetails();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As deleteError isn't used anywhere else, can it be removed from the useSiteDetails hook?

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.

I've deleted it now.

@jeroenpf
jeroenpf requested a review from SiobhyB April 26, 2024 08:35

@SiobhyB SiobhyB left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for making those changes, @jeroenpf! Looks great to me 🙌

@jeroenpf
jeroenpf merged commit c1d666c into trunk Apr 29, 2024
@jeroenpf
jeroenpf deleted the fix/use-native-dialog-to-confirm-site-deletion branch April 29, 2024 02:58
@wojtekn wojtekn mentioned this pull request May 14, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants