ProjectSidewalk / SidewalkWebpage

Project Sidewalk web page
http://projectsidewalk.org
MIT License
80 stars 23 forks source link

Only allowing tutorial users to delete appropriate labels #3541

Closed srihariKrishnaswamy closed 1 month ago

srihariKrishnaswamy commented 2 months ago

Resolves #2634

In this PR, I prohibited users from being able to delete any of the labels they place in tutorial except for the latest, erroneous one that they placed. I did this by adding a currentLabelId field in the Onboarding.js file in the frontend, and comparing the id of the label being deleted against it to see if the deletion was valid. The label only got deleted if it had the same id as the most recent label placed.

Before/After screenshots (if applicable)

BEFORE

image

Here we can delete the first label instead since there's no restrictions on what labels we can delete:

image

AFTER

image

Since you're only allowed to delete the most recent label, the only thing you can do now is delete it and re-place it appropriately:

image
Testing instructions
  1. Fire up tutorial
  2. Label 1 label
  3. For the next label, be wildly inaccurate
  4. Try to delete the first label when prompted to delete a label (nothing should happen when you press the x button)
  5. Try to delete the latest label now (it should delete successfully and move on with the tutorial!)
Things to check before submitting the PR