fix(viz-gallery): respect denylist in viz gallery (#22658)

This commit is contained in:
Ville Brofeldt
2023-01-10 19:08:30 +02:00
committed by GitHub
parent 1e3746be21
commit 08f45ef207
33 changed files with 111 additions and 123 deletions

View File

@@ -40,7 +40,7 @@ import {
} from '@superset-ui/plugin-chart-echarts';
import TableChartPlugin from '@superset-ui/plugin-chart-table';
import { LineChartPlugin } from '@superset-ui/preset-chart-xy';
import TimeTableChartPlugin from '../../../../visualizations/TimeTable';
import TimeTableChartPlugin from 'src/visualizations/TimeTable';
import VizTypeControl, { VIZ_TYPE_CONTROL_TEST_ID } from './index';
jest.useFakeTimers();

View File

@@ -50,6 +50,7 @@ interface VizTypeGalleryProps {
onDoubleClick: () => void;
selectedViz: string | null;
className?: string;
denyList: string[];
}
type VizEntry = {
@@ -506,6 +507,7 @@ export default function VizTypeGallery(props: VizTypeGalleryProps) {
const chartMetadata: VizEntry[] = useMemo(() => {
const result = Object.entries(mountedPluginMetadata)
.map(([key, value]) => ({ key, value }))
.filter(({ key }) => !props.denyList.includes(key))
.filter(
({ value }) =>
nativeFilterGate(value.behaviors || []) && !value.deprecated,

View File

@@ -27,6 +27,7 @@ import {
import { usePluginContext } from 'src/components/DynamicPlugins';
import Modal from 'src/components/Modal';
import { noOp } from 'src/utils/common';
import getBootstrapData from 'src/utils/getBootstrapData';
import VizTypeGallery, {
MAX_ADVISABLE_VIZ_GALLERY_WIDTH,
} from './VizTypeGallery';
@@ -41,6 +42,8 @@ interface VizTypeControlProps {
isModalOpenInit?: boolean;
}
const bootstrapData = getBootstrapData();
const denyList: string[] = bootstrapData.common.conf.VIZ_TYPE_DENYLIST || [];
const metadataRegistry = getChartMetadataRegistry();
export const VIZ_TYPE_CONTROL_TEST_ID = 'viz-type-control';
@@ -141,6 +144,7 @@ const VizTypeControl = ({
selectedViz={selectedViz}
onChange={setSelectedViz}
onDoubleClick={onSubmit}
denyList={denyList}
/>
</UnpaddedModal>
</>