Open external links in new window by default
Signed-off-by: Deepak Bhardwaj <deepak.bhardwaj@outlook.com>
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user