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(ShemaViewer): show loader correctly #2019

Merged
merged 2 commits into from
Mar 19, 2025
Merged
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
31 changes: 17 additions & 14 deletions src/containers/Tenant/Schema/SchemaViewer/SchemaViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';

import {skipToken} from '@reduxjs/toolkit/query';

import {ResizeableDataTable} from '../../../../components/ResizeableDataTable/ResizeableDataTable';
import {TableSkeleton} from '../../../../components/TableSkeleton/TableSkeleton';
import {overviewApi} from '../../../../store/reducers/overview/overview';
Expand Down Expand Up @@ -42,23 +40,28 @@ export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaV
// Refresh table only in Diagnostics
const pollingInterval = extended ? autoRefreshInterval : undefined;

const {currentData: schemaData, isLoading: loading} = overviewApi.useGetOverviewQuery(
{path, database: tenantName},
{pollingInterval},
);

const viewSchemaRequestParams = isViewType(type) ? {path, database: tenantName} : skipToken;

const {data: viewColumnsData, isLoading: isViewSchemaLoading} =
viewSchemaApi.useGetViewSchemaQuery(viewSchemaRequestParams, {pollingInterval});
const {currentData: tableSchemaData, isFetching: isTableSchemaFetching} =
overviewApi.useGetOverviewQuery(
{path, database: tenantName},
{pollingInterval, skip: isViewType(type)},
);
const {currentData: viewColumnsData, isFetching: isViewSchemaFetching} =
viewSchemaApi.useGetViewSchemaQuery(
{path, database: tenantName},
{pollingInterval, skip: !isViewType(type)},
);

const loading =
(isViewSchemaFetching && viewColumnsData === undefined) ||
(isTableSchemaFetching && tableSchemaData === undefined);
Comment on lines +54 to +56
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isLoading isn't set to true when path changes, so we don't see loader on schema object change


const tableData = React.useMemo(() => {
if (isViewType(type)) {
return prepareViewSchema(viewColumnsData);
}

return prepareSchemaData(type, schemaData);
}, [schemaData, type, viewColumnsData]);
return prepareSchemaData(type, tableSchemaData);
}, [tableSchemaData, type, viewColumnsData]);

const hasAutoIncrement = React.useMemo(() => {
return tableData.some((i) => i.autoIncrement);
Expand All @@ -85,7 +88,7 @@ export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaV
return [];
}, [type, extended, hasAutoIncrement, hasDefaultValue, tableData]);

if (loading || isViewSchemaLoading) {
if (loading) {
return <TableSkeleton />;
}

Expand Down
Loading