Skip to content
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