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

Add warnings when deleting questions that are associated with routes #1663

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

lfdebrux
Copy link
Member

@lfdebrux lfdebrux commented Dec 11, 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've decided that we want to delete routes when a question is deleted, rather than leave the form in an invalid state.

As part of this we will show a notification banner about routes associated with the question to form creators when they are on the page to confirm that they want to delete a question. The content of the banner varies depending on the route associated; see the commits for details.

Note that currently the routes are not always actually deleted just yet, there needs to be a change to forms-api for that which is in alphagov/forms-api#654.

Screenshots

Warning if the question is the start of a "route 1" route

https://admin.dev.forms.service.gov.uk/forms/12788/pages/15016/delete

admin dev forms service gov uk_forms_12788_pages_15016_delete

Warning if the question is the end of a "route 1" route

https://admin.dev.forms.service.gov.uk/forms/12788/pages/15017/delete

admin dev forms service gov uk_forms_12788_pages_15017_delete

Warning if the question is the end of a "route 2" route

https://admin.dev.forms.service.gov.uk/forms/12788/pages/15018/delete

admin dev forms service gov uk_forms_12788_pages_15018_delete

Warning if the question is the start of a "route 2" route

https://admin.dev.forms.service.gov.uk/forms/12788/pages/15023/delete

admin dev forms service gov uk_forms_12788_pages_15023_delete

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-add-warning-when-deleting-page-with-routes branch 2 times, most recently from 0648d1a to bfa33bc Compare December 11, 2024 20:53
@thomasiles thomasiles force-pushed the ldeb-add-warning-when-deleting-page-with-routes branch from bfa33bc to 32089fe Compare December 16, 2024 09:54
@lfdebrux lfdebrux force-pushed the ldeb-add-warning-when-deleting-page-with-routes branch from 32089fe to 735ef5b Compare December 23, 2024 08:28
@lfdebrux lfdebrux force-pushed the ldeb-add-warning-when-deleting-page-with-routes branch 2 times, most recently from 5cc8521 to a09c4e9 Compare January 8, 2025 13:13
@lfdebrux lfdebrux marked this pull request as ready for review January 10, 2025 09:07
@lfdebrux lfdebrux force-pushed the ldeb-add-warning-when-deleting-page-with-routes branch 2 times, most recently from 3ee5b11 to 28b9617 Compare January 15, 2025 13:34
lfdebrux and others added 8 commits January 15, 2025 15:51
If the form resource object is not persisted then ActiveResource won't
make an API request if `form.pages` is accessed.
Move logic around routing from the view to the controller for the
page#delete action.

The main aim is to reduce the repetition of the notification banner
call in the view; to achieve this we rely on the consistency of the
content, where the warning refers to up to two different questions; the
question about to be deleted, and the question that "owns" the route
(which depends on the kind of route involved).

A future refactor might appropriately move this logic out of the
controller to a service, or maybe something more generally useful like a
model that expresses the relationships between conditions and routes,
but before that we need to make this view work with cases where the page
to be deleted is associated with more than two routes, so for now I
think this is a good place to stop.
@lfdebrux lfdebrux force-pushed the ldeb-add-warning-when-deleting-page-with-routes branch from 28b9617 to e45d4e3 Compare January 15, 2025 15:51

describe "when page to delete is not associated with any routes" do
it "does not render a notification banner" do
expect(rendered).not_to have_css "govuk-notification-banner"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is missing a dot which means it'll always pass:

Suggested change
expect(rendered).not_to have_css "govuk-notification-banner"
expect(rendered).not_to have_css ".govuk-notification-banner"

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