dspace-angular icon indicating copy to clipboard operation
dspace-angular copied to clipboard

Allow opening ds-metadata-uri-values links in a new window

Open kunovercammen opened this issue 1 year ago • 1 comments

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 linkTarget to 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.ts to verify the correct application of the linkTarget attribute 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.

kunovercammen avatar Mar 15 '24 12:03 kunovercammen

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.

alanorth avatar Mar 18 '24 05:03 alanorth

@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.

tdonohue avatar May 08 '24 19:05 tdonohue

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.

alanorth avatar May 09 '24 12:05 alanorth