Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Loading state when cols for drill by are loading #23830

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<Dataset>();
const [columns, setColumns] = useState<Column[]>([]);
Expand Down Expand Up @@ -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);
});
}
}, [
Expand Down Expand Up @@ -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 (
<Menu.Item key="drill-by-disabled" disabled {...rest}>
<div>
Expand Down Expand Up @@ -239,7 +242,15 @@ export const DrillByMenuItems = ({
`}
/>
)}
{filteredColumns.length ? (
{isLoadingColumns ? (
<div
css={css`
padding: ${theme.gridUnit * 3}px 0;
`}
>
<Loading position="inline-centered" />
</div>
) : filteredColumns.length ? (
<div
css={css`
max-height: ${MAX_SUBMENU_HEIGHT}px;
Expand Down