From c09f9f8031a5b592bcf066e667b620ffe0f3aefe Mon Sep 17 00:00:00 2001 From: Joe Li Date: Mon, 14 Mar 2022 13:25:32 -0700 Subject: [PATCH] Revert "feat(viz-gallery): add 'feature' tag and fuzzy search weighting (#18662)" This reverts commit 7524e1e3c86f3de2b3b0343c3ec5efc0b345937a. --- .../src/chart/models/ChartMetadata.ts | 18 ++--- .../superset-ui-core/src/chart/types/Base.ts | 18 ----- .../VizTypeControl/VizTypeGallery.tsx | 73 +------------------ 3 files changed, 8 insertions(+), 101 deletions(-) diff --git a/superset-frontend/packages/superset-ui-core/src/chart/models/ChartMetadata.ts b/superset-frontend/packages/superset-ui-core/src/chart/models/ChartMetadata.ts index 1013eeee2d3b3..8b1c4590a3e92 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/models/ChartMetadata.ts +++ b/superset-frontend/packages/superset-ui-core/src/chart/models/ChartMetadata.ts @@ -17,7 +17,7 @@ * under the License. */ -import { Behavior, ChartLabel } from '../types/Base'; +import { Behavior } from '../types/Base'; interface LookupTable { [key: string]: boolean; @@ -40,13 +40,10 @@ export interface ChartMetadataConfig { thumbnail: string; useLegacyApi?: boolean; behaviors?: Behavior[]; + deprecated?: boolean; exampleGallery?: ExampleImage[]; tags?: string[]; category?: string | null; - label?: { - name?: ChartLabel; - description?: string; - } | null; } export default class ChartMetadata { @@ -74,17 +71,14 @@ export default class ChartMetadata { enableNoResults: boolean; + deprecated: boolean; + exampleGallery: ExampleImage[]; tags: string[]; category: string | null; - label?: { - name?: ChartLabel; - description?: string; - } | null; - constructor(config: ChartMetadataConfig) { const { name, @@ -98,10 +92,10 @@ export default class ChartMetadata { behaviors = [], datasourceCount = 1, enableNoResults = true, + deprecated = false, exampleGallery = [], tags = [], category = null, - label = null, } = config; this.name = name; @@ -124,10 +118,10 @@ export default class ChartMetadata { this.behaviors = behaviors; this.datasourceCount = datasourceCount; this.enableNoResults = enableNoResults; + this.deprecated = deprecated; this.exampleGallery = exampleGallery; this.tags = tags; this.category = category; - this.label = label; } canBeAnnotationType(type: string): boolean { diff --git a/superset-frontend/packages/superset-ui-core/src/chart/types/Base.ts b/superset-frontend/packages/superset-ui-core/src/chart/types/Base.ts index aad547ca2aa5d..a3fe0f70a3fa2 100644 --- a/superset-frontend/packages/superset-ui-core/src/chart/types/Base.ts +++ b/superset-frontend/packages/superset-ui-core/src/chart/types/Base.ts @@ -52,22 +52,4 @@ export interface PlainObject { [key: string]: any; } -export enum ChartLabel { - VERIFIED = 'VERIFIED', - DEPRECATED = 'DEPRECATED', - FEATURED = 'FEATURED', -} - -export const ChartLabelWeight = { - [ChartLabel.DEPRECATED]: { - weight: -0.1, - }, - [ChartLabel.VERIFIED]: { - weight: 0.2, - }, - [ChartLabel.FEATURED]: { - weight: 0.1, - }, -}; - export default {}; diff --git a/superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsx b/superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsx index dc7afacb6c082..7b9ada5d9d8cc 100644 --- a/superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsx +++ b/superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsx @@ -33,11 +33,8 @@ import { ChartMetadata, SupersetTheme, useTheme, - ChartLabel, - ChartLabelWeight, } from '@superset-ui/core'; import { AntdCollapse } from 'src/components'; -import { Tooltip } from 'src/components/Tooltip'; import { Input } from 'src/components/Input'; import Label from 'src/components/Label'; import { usePluginContext } from 'src/components/DynamicPlugins'; @@ -313,7 +310,6 @@ const Examples = styled.div` const thumbnailContainerCss = (theme: SupersetTheme) => css` cursor: pointer; width: ${theme.gridUnit * THUMBNAIL_GRID_UNITS}px; - position: relative; img { min-width: ${theme.gridUnit * THUMBNAIL_GRID_UNITS}px; @@ -337,38 +333,6 @@ const thumbnailContainerCss = (theme: SupersetTheme) => css` } `; -const HighlightLabel = styled.div` - ${({ theme }) => ` - border: 1px solid ${theme.colors.primary.dark1}; - box-sizing: border-box; - border-radius: ${theme.gridUnit}px; - background: ${theme.colors.grayscale.light5}; - line-height: ${theme.gridUnit * 2.5}px; - color: ${theme.colors.primary.dark1}; - font-size: ${theme.typography.sizes.s}px; - font-weight: ${theme.typography.weights.bold}; - text-align: center; - padding: ${theme.gridUnit * 0.5}px ${theme.gridUnit}px; - text-transform: uppercase; - cursor: pointer; - - div { - transform: scale(0.83,0.83); - } - `} -`; - -const ThumbnailLabelWrapper = styled.div` - position: absolute; - right: ${({ theme }) => theme.gridUnit}px; - top: ${({ theme }) => theme.gridUnit * 19}px; -`; - -const TitleLabelWrapper = styled.div` - display: inline-block !important; - margin-left: ${({ theme }) => theme.gridUnit * 2}px; -`; - function vizSortFactor(entry: VizEntry) { if (typesWithDefaultOrder.has(entry.key)) { return DEFAULT_ORDER.indexOf(entry.key); @@ -414,13 +378,6 @@ const Thumbnail: React.FC = ({ > {type.name} - {type.label?.name && ( - - -
{t(type.label?.name)}
-
-
- )} ); }; @@ -503,8 +460,7 @@ export default function VizTypeGallery(props: VizTypeGalleryProps) { .map(([key, value]) => ({ key, value })) .filter( ({ value }) => - nativeFilterGate(value.behaviors || []) && - value.label?.name !== ChartLabel.DEPRECATED, + nativeFilterGate(value.behaviors || []) && !value.deprecated, ); result.sort((a, b) => vizSortFactor(a) - vizSortFactor(b)); return result; @@ -589,18 +545,7 @@ export default function VizTypeGallery(props: VizTypeGalleryProps) { if (searchInputValue.trim() === '') { return []; } - return fuse - .search(searchInputValue) - .map(result => result.item) - .sort((a, b) => { - const aName = a.value?.label?.name; - const bName = b.value?.label?.name; - const aOrder = - aName && ChartLabelWeight[aName] ? ChartLabelWeight[aName].weight : 0; - const bOrder = - bName && ChartLabelWeight[bName] ? ChartLabelWeight[bName].weight : 0; - return bOrder - aOrder; - }); + return fuse.search(searchInputValue).map(result => result.item); }, [searchInputValue, fuse]); const focusSearch = useCallback(() => { @@ -794,23 +739,9 @@ export default function VizTypeGallery(props: VizTypeGalleryProps) { {selectedVizMetadata?.name} - {selectedVizMetadata?.label?.name && ( - - - -
{t(selectedVizMetadata.label?.name)}
-
-
-
- )}
{selectedVizMetadata?.tags.map(tag => (