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

fix #3241: Configuring the URI link target #3322

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

IgorBaptist4
Copy link
Contributor

References

  • Fixes #3241
    Note: To reproduce the error, use DSpace version 8.

Description

Creation of a new method in the “metadata-uri-values” component to identify when the url link on the item's simplified page is internal or external and where it will open.

Instructions for Reviewers

A getLinkAttributes method has been created which receives the value of the item's url and compares this value with the repository's base url; if the values of the urls are the same, the method returns the following attributes {target: '_self', rel:' '} and the link is opened in the same browser tab. Otherwise, the method returns the attributes {target: '_blank', rel: 'noopener noreferrer'} and the link is opened in a new browser tab. In the end, this conditional was dynamically added to the template via [attr.target] and [attr.rel].

List of changes in this PR:

  • Creation of the “getLinkAttributes” method.
  • Removal of the static target=“_blank” attribute from the anchor that forms the url on the item's simplified page.
  • And adding the attributes “[attr.target]” and “[attr.rel]” to the same anchor.

To reproduce:

  1. Go to the simplified page for any item.
  2. Inside the page, click on the item's URI and see how the link behaves.

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!

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • 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.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • 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.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@tdonohue tdonohue added bug component: Item (Archived) Item display or editing port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release labels Sep 11, 2024
Copy link
Contributor

@nwoodward nwoodward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @IgorBaptist4! I tested this and confirmed it works. It's probably a good idea to add two tests for getLinkAttributes(urlValue), one with the environment.ui.baseUrl and one without to make sure the right target is returned.

@Andrea-Guevara
Copy link
Contributor

Good afternoon @nwoodward! Sorry for the delay in replying.

As you suggested, I've added new tests to the test file. One checks if the getLinkAttributes method returns the correct attributes for internal links and the other checks if the getLinkAttributes method returns the correct attributes for external links.

Any questions, I'm happy to help.

@nwoodward
Copy link
Contributor

Hi @Andrea-Guevara. Thank you for adding the tests! They look correct to me, and they pass when I run them. I'm not sure what the issue is with Codecov. Maybe someone with more knowledge about it could help us out. Thoughts, @tdonohue?

@tdonohue
Copy link
Member

@nwoodward and @Andrea-Guevara : The Codecov failure appears to be a false positive. Sometimes Codecov compares coverage percentages against the wrong prior commit (which seems to be the case here). Never been able to understand what causes it, but it occurs every now and then. Overall, this PR seems to have proper code coverage and Codecov is wrong.

@Andrea-Guevara
Copy link
Contributor

What a relief haha
Thank you so much @tdonohue

Copy link
Contributor

@nwoodward nwoodward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks @IgorBaptist4 and @Andrea-Guevara!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component: Item (Archived) Item display or editing port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release
Projects
Status: 👍 Reviewer Approved
Development

Successfully merging this pull request may close these issues.

URI link on simple item page always opens in a new page/tab
4 participants