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

Refactor controller actions and views for page delete confirmation #1659

Merged
merged 5 commits into from
Dec 9, 2024

Conversation

lfdebrux
Copy link
Member

@lfdebrux lfdebrux commented Dec 9, 2024

What problem does this pull request solve?

Trello card: https://trello.com/c/UThSZ8ga/2037-fix-behaviour-of-deleting-page-with-secondary-skip-route

We want to be able to add some extra warnings and information to the confirmation page shown to users when they try to delete a question in a form.

However, to do this, we need to do some refactoring first, because currently the code for deleting pages is tangled up with the code for deleting forms.

This PR refactors the forms delete confirmation controller to deal with forms only, and moves the code for deleting pages to the pages controller; it is more idiomatic Rails to have the destroy and delete actions for a model in the controller for that model.

While working on this change I also noticed that there's an extra bit of hint text which is supposed to be shown to users when deleting a live form. It currently is not due to a typo, but it's also inaccurate as we haven't yet fully implemented deleting a form draft. So this PR just removes that hint text completely.

The changes in this PR should be purely refactors and not result in any user facing changes.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Has all relevant documentation been updated?

@lfdebrux lfdebrux force-pushed the ldeb-refactor-page-delete branch from e79f72a to 84a9c3c Compare December 9, 2024 12:36
Copy link
Contributor

@stephencdaly stephencdaly left a comment

Choose a reason for hiding this comment

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

Changes all look good, and I've tested locally and it works as expected. Thanks for doing this!!

This is purely a cosmetic change at this point, but it helps to make it
clearer what is the appropriate policy action for various controller
actions.
This was supposed to be shown when deleting a form that is live, but due
to a typo (there is no method `Forms#live?` in forms-admin), it never
did get shown. However, it's also inaccurate, because currently we can't
delete just a draft, and deleting a live form does delete the whole
form.

I'm not sure when we'll be implementing deleting a draft form, so for
now let's just remove this content. When we do get around to making it
possible to delete a draft form the content may change anyway, but if it
doesn't we can always put the code back.
Refactor the forms delete confirmation controller to deal with forms
only, and move the code for deleting pages to the pages controller; it
is more idiomatic Rails to have the destroy and delete actions for a
model in the controller for that model.
@lfdebrux lfdebrux force-pushed the ldeb-refactor-page-delete branch from 84a9c3c to caba6b4 Compare December 9, 2024 13:42
@lfdebrux lfdebrux enabled auto-merge December 9, 2024 13:42
@lfdebrux lfdebrux merged commit 58ee663 into main Dec 9, 2024
4 checks passed
@lfdebrux lfdebrux deleted the ldeb-refactor-page-delete branch December 9, 2024 13:46
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.

2 participants