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 email subscribe/unsubscribe flash messages #2271

Merged
merged 2 commits into from
Nov 12, 2021
Merged

Conversation

alex9smith
Copy link
Member

When a user completes the single page email subscribe or unsubscribe
journey they will be redirected to the page they were on with a message
in the account session flash.

Check for these messages in the flash and render the appropriate success
banner. The pages chosen for phase 1 and phase 2 of the rollout are
either publication or detailed_guide content types, so only add the
partial to these templates. In the future when we roll out to more pages
we can add the partial to the rest of the content types.

Also set the vary header to indicate to Fastly that the success
messages are different variations and should be cached and served
separately. The GovukPersonalisation::ControllerConcern handles this
for us but sets the header to vary on the full account session. This
would result in pages being cached per-user which isn't very helpful in
this case.

Instead, override the set_account_vary_header method to vary on the
flash message instead. The message content won't vary per user so this
will mean we only cache three versions of the page - one without a flash
message, one with the subscribed message and one with the unsubscribed
message.

Trello

Subscribe:
Screenshot 2021-11-05 at 15 50 45

Unsubscribe:
Screenshot 2021-11-05 at 15 52 32

@alex9smith alex9smith force-pushed the email-flash-message branch 2 times, most recently from 88b14fa to 142715c Compare November 8, 2021 10:39
@govuk-ci govuk-ci temporarily deployed to government-f-email-flas-plclaw November 8, 2021 10:39 Inactive
@govuk-ci govuk-ci temporarily deployed to government-f-email-flas-plclaw November 11, 2021 09:50 Inactive
@govuk-ci govuk-ci temporarily deployed to government-f-email-flas-plclaw November 11, 2021 10:10 Inactive
@govuk-ci govuk-ci temporarily deployed to government-f-email-flas-plclaw November 11, 2021 10:18 Inactive
@barrucadu
Copy link
Contributor

@alex9smith Can you rebase this so I can deploy the branch for testing?

@govuk-ci govuk-ci temporarily deployed to government-f-email-flas-plclaw November 11, 2021 10:44 Inactive
When a user subscribes or unsubscribes to a single page email
notification topic, they'll be redirected back to the content page with
a message in their account session flash. This message will be detected
and used to display the relevant success message on the page.

We need to set the vary header to indicate to Fastly that the success
messages are different variations and should be cached and served
separately. The `GovukPersonalisation::ControllerConcern` handles this
for us but sets the header to vary on the full account session. This
would result in pages being cached per-user which isn't very helpful in
this case.

Instead, override the `set_account_vary_header` method to vary on the
flash message instead. The message content won't vary per user so this
will mean we only cache three versions of the page - one without a flash
message, one with the subscribed message and one with the unsubscribed
message.
@govuk-ci govuk-ci temporarily deployed to government-f-email-flas-plclaw November 11, 2021 10:59 Inactive
@govuk-ci govuk-ci temporarily deployed to government-f-email-flas-plclaw November 11, 2021 11:04 Inactive
@alex9smith
Copy link
Member Author

@barrucadu should be good now

When a user completes the single page email subscribe or unsubscribe
journey they will be redirected to the page they were on with a message
in the account session flash.

Check for these messages in the flash and render the appropriate success
banner. The pages chosen for  phase 1 and phase 2 of the rollout are
either `publication` or `detailed_guide` content types, so only add the
partial to these templates. In the future when we roll out to more pages
we can add the partial to the rest of the content types.
@govuk-ci govuk-ci temporarily deployed to government-f-email-flas-plclaw November 11, 2021 14:28 Inactive
@alex9smith
Copy link
Member Author

I've fixed most of the spacing, column width and content changes requested from design review.

There is one outstanding which we are deciding to leave for now as it won't be a simple fix. On desktop only, there is a lot of extra spacing underneath the flash message banners:

image

This does not appear on mobile. To fix, we'll probably need to modify the component so it can take a custom margin_bottom argument, release the components gem, bump the version here then add in a custom margin to reduce the spacing.

Copy link
Contributor

@barrucadu barrucadu left a comment

Choose a reason for hiding this comment

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

Looks good to me (well, other than the extra spacing, but that's a separate issue)

@barrucadu barrucadu merged commit 9b50162 into main Nov 12, 2021
@barrucadu barrucadu deleted the email-flash-message branch November 12, 2021 09:30
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.

5 participants