-
Notifications
You must be signed in to change notification settings - Fork 12
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 widget link issues #91
base: master
Are you sure you want to change the base?
Conversation
@@ -62,6 +64,14 @@ const GridTile = ({ widgetType, isDragging, setIsDragging, setWidgetAttribute, w | |||
return null; | |||
} | |||
|
|||
const widgetLink = (href: string) => { | |||
if (href.includes('https://')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a better way to check if the href is an external link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not reliable. We use a isExternal
prop in our links to determine if a link is external. Configuration is responsible for marking external links.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing an isExternal
prop being passed down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think exists yet in the widgets. But its a pattern all across the platform.
@@ -192,7 +202,8 @@ const GridTile = ({ widgetType, isDragging, setIsDragging, setWidgetAttribute, w | |||
<Button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use react-router-dom
Links when we are not opening new tabs and staying in HCC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@Hyperkid123 @InsaneZein Styling looks fine now |
if (href.includes('https://')) { | ||
return href; | ||
} else { | ||
return `${window.location.origin}${chrome.isBeta() ? '/preview' : ''}${href}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to add origin or the preview partial to router links. That is handled via the component.
{headerLink.title} | ||
</Button> | ||
{headerLink.href && ( | ||
<Link to={widgetLink(headerLink.href)}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't mix client-side routing with classic HTML routing. You have to pick a link component based on what the target is.
// for origin console.redhat.com
const href = https://www.google.com/
<Link to={href}>...</Link>
// actual link: console.redhat.com/https://www.google.com/
You have to decide which type of a link you are supposed to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand. Do I pick a different routing component based on whether its external or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. For external links, you use the plain HTML tags.
@@ -62,6 +64,14 @@ const GridTile = ({ widgetType, isDragging, setIsDragging, setWidgetAttribute, w | |||
return null; | |||
} | |||
|
|||
const widgetLink = (href: string) => { | |||
if (href.includes('https://')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not reliable. We use a isExternal
prop in our links to determine if a link is external. Configuration is responsible for marking external links.
PR has still some code issues to be addressed.
@Hyperkid123 I'm not seeing an isExternal link prop passed anywhere. |
Description
Fixes RHCLOUD-32859
Screenshots
After:
Checklist ☑️