diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.test.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.test.tsx index 7d411e050bea2..485e19652cdd2 100644 --- a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.test.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.test.tsx @@ -140,7 +140,8 @@ test('render disabled menu item for supported chart, no columns', async () => { fetchMock.get(DATASET_ENDPOINT, { result: { columns: [] } }); renderMenu({}); await waitFor(() => fetchMock.called(DATASET_ENDPOINT)); - await expectDrillByDisabled('No dimensions available for drill by'); + await expectDrillByEnabled(); + screen.getByText('No columns found'); }); test('render menu item with submenu without searchbox', async () => { diff --git a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx index 17e013d29f1ff..c5d7aac7a7d7c 100644 --- a/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/DrillByMenuItems.tsx @@ -40,6 +40,7 @@ import { import Icons from 'src/components/Icons'; import { Input } from 'src/components/Input'; import { useToasts } from 'src/components/MessageToasts/withToasts'; +import Loading from 'src/components/Loading'; import { cachedSupersetGet, supersetGetCache, @@ -78,6 +79,7 @@ export const DrillByMenuItems = ({ }: DrillByMenuItemsProps) => { const theme = useTheme(); const { addDangerToast } = useToasts(); + const [isLoadingColumns, setIsLoadingColumns] = useState(true); const [searchInput, setSearchInput] = useState(''); const [dataset, setDataset] = useState(); const [columns, setColumns] = useState([]); @@ -143,6 +145,9 @@ export const DrillByMenuItems = ({ .catch(() => { supersetGetCache.delete(`/api/v1/dataset/${datasetId}`); addDangerToast(t('Failed to load dimensions for drill by')); + }) + .finally(() => { + setIsLoadingColumns(false); }); } }, [ @@ -190,11 +195,9 @@ export const DrillByMenuItems = ({ tooltip = t('Drill by is not yet supported for this chart type'); } else if (!hasDrillBy) { tooltip = t('Drill by is not available for this data point'); - } else if (columns.length === 0) { - tooltip = t('No dimensions available for drill by'); } - if (!handlesDimensionContextMenu || !hasDrillBy || columns.length === 0) { + if (!handlesDimensionContextMenu || !hasDrillBy) { return (
@@ -239,7 +242,15 @@ export const DrillByMenuItems = ({ `} /> )} - {filteredColumns.length ? ( + {isLoadingColumns ? ( +
+ +
+ ) : filteredColumns.length ? (