Skip to content

Studio: Delete all active demo sites - #131

Merged
kozer merged 12 commits into
trunkfrom
fix/delete_all_active_demo_sites
May 21, 2024
Merged

Studio: Delete all active demo sites#131
kozer merged 12 commits into
trunkfrom
fix/delete_all_active_demo_sites

Conversation

@kozer

@kozer kozer commented May 15, 2024

Copy link
Copy Markdown
Contributor

Related to https://github.com/Automattic/dotcom-forge/issues/6655
Fixes https://github.com/Automattic/dotcom-forge/issues/7081

Proposed Changes

This PR fixes a bug where the user reaches the maximum number of active demo sites. However, if none of the created sites are linked to the demo sites, he can't remove any to continue creating demo sites.

Testing Instructions

Prerequisite: Apply D148749-code

  1. Create some sites.
  2. Edit appdata-v1.json files, and remove all snapshots
  3. Restart the app
  4. Go to settings, and ensure that you see a number of active demo sites like the below:
    2024-05-15T09:36:58,113953464+03:00
  5. Press the 3 dots menu, and then press the "Delete all demo sites" button.
  6. Ensure that you see a message like below:
    2024-05-15T09:37:57,606601158+03:00
  7. Ensure that pressing cancel doesn't have any effect.
  8. Repeat steps from 4-6.
  9. On the dialog press "Delete all demo sites"
  10. Notice that the sites are deleted, and you end up with 0 active demo sites.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@kozer kozer self-assigned this May 15, 2024
@kozer
kozer requested a review from a team May 15, 2024 07:11
@sejas

sejas commented May 15, 2024

Copy link
Copy Markdown
Member

@kozer , what do you think about moving the heavy logic to the backend? I feel more confident if the App makes only one request to delete all the sites.

Comment thread src/hooks/use-site-usage.ts Outdated
@katinthehatsite

Copy link
Copy Markdown
Contributor

@kozer it seems that you are adding a confirmation window for deleting all sites in this PR. I currently have a similar issue assigned: https://github.com/Automattic/dotcom-forge/issues/7081 - would you like to assign it to yourself if that case since you are covering that functionality?

@kozer

kozer commented May 16, 2024

Copy link
Copy Markdown
Contributor Author

@kozer it seems that you are adding a confirmation window for deleting all sites in this PR. I currently have a similar issue assigned: https://github.com/Automattic/dotcom-forge/issues/7081 - would you like to assign it to yourself if that case since you are covering that functionality?

I'm sorry, Kat! The ticket I'm working on, mentioned the confirmation in the comments, and I haven't realized, there was a separate issue for that! I can assign it to me, thanks!

@kozer

kozer commented May 16, 2024

Copy link
Copy Markdown
Contributor Author

@kozer , what do you think about moving the heavy logic to the backend? I feel more confident if the App makes only one request to delete all the sites.

@sejas , I was thinking about that, and I decided not to do that, for the following reasons:

  1. We have all that logic in the client already implemented.
  2. It wouldn't change anything more, than just moving things around, as still, we will have to loop the sites and call request_site_deletion, on each one of them. Any of those delete requests can fail asynchronously ( as we call jobs in that function, that schedule a job, and call other apis ), so again we could have a network partition.
    So given that, I thought that although seems strange to have multiple requests, I don't see the real value of moving all that complicated logic of handling failures etc, as firstly, it works perfectly as is, and I don't see the clear benefit by doing so.
    What do you think?
@kozer
kozer requested review from a team and sejas May 16, 2024 06:04
@katinthehatsite

Copy link
Copy Markdown
Contributor

I'm sorry, Kat! The ticket I'm working on, mentioned the confirmation in the comments, and I haven't realized, there was a separate issue for that! I can assign it to me, thanks!

No worries, I have not started yet - so all good! I removed my assignment from that issue 👍

@katinthehatsite katinthehatsite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey I am testing this PR now and once I delete all the snapshots and navigate to Settings > three dots and attempt to click on the button to delete all sites, I can't seem to make proceed further as the button appears blocked:

Capture d’écran, le 2024-05-16 à 09 37 42

Any ideas what might be happening?

@kozer

kozer commented May 16, 2024

Copy link
Copy Markdown
Contributor Author

Hey I am testing this PR now and once I delete all the snapshots and navigate to Settings > three dots and attempt to click on the button to delete all sites, I can't seem to make proceed further as the button appears blocked:

Capture d’écran, le 2024-05-16 à 09 37 42 Any ideas what might be happening?

Tbh, I had the same problem this morning, @katinthehatsite . I applied the diff, and I didn't have any success.
I restarted the proxy and worked as expected!

To see if it's working or not, open dev tools and check if /usage endpoint resolves. For me it didn't

Comment thread src/components/user-settings.tsx
@katinthehatsite

Copy link
Copy Markdown
Contributor

Tbh, I had the same problem this morning, @katinthehatsite . I applied the diff, and I didn't have any success.
I restarted the proxy and worked as expected!
To see if it's working or not, open dev tools and check if /usage endpoint resolves. For me it didn't

I see, I did not apply the diff initially because I missed Prerequisite: Apply D148749 🤦‍♀️ However, now it works for me as expected when I follow the testing steps. I only have one comment on my end regarding buttons color.

@wojtekn wojtekn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When I tested the feature, I had some floating demo sites in Studio: a few expired ones, and one I removed using Jurassic Ninja Report Card tool. The new feature removed existing sites correctly, but it didn't clear the floating ones. Should it also remove all local demo sites?

Comment thread src/components/user-settings.tsx
@matt-west

Copy link
Copy Markdown
Contributor

Prerequisite: Apply D148749-code

@kozer I don't have access to that diff to apply it.

@kozer

kozer commented May 17, 2024

Copy link
Copy Markdown
Contributor Author

Prerequisite: Apply D148749-code

@kozer I don't have access to that diff to apply it.

It's ok Matt! I'm not sure what I need to do for you to obtain access. My guess is that @wojtekn can do that for you.

@sejas

sejas commented May 17, 2024

Copy link
Copy Markdown
Member

@kozer , what do you think about moving the heavy logic to the backend? I feel more confident if the App makes only one request to delete all the sites.

@sejas , I was thinking about that, and I decided not to do that, for the following reasons:

  1. We have all that logic in the client already implemented.
  2. It wouldn't change anything more, than just moving things around, as still, we will have to loop the sites and call request_site_deletion, on each one of them. Any of those delete requests can fail asynchronously ( as we call jobs in that function, that schedule a job, and call other apis ), so again we could have a network partition.
    So given that, I thought that although seems strange to have multiple requests, I don't see the real value of moving all that complicated logic of handling failures etc, as firstly, it works perfectly as is, and I don't see the clear benefit by doing so.
    What do you think?

Thanks for sharing the context! Let's do that 👌

Comment thread src/components/user-settings.tsx Outdated
Comment thread src/components/user-settings.tsx
@kozer
kozer requested a review from wojtekn May 20, 2024 15:20
@wojtekn

wojtekn commented May 21, 2024

Copy link
Copy Markdown
Contributor

Thanks @kozer , looks good:

Screenshot 2024-05-21 at 11 25 20 Screenshot 2024-05-21 at 11 22 28

Could you please fix lint errors?

@kozer
kozer merged commit b0e12c8 into trunk May 21, 2024
@kozer
kozer deleted the fix/delete_all_active_demo_sites branch May 21, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants