-
Notifications
You must be signed in to change notification settings - Fork 0
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
Download links target _blank and append UI marker #192
Conversation
Pull Request Test Coverage Report for Build 9224571738Details
💛 - Coveralls |
Why are these changes being introduced: * We want to display a message in our restricted CDN auth flow that instructs a user to close the window/tab when the download is complete to return to their search if they came from TIMDEX UI. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/GDT-317 * https://mitlibraries.atlassian.net/browse/GDT-304 How does this address that need: * Adds `target=_blank` to download link tags * appends `?timdex-ui=true` to download link URLs Document any side effects to this change: * A bunch of tests reformatted automatically on save. The only relevant changes to the tests were on lines 246-247
73b6440
to
a11558c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks good to me, and I've confirmed that the one relevant test makes sense with this change to the helper and the template. I do have a question about whether any of the URLs passing through this system already have querystrings - in which case I think more complex logic might be needed in the helper.
If that's not in our data (and isn't likely to be in the future), then I'm fine with all of this and will switch this to an approval.
app/helpers/record_helper.rb
Outdated
@@ -86,7 +86,8 @@ def gis_access_link(metadata) | |||
if access_type(metadata) == 'unknown: check with owning institution' | |||
links.select { |link| link['kind'] == 'Website' }.first['url'] | |||
else | |||
links.select { |link| link['kind'] == 'Download' && link['text'] == 'Data' }.first['url'] | |||
url = links.select { |link| link['kind'] == 'Download' && link['text'] == 'Data' }.first['url'] | |||
"#{url}?timdexui=true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only question is whether there's going to be any of these links that already have a querystring in them, which would result in something like
https://cdn.dev1.mitlibrary.net/geo/public/US_MA_P3STATIONS_2004.zip?foo=bar?timdexui=true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question, and I did think about this and decided that since these links should only be for resources in our buckets which should never have query strings in them this would be okay.
However, we could probably parse the URL and append the query string more safely without a ton of work. Let me look at what that would entail before moving forward.
A few complex lines were moved to their own methods to make reading the method a bit easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good - I appreciate having those additional helper methods in place here, because that would have been a lot to parse without them.
Why are these changes being introduced:
Relevant ticket(s):
How does this address that need:
target=_blank
to download link tags?timdex-ui=true
to download link URLsDocument any side effects to this change:
Developer
Accessibility
New ENV
Approval beyond code review
Additional context needed to review
The download links for restricted MIT downloads should now pop into a new window/tab. The messaging for the CDN auth app has not been updated to inform the user to close the window to return to the search, but that will be added soon.
All download links (restricted and not) should get
?timdexui=true
appended.Links to metadata or external sites should not be affected.
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing