[DSpace-CRIS] Download button & Allow authors to download restricted files#5132
[DSpace-CRIS] Download button & Allow authors to download restricted files#5132FrancescoMolinaro wants to merge 10 commits intoDSpace:mainfrom
Conversation
|
@FrancescoMolinaro : Same here, please specify in the PR description which DSpace-CRIS differences this PR implements/relates to. |
|
Hi @FrancescoMolinaro, |
|
@FrancescoMolinaro : Just to verify, does this PR require any backend PR? Or is it standalone? It's unclear to me whether this requires specific backend changes to work. |
|
Hi @tdonohue , sorry for missing to specify it, this PR is mainly a UI variant of the normal link and it is indeed standalone. |
|
@aprilherron General reminder for all new feature PRs currently under review: there is still a possibility of getting this into 10.0, in case you have the capacity to complete the review at the moment. Feature merge deadline will be Friday 3/27. Thank you! |
|
Review notes: Config syntaxFeature is enabled by default. Tests
|
|
Hi @aprilherron , thanks for the feedback, I have set the property as false by default so that the new layout will be optional. In addition I have also fixed the issue with the missing default download link and implemented some test to enforce the behavior, now it should work as expected, thanks again for the review. |
|
@aprilherron : If you can find time to rereview this (based on the updates), I'd appreciate it. Please also remember to explicitly give the PR a "+1" if you feel it's working well and ready to be merged. @FrancescoMolinaro : I've yet to review/test this, but we may want to consider enabling this by default if it accurately fixes #3384 (as that's a long standing accessibility/usability issue). That said, I'll try to give this a test tomorrow to see if this should be enabled by default. |
aprilherron
left a comment
There was a problem hiding this comment.
Bug in untyped-item view has been addressed. This PR looks good to be merged 👍
src/app/item-page/simple/item-types/untyped-item/untyped-item.component.html
Outdated
Show resolved
Hide resolved
|
@FrancescoMolinaro I ran some response time performance tests on your branch, because I recently worked on a similar area of the code (#5028). I found out that your new code runs much faster on larger page sizes with Could you maybe explain a bit what you are doing with this bitstream route guard, and if we could also use it for the 'normal' bitstream download links? Here is a diagram from my performance tests, so that you can see how much better the new feature performs: |
|
Hi @FrancescoMolinaro, |
|
@FrancescoMolinaro : Could you quickly rebase this PR? It appears to have gained merge conflicts after the merger of #5112 |
|
Hi @tinsch , thanks for the feedback much appreciated, the bitstream route guard is currently already active for all the downloads as it runs on the download page indipendently from the property showDownloadLinkAsAttachment. I believe that what makes the file-download-link.component.html slow to render on pages, is the template of the component itself, which creates many unnecessary subscriptions, creating the risk of memory leaks. I have made a commit to change this as I think is a good improvment in any case, you can check the last commit of this PR for confirmation on your tests, hopefully performaces will be better also with the property set to false. |
|
Thanks a lot! I will look into it and retest it 👍 |
tdonohue
left a comment
There was a problem hiding this comment.
@FrancescoMolinaro : I gave this a review and test today. Overall, it works, but I've found some issues in the code which I think need cleanup/correction (see inline below).
I also have a few basic questions here:
- I don't understand how to configure
advancedAttachmentRendering > metadatafields, as the examples provided inconfig.example.ymlseem to be invalid. - I also don't see how this PR is providing authors with the ability to download restricted files. Is that provided via a backend PR? If so, which backend PR does this feature require?
I have been able to verify that the basics of rendering bitstreams in a list with a download button works properly.
| showDownloadLinkAsAttachment: true | ||
| # Configuration for advanced attachment rendering in item pages. This controls how files are displayed when showDownloadLinkAsAttachment is enabled. | ||
| # Each configuration maps a bundle name to specific metadata fields that should be displayed alongside the file. | ||
| advancedAttachmentRendering: |
There was a problem hiding this comment.
The pagination setting appears to be missing from the examples here.
Also, I'd recommend the configuration in config.example.yml match the default configuration that you've set in default-app-config.ts. That makes it much easier for users to understand what the default configs are.
| - dc.title | ||
| - bundle: LICENSE | ||
| metadata: | ||
| - dc.rights |
There was a problem hiding this comment.
Why is the structure of these bundle and metadata configs so much different here then in default-app-config.ts? Are these settings correct?
| } from '../utils/empty.util'; | ||
|
|
||
|
|
||
| export const bitstreamDownloadRedirectGuard: CanActivateFn = ( |
There was a problem hiding this comment.
Please add code comments to describe the behavior of this new guard.
| * The actual security header will be set by the rest | ||
| */ | ||
| setCorsHeader() { | ||
| this.responseService.setHeader('Access-Control-Allow-Origin', '*'); |
There was a problem hiding this comment.
I want to understand why this is being set to a wildcard/asterisk. This can be a potential security flaw as it allows resources to be accessed by any domain (even untrusted ones).
Why do we need this to be set to an asterisk? Is there a way to instead set it to the UI's URL? As of #5276 it should now be possible to access the URL of the User Interface via the environment.ui.baseUrl setting. So, that might be a better value here, assuming it works as well.
|
|
||
| "cookies.consent.purpose.sharing": "Sharing", | ||
|
|
||
| "cris-layout.advanced-attachment.dc.title": "Name", |
There was a problem hiding this comment.
Could we consider changing all these new keys to start with layout instead of cris-layout? That way they'd match with the new layout configuration section where they are used.
| icon: fas fa-project-diagram | ||
| style: text-success | ||
| # If true the download link in item page will be rendered as an advanced attachment, the view can be then configured with the layout.advancedAttachmentRendering config | ||
| showDownloadLinkAsAttachment: true |
There was a problem hiding this comment.
@FrancescoMolinaro : One last note, this setting should match the default value in default-app-config.ts.
For now, I'd say maybe we should keep this disabled by default. However, if we receive positive feedback on the display, we can modify it at a later time.
Personally, I like the new look overall. But I do find displaying the same thumbnail twice on the Item page seems a bit odd. For example, with an Item with one bitstream, you see its thumbnail twice near the top of the page:
I ran the performance tests again, and the results are nearly the same now with and without the new |

References
Description
Add new way of rendering download link in item page, the new UI component can be activated via the config:
showDownloadLinkAsAttachment
inside the layout config in default.app.config.ts.
The metadata to be visualized in the attachment box are handled with a separated config param:
advancedAttachmentRendering
Which allows granural control on which information to show in the template.
In addition a new route guard has been added for the bitstream download path, so that we can check the authorization before loading the page and handle in advance eventual authorizations needed.
On the rest side the canDownload authorization feature will be enhanced to allow authors the download of restricted items.
Instructions for Reviewers
The new config has been set as true for the time being so that every link in item page will be displayed with the new component.
The positioning was also adapted from the left side of the page to the right one, so to use the wider space for the additional informations.
List of changes in this PR:
Add new UI component and related configs
Add new guard for bitsream download path
Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.