From e0f24ab1c042fa01d6b880f1d5103e91dfcd6cee Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Fri, 21 Oct 2022 09:39:03 -0300 Subject: [PATCH 1/2] chore: Improves D2D loading indicator --- .../Chart/DrillDetail/DrillDetailPane.tsx | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx index 7d2d572d12cee..9451cae5265d5 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx @@ -194,6 +194,12 @@ export default function DrillDetailPane({ resultsPages, ]); + // Get datasource metadata + const response = useApiV1Resource(`/api/v1/dataset/${datasourceId}`); + + const bootstrapping = + (!responseError && !resultsPages.size) || response.status === 'loading'; + let tableContent = null; if (responseError) { // Render error if page download failed @@ -206,7 +212,7 @@ export default function DrillDetailPane({ {responseError} ); - } else if (!resultsPages.size) { + } else if (bootstrapping) { // Render loading if first page hasn't loaded tableContent = ; } else if (resultsPage?.total === 0) { @@ -241,9 +247,6 @@ export default function DrillDetailPane({ ); } - // Get datasource metadata - const response = useApiV1Resource(`/api/v1/dataset/${datasourceId}`); - const metadata = useMemo(() => { const { status, result } = response; const items: ContentType[] = []; @@ -298,7 +301,6 @@ export default function DrillDetailPane({ margin-bottom: ${theme.gridUnit * 4}px; `} > - {status === 'loading' && } {status === 'complete' && } {status === 'error' && ( - {metadata} - + {!bootstrapping && metadata} + {!bootstrapping && ( + + )} {tableContent} ); From 2499fca90f6a010313c2d6ef59387c57364294fc Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Fri, 21 Oct 2022 11:24:21 -0300 Subject: [PATCH 2/2] Fixes test --- .../src/components/Chart/DrillDetail/DrillDetailPane.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.test.tsx b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.test.tsx index 45a342b5fca16..4b42c39da8bd1 100644 --- a/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.test.tsx +++ b/superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.test.tsx @@ -122,11 +122,11 @@ test('should render', async () => { expect(container).toBeInTheDocument(); }); -test('should render metadata and table loading indicators', async () => { +test('should render loading indicator', async () => { fetchWithData(); setup(); await waitFor(() => - expect(screen.getAllByLabelText('Loading').length).toBe(2), + expect(screen.getByLabelText('Loading')).toBeInTheDocument(), ); });