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

Display success banner when adding or removing access to an application (take 2) #3175

Merged
merged 5 commits into from
Sep 23, 2024

Conversation

Gweaton
Copy link
Contributor

@Gweaton Gweaton commented Sep 18, 2024

Trello card

Changes in this PR

This is (I feel) a neater, second attempt at #3171 with less complexity and is more easily extensible.

We previously displayed a success alert banner when one's own or another user's permissions were updated, but didn't show anything when granting access or removing it. We now display the same banner with different messaging when a user's access is granted or removed.

The API Users journey didn't need updating here, as we already show flash messages when an API token is created or revoked, as well as when permissions are updated.

Screenshots

Granting own access

image

Removing own access

image

Granting another user access

image

Removing another user's access

image

This application is owned by the publishing platform team. Please let us know in #govuk-publishing-platform when you raise any PRs.

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

Follow these steps if you are doing a Rails upgrade.

@Gweaton Gweaton changed the title Success banner 2 Display success banner when adding or removing access to an application (take 2) Sep 18, 2024
Copy link
Member

@yndajas yndajas 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!

app/views/account/applications/index.html.erb Outdated Show resolved Hide resolved
test/controllers/account/permissions_controller_test.rb Outdated Show resolved Hide resolved
test/support/updating_permissions_helpers.rb Show resolved Hide resolved
test/support/granting_access_helpers.rb Outdated Show resolved Hide resolved
This is set to the Success Alert's param called `description` rather
than `message`, so calling it `message` which is used for the header to
the banner is misleading.
This felt a bit much to take in, I find it a little more readable now.
We'll shortly be adding success alerts for adding and removing access,
so being able to pass in message and description in the controller makes
this simple.

We need to include `ActionView::Helpers::TagHelper` in the helper here
to make the `tag` method available to be called in controllers. We could
include it directly in the controller but including it in the helper
itself means we're less likely to forget this.

Unforunately we can't call `serialize` in the helper/controller as the
escaping is stripped out when it's serialized as JSON when stored as a
browser cookie. [1]

This same serialization is what converts symbols to strings, meaning we
also can't pass `flash[:success_alert]` to the Success Alert, as the
`message` and `description` keys are converted to strings to store in
the cookie, while the component expected an object with symbol keys.[2]

[1]: https://groups.google.com/g/rubyonrails-core/c/z52zgDgUmbs
[2]: bigbinary.com/blog/flash-access-changes-rails-4-1
@Gweaton Gweaton merged commit bd6cf2d into main Sep 23, 2024
15 checks passed
@Gweaton Gweaton deleted the success-banner-2 branch September 23, 2024 10:06
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