From 0ca39a82bace5eb8cda654ae7af6fb41e8118ec1 Mon Sep 17 00:00:00 2001
From: reesercollins <10563996+reesercollins@users.noreply.github.com>
Date: Fri, 4 Nov 2022 11:21:06 -0400
Subject: [PATCH 1/3] Added ability to certify entities with multiple values
---
superset-frontend/src/components/CertifiedBadge/index.tsx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/src/components/CertifiedBadge/index.tsx b/superset-frontend/src/components/CertifiedBadge/index.tsx
index 80581e6320d70..635cff4fa8b5f 100644
--- a/superset-frontend/src/components/CertifiedBadge/index.tsx
+++ b/superset-frontend/src/components/CertifiedBadge/index.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
-import { t, useTheme } from '@superset-ui/core';
+import { ensureIsArray, t, useTheme } from '@superset-ui/core';
import Icons, { IconType } from 'src/components/Icons';
import { Tooltip } from 'src/components/Tooltip';
@@ -41,7 +41,9 @@ function CertifiedBadge({
<>
{certifiedBy && (
- {t('Certified by %s', certifiedBy)}
+
+ {t('Certified by %s', ensureIsArray(certifiedBy).join(', '))}
+
)}
{details}
From dcf1f1cc8a2f6d5adf559ddca4e9560199eaea45 Mon Sep 17 00:00:00 2001
From: reesercollins <10563996+reesercollins@users.noreply.github.com>
Date: Fri, 4 Nov 2022 11:26:40 -0400
Subject: [PATCH 2/3] Update description text to reflect new feature
---
.../src/components/Datasource/DatasourceEditor.jsx | 2 +-
superset/connectors/sqla/views.py | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
index 3354d9d42122a..cfc826da6aa71 100644
--- a/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
+++ b/superset-frontend/src/components/Datasource/DatasourceEditor.jsx
@@ -905,7 +905,7 @@ class DatasourceEditor extends React.PureComponent {
description={t(
'Extra data to specify table metadata. Currently supports ' +
'metadata of the format: `{ "certification": { "certified_by": ' +
- '"Data Platform Team", "details": "This table is the source of truth." ' +
+ '["Data Platform Team", "Engineering Team"], "details": "This table is the source of truth." ' +
'}, "warning_markdown": "This is a warning." }`.',
)}
control={
diff --git a/superset/connectors/sqla/views.py b/superset/connectors/sqla/views.py
index 47e5f216d5647..c7b0271123924 100644
--- a/superset/connectors/sqla/views.py
+++ b/superset/connectors/sqla/views.py
@@ -144,7 +144,7 @@ class TableColumnInlineView(
"extra": utils.markdown(
"Extra data to specify column metadata. Currently supports "
'certification data of the format: `{ "certification": "certified_by": '
- '"Taylor Swift", "details": "This column is the source of truth." '
+ '["Taylor Swift", "Harry Styles"], "details": "This column is the source of truth." '
"} }`. This should be modified from the edit datasource model in "
"Explore to ensure correct formatting.",
True,
@@ -236,7 +236,7 @@ class SqlMetricInlineView(
"extra": utils.markdown(
"Extra data to specify metric metadata. Currently supports "
'metadata of the format: `{ "certification": { "certified_by": '
- '"Data Platform Team", "details": "This metric is the source of truth." '
+ '["Data Platform Team", "Engineering Team"], "details": "This metric is the source of truth." '
'}, "warning_markdown": "This is a warning." }`. This should be modified '
"from the edit datasource model in Explore to ensure correct formatting.",
True,
@@ -443,7 +443,7 @@ class TableModelView( # pylint: disable=too-many-ancestors
"extra": utils.markdown(
"Extra data to specify table metadata. Currently supports "
'metadata of the format: `{ "certification": { "certified_by": '
- '"Data Platform Team", "details": "This table is the source of truth." '
+ '["Data Platform Team", "Engineering Team"], "details": "This table is the source of truth." '
'}, "warning_markdown": "This is a warning." }`.',
True,
),
From 94282b7e35322fefd37df9a53152d37ec5edec7d Mon Sep 17 00:00:00 2001
From: reesercollins <10563996+reesercollins@users.noreply.github.com>
Date: Fri, 18 Nov 2022 11:46:31 -0500
Subject: [PATCH 3/3] Add tests for multiple certified by values
---
.../components/CertifiedBadge/CertifiedBadge.test.tsx | 9 +++++++++
.../src/components/CertifiedBadge/index.tsx | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx b/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx
index dd7ebb8bf9371..eb593be1607bc 100644
--- a/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx
+++ b/superset-frontend/src/components/CertifiedBadge/CertifiedBadge.test.tsx
@@ -39,6 +39,15 @@ test('renders with certified by', async () => {
expect(await screen.findByRole('tooltip')).toHaveTextContent(certifiedBy);
});
+test('renders with multiple certified by values', async () => {
+ const certifiedBy = ['Trusted Authority', 'Other Authority'];
+ render();
+ userEvent.hover(screen.getByRole('img'));
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ certifiedBy.join(', '),
+ );
+});
+
test('renders with details', async () => {
const details = 'All requirements have been met.';
render();
diff --git a/superset-frontend/src/components/CertifiedBadge/index.tsx b/superset-frontend/src/components/CertifiedBadge/index.tsx
index 635cff4fa8b5f..d2ef264c5dfb7 100644
--- a/superset-frontend/src/components/CertifiedBadge/index.tsx
+++ b/superset-frontend/src/components/CertifiedBadge/index.tsx
@@ -22,7 +22,7 @@ import Icons, { IconType } from 'src/components/Icons';
import { Tooltip } from 'src/components/Tooltip';
export interface CertifiedBadgeProps {
- certifiedBy?: string;
+ certifiedBy?: string | string[];
details?: string;
size?: IconType['iconSize'];
}