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: Federation portal button link #854

Merged
merged 2 commits into from
Nov 23, 2024

Conversation

Bilelkihal
Copy link
Collaborator

Fix: #853

Changes:

  • Fix federated portal button link of the current portal in browse page(5279023)
  • Make it open in the current tab (31a42da)

@Bilelkihal Bilelkihal self-assigned this Nov 19, 2024
@Bilelkihal Bilelkihal added the bug Something isn't working label Nov 19, 2024
Copy link
Collaborator Author

@Bilelkihal Bilelkihal left a comment

Choose a reason for hiding this comment

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

@@ -10,4 +11,8 @@ def initialize(name:, link:, color:, tooltip:, light_color:)
@color = color
@light_color = light_color
end

def internal?
!link?(@link)
Copy link
Collaborator

Choose a reason for hiding this comment

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

here it should be id.include?($REST_URL) , because logically this function does not make sense if you are unaware of the existence of ontoportal_ui_link hack.

Copy link
Collaborator Author

@Bilelkihal Bilelkihal Nov 19, 2024

Choose a reason for hiding this comment

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

I didn't got you well, what do you mean by ontoportal_ui_link hack?

Here basically, when a link is internal we pass it relative like this /ontologies/acronym and when it is external we pass it absolute like this https://data...
so the first one technically is not considered as a valid link this is why I used the function link?

Copy link
Collaborator

Choose a reason for hiding this comment

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

How do you enforce that internal we pass it relative like this /ontologies/acronym and when it is external we pass it absolute like this https://data... ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the external, no choice it should be absolute.
And for the internal onces, this is the practice that we have in all the app.
What is the case that you have in your mind and can break this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the external, yes.
For the internal, you did this

 def ontoportal_ui_link(id)
    if id.include?($REST_URL)
      return id.gsub($REST_URL,'')
    end

which says if I understood well, check if the given link includes the internal rest URL, and in this case remove it from it. So that you enforce that the internal link is not absolute, what I propose is to not have this code and just directly test if includes or not $REST_URL inside your new function internal?, with no need for any external expectation of absolute or relative URL.

And also I think that this function does that already https://github.com/ontoportal-lirmm/bioportal_web_ui/blob/master/app/helpers/federation_helper.rb#L65, but to test if does work in this case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did not substruct the $REST_URL only to use it inside the other component here.
If the url is internal the best practice is to use the relative one instead of the absolute.
And inside the component I built my logic based on that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed, ok

@syphax-bouazzouni syphax-bouazzouni merged commit df623f0 into development Nov 23, 2024
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants