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

chore: Improves D2D loading indicator #21908

Merged
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 @@ -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(),
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ export default function DrillDetailPane({
resultsPages,
]);

// Get datasource metadata
const response = useApiV1Resource<Dataset>(`/api/v1/dataset/${datasourceId}`);

const bootstrapping =
(!responseError && !resultsPages.size) || response.status === 'loading';

let tableContent = null;
if (responseError) {
// Render error if page download failed
Expand All @@ -206,7 +212,7 @@ export default function DrillDetailPane({
{responseError}
</pre>
);
} else if (!resultsPages.size) {
} else if (bootstrapping) {
// Render loading if first page hasn't loaded
tableContent = <Loading />;
} else if (resultsPage?.total === 0) {
Expand Down Expand Up @@ -241,9 +247,6 @@ export default function DrillDetailPane({
);
}

// Get datasource metadata
const response = useApiV1Resource<Dataset>(`/api/v1/dataset/${datasourceId}`);

const metadata = useMemo(() => {
const { status, result } = response;
const items: ContentType[] = [];
Expand Down Expand Up @@ -298,7 +301,6 @@ export default function DrillDetailPane({
margin-bottom: ${theme.gridUnit * 4}px;
`}
>
{status === 'loading' && <Loading position="inline-centered" />}
{status === 'complete' && <MetadataBar items={items} />}
{status === 'error' && (
<Alert
Expand All @@ -312,14 +314,16 @@ export default function DrillDetailPane({

return (
<>
{metadata}
<TableControls
filters={filters}
setFilters={setFilters}
totalCount={resultsPage?.total}
loading={isLoading}
onReload={handleReload}
/>
{!bootstrapping && metadata}
{!bootstrapping && (
<TableControls
filters={filters}
setFilters={setFilters}
totalCount={resultsPage?.total}
loading={isLoading}
onReload={handleReload}
/>
)}
{tableContent}
</>
);
Expand Down