Skip to content
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

Studio: Delete all active demo sites #131

Merged
merged 12 commits into from
May 21, 2024
Merged

Conversation

kozer
Copy link
Contributor

@kozer kozer commented May 15, 2024

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 added [Type] Bug Something isn't working Studio App labels May 15, 2024
@kozer kozer self-assigned this May 15, 2024
@kozer kozer requested a review from a team May 15, 2024 07:11
@sejas
Copy link
Member

sejas commented May 15, 2024

@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.

src/hooks/use-site-usage.ts Outdated Show resolved Hide resolved
@katinthehatsite
Copy link
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
Copy link
Contributor Author

kozer commented May 16, 2024

@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
Copy link
Contributor Author

kozer commented May 16, 2024

@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 sejas and a team May 16, 2024 06:04
@katinthehatsite
Copy link
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 👍

Copy link
Contributor

@katinthehatsite katinthehatsite left a comment

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
Copy link
Contributor Author

kozer commented May 16, 2024

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

@katinthehatsite
Copy link
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.

Copy link
Contributor

@wojtekn wojtekn left a comment

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?

src/components/user-settings.tsx Show resolved Hide resolved
@matt-west
Copy link
Contributor

Prerequisite: Apply D148749-code

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

@kozer
Copy link
Contributor Author

kozer commented May 17, 2024

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
Copy link
Member

sejas commented May 17, 2024

@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 👌

src/components/user-settings.tsx Outdated Show resolved Hide resolved
src/components/user-settings.tsx Show resolved Hide resolved
@kozer kozer requested a review from wojtekn May 20, 2024 15:20
@wojtekn
Copy link
Contributor

wojtekn commented May 21, 2024

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
11 checks passed
@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
Studio App [Type] Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants