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

Make "discard flash for xhr requests" a configurable behavior #1861

Closed
wants to merge 3 commits into from
Closed

Make "discard flash for xhr requests" a configurable behavior #1861

wants to merge 3 commits into from

Conversation

jgondron
Copy link
Contributor

@jgondron jgondron commented Apr 5, 2018

Blacklight will by default discard flash messages for XHR requests. This is not always desirable, in particular when an application is using Turbolinks and performs an XHR post-redirect-get, the client will follow the redirect but the flash messages are lost. This PR adds a few changes to make this configurable by the application. Summary of changes:

  • Added a "discard_flash_if_xhr" flag to the blacklight configuration. Added this config option both to the catalog_controller generator and lib/blacklight/configuration.rb to cover pre-existing applications
  • Blacklight::Controller will now check this flag before discarding the flash messages in the associated after_action method
  • Added a spec to more directly unit test the Blacklight::Controller module and added specs that test this discard behavior for the usual CRUD actions

Related: samvera/hyrax#2592

I'm targeting the 6.x branch for now, since this is what Hyrax uses. If this gets accepted I'll make a new PR for a related fix to master.

- Added a "discard_flash_if_xhr" flag to the blacklight configuration. Added this config option both to the catalog_controller generator and lib/blacklight/configuration.rb to cover pre-existing applications
- Blacklight::Controller will now check this flag before discarding the flash messages in the associated after_action method
- Added a spec to more directly unit test the Blacklight::Controller module and added specs that test this discard behavior for the usual CRUD actions
@coveralls
Copy link

coveralls commented Apr 5, 2018

Coverage Status

Coverage increased (+0.003%) to 94.426% when pulling 0a16f6e on jgondron:configurable-xhr-flash-handling into bf97ad0 on projectblacklight:release-6.x.

…removed in 7.x. Also moved the config check to the after_action binding so that apps that have this turned off will not get the deprecation warning.
@jgondron jgondron closed this Apr 9, 2018
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.

None yet

2 participants