committed by
Fredrik Adelöw
parent
b341771b91
commit
5e0879da2b
@@ -20,6 +20,7 @@ import DialogTitle from '@material-ui/core/DialogTitle';
|
||||
import { Button, DialogActions, DialogContent } from '@material-ui/core';
|
||||
import LinkIcon from '@material-ui/icons/Link';
|
||||
import { MarkdownContent } from '@backstage/core-components';
|
||||
import { isValidUrl } from '../../utils/components';
|
||||
|
||||
export type Props = {
|
||||
open: boolean;
|
||||
@@ -36,10 +37,8 @@ const RadarDescription = (props: Props): JSX.Element => {
|
||||
const handleClick = () => {
|
||||
onClose();
|
||||
if (urlTarget) {
|
||||
console.log('with target' + urlTarget)
|
||||
window.open(url, urlTarget);
|
||||
} else {
|
||||
console.log('no target' + urlTarget)
|
||||
window.location.href = url;
|
||||
}
|
||||
};
|
||||
@@ -52,7 +51,7 @@ const RadarDescription = (props: Props): JSX.Element => {
|
||||
<DialogContent dividers>
|
||||
<MarkdownContent content={description} />
|
||||
</DialogContent>
|
||||
{(url && url !== '#') && (
|
||||
{isValidUrl(url) && (
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={handleClick}
|
||||
|
||||
@@ -29,10 +29,14 @@ export const WithLink = ({
|
||||
className,
|
||||
children,
|
||||
}: WithLinkProps): JSX.Element =>
|
||||
(url && url!== '#') ? (
|
||||
isValidUrl(url) ? (
|
||||
<Link target={urlTarget} className={className} to={url}>
|
||||
{children}
|
||||
</Link>
|
||||
) : (
|
||||
<>{children}</>
|
||||
);
|
||||
|
||||
export const isValidUrl = (url: String) => {
|
||||
return (url && url !== '#' && url.length > 0)
|
||||
}
|
||||
Reference in New Issue
Block a user