dspace-angular
dspace-angular copied to clipboard
Allow opening ds-metadata-uri-values links in a new window
References
- Fixes #2834
Description
This feature request proposes adding a new optional input parameter to the <ds-metadata-uri-values> component in order to specify the link target, allowing metadata links to open in a new window/tab.
Instructions for Reviewers
List of changes in this PR:
- Added a new optional input parameter
linkTargetto the<ds-metadata-uri-values>component. The default value of this parameter is_blank, this will make sure the link is opened in a new window/tab. - Added a test case in the
src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.spec.tsto verify the correct application of thelinkTargetattribute to metadata links.
How to test:
- Go to an item page, for example a publication
- Click on the link that's under the URI-title
- The link now opens in a new tab/window
Reason for changes: If the user clicks a link that leads away from DSpace, we want it to open in a new window.
Checklist
- [x] My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
- [x] My PR passes ESLint validation using
yarn lint - [x] My PR doesn't introduce circular dependencies (verified via
yarn check-circ-deps) - [x] My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
- [x] My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
- [x] If my PR includes new libraries/dependencies (in
package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation. - [x] If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
- [x] If my PR fixes an issue ticket, I've linked them together.
Thanks @kunovercammen. This patch works well for me on DSpace 7.6.1. Our repository has many metadata fields containing URLs that should be opened in a new window (for example DOIs and other URLs on external sites).
This is a very minor change, but I wonder if @tdonohue will allow it in dspace-7_x since it changes the existing behavior? In any case, the base branch should probably be changed to main and then the port to dspace-7_x tag should be added if Tim agrees.
@kunovercammen : This seems reasonable to me for both 7.x and main. However, I cannot get this PR to apply cleanly to the main branch. Could you please create a second PR which can be applied to main? That way this can be more easily tested for 8.x as well.
From reading the code in d46248e99be7383fe3308d37d1d77be56b81f427 it seems this same functionality was introduced as part of the COAR Notify support recently merged in main for DSpace 8.0-SNAPSHOT.
Edit: I have just tested on sandbox.dspace.org (DSpace 8.0-RC1) and external links use target=_blank by default. Therefore this patch is not necessary on main.
Merging this for DSpace 7.6.1 as I have already tested it and this is 1 APPROVAL. Thanks @kunovercammen.