Open external links in new window by default

Signed-off-by: Deepak Bhardwaj <deepak.bhardwaj@outlook.com>
This commit is contained in:
Deepak Bhardwaj
2021-07-01 19:09:03 +05:30
parent fbfc9e4d0f
commit 80b42d7137
3 changed files with 5 additions and 11 deletions
+3 -1
View File
@@ -1,5 +1,7 @@
---
'@backstage/core-components': patch
'@backstage/plugin-explore': patch
---
Enhanced tools card to open external tools in new tab
- Enhanced core `Button` component to open external links in new tab.
- Replaced the use of `Button` component from material by `core-components` in tools card.
@@ -29,7 +29,6 @@ export const isExternalUri = (uri: string) => /^([a-z+.-]+):/.test(uri);
export type LinkProps = MaterialLinkProps &
RouterLinkProps & {
component?: ElementType<any>;
externalLinkTarget?: undefined | '_blank';
};
/**
@@ -43,9 +42,7 @@ export const Link = React.forwardRef<any, LinkProps>((props, ref) => {
<MaterialLink
ref={ref}
href={to}
{...(props.externalLinkTarget
? { target: props.externalLinkTarget, rel: 'noopener' }
: {})}
{...{ target: '_blank', rel: 'noopener' }}
{...props}
/>
) : (
@@ -97,12 +97,7 @@ export const ToolCard = ({ card, objectFit }: Props) => {
)}
</CardContent>
<CardActions>
<Button
externalLinkTarget="_blank"
color="primary"
to={url}
disabled={!url}
>
<Button color="primary" to={url} disabled={!url}>
Explore
</Button>
</CardActions>