From 99b0c9e744279da8397f76c17067ef0c5695fbb5 Mon Sep 17 00:00:00 2001
From: fuzmish <71511927+fuzmish@users.noreply.github.com>
Date: Tue, 8 Oct 2024 17:44:11 +0000
Subject: [PATCH 1/2] MINOR: open links in new tab in DataAssetsHeader
---
.../DataAssetsHeader.component.tsx | 8 ++++-
.../DataAssetsHeader.test.tsx | 33 ++++++++++++++++++-
.../ui/src/utils/DataAssetsHeader.utils.tsx | 7 ++++
3 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataAssets/DataAssetsHeader/DataAssetsHeader.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataAssets/DataAssetsHeader/DataAssetsHeader.component.tsx
index 41903907db34..8ebf9c75d90e 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/DataAssets/DataAssetsHeader/DataAssetsHeader.component.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/DataAssets/DataAssetsHeader/DataAssetsHeader.component.tsx
@@ -107,10 +107,12 @@ export const ExtraInfoLink = ({
label,
value,
href,
+ newTab = false,
}: {
label: string;
value: string | number;
href: string;
+ newTab?: boolean;
}) => (
<>
@@ -118,7 +120,11 @@ export const ExtraInfoLink = ({
{!isEmpty(label) && (
{`${label}: `}
)}
-
+
{value}{' '}
({
.mockImplementation(() => Promise.resolve({ name: 'test' })),
}));
+describe('ExtraInfoLink component', () => {
+ const mockProps = {
+ label: 'myLabel',
+ value: 'example',
+ href: 'http://example.com/',
+ };
+
+ it('should not have target and rel attributes when newTab is false (default)', () => {
+ const { container } = render();
+
+ const elm = container.querySelector('a');
+
+ expect(elm).toHaveAttribute('href', mockProps.href);
+ expect(elm).not.toHaveAttribute('target');
+ expect(elm).not.toHaveAttribute('rel');
+ });
+
+ it('should have target and rel attributes when newTab is true', () => {
+ const { container } = render();
+
+ const elm = container.querySelector('a');
+
+ expect(elm).toHaveAttribute('href', mockProps.href);
+ expect(elm).toHaveAttribute('target', '_blank');
+
+ const rel = (elm?.getAttribute('rel') || '').split(/\s+/g);
+
+ expect(rel.sort()).toStrictEqual(['noopener', 'noreferrer'].sort());
+ });
+});
+
describe('DataAssetsHeader component', () => {
it('should call getContainerByName API on Page load for container assets', () => {
const mockGetContainerByName = getContainerByName as jest.Mock;
diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx
index 613ce2955c79..3e0a51b84c11 100644
--- a/openmetadata-ui/src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx
@@ -105,6 +105,7 @@ export const getDataAssetsHeaderInfo = (
<>
{dashboardDetails.sourceUrl && (
{pipelineDetails.sourceUrl && (
{storedProcedureDetails.sourceUrl && (
{apiCollection.endpointURL && (
Date: Tue, 8 Oct 2024 18:43:28 +0000
Subject: [PATCH 2/2] fix: make mlModelDetail.dashboard internal link
---
.../src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx
index 3e0a51b84c11..0907319428ad 100644
--- a/openmetadata-ui/src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/utils/DataAssetsHeader.utils.tsx
@@ -188,7 +188,6 @@ export const getDataAssetsHeaderInfo = (
)}
{mlModelDetail.dashboard && (