Signed-off-by: Bruno Fuzetti Penso <bruno.penso@gmail.com>
This commit is contained in:
Bruno Fuzetti Penso
2021-12-10 11:07:13 -03:00
committed by Fredrik Adelöw
parent b341771b91
commit 5e0879da2b
2 changed files with 7 additions and 4 deletions
@@ -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}
+5 -1
View File
@@ -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)
}