Skip to content

Commit

Permalink
Added ability to certify entities with multiple values (#224)
Browse files Browse the repository at this point in the history
* Added ability to certify entities with multiple values

* Update description text to reflect new feature

* Add tests for multiple certified by values
  • Loading branch information
reesercollins committed Nov 24, 2022
1 parent 0635660 commit 0d5fee8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(<CertifiedBadge certifiedBy={certifiedBy} />);
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(<CertifiedBadge details={details} />);
Expand Down
8 changes: 5 additions & 3 deletions superset-frontend/src/components/CertifiedBadge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* 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';

export interface CertifiedBadgeProps {
certifiedBy?: string;
certifiedBy?: string | string[];
details?: string;
size?: IconType['iconSize'];
}
Expand All @@ -41,7 +41,9 @@ function CertifiedBadge({
<>
{certifiedBy && (
<div>
<strong>{t('Certified by %s', certifiedBy)}</strong>
<strong>
{t('Certified by %s', ensureIsArray(certifiedBy).join(', '))}
</strong>
</div>
)}
<div>{details}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down
6 changes: 3 additions & 3 deletions superset/connectors/sqla/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
),
Expand Down

0 comments on commit 0d5fee8

Please sign in to comment.