Skip to content

Commit d56790c

Browse files
authored
Merge branch 'main' into astandrik.display-a-list-of-operations-1414
2 parents 7f85b67 + 82531a5 commit d56790c

File tree

14 files changed

+185
-117
lines changed

14 files changed

+185
-117
lines changed

src/containers/Cluster/ClusterInfo/utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export const useGetVersionValues = (cluster?: TClusterInfo, versionToColor?: Ver
208208
? skipToken
209209
: {
210210
tablets: false,
211+
fieldsRequired: ['SystemState'],
211212
group: 'Version',
212213
},
213214
);

src/containers/Tenant/Diagnostics/Describe/Describe.tsx

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {ClipboardButton} from '@gravity-ui/uikit';
2-
import {skipToken} from '@reduxjs/toolkit/query';
32
import JSONTree from 'react-json-inspector';
43
import {shallowEqual} from 'react-redux';
54

65
import {ResponseError} from '../../../../components/Errors/ResponseError';
76
import {Loader} from '../../../../components/Loader';
8-
import {overviewApi} from '../../../../store/reducers/overview/overview';
9-
import {selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
7+
import {
8+
selectSchemaMergedChildrenPaths,
9+
useGetMultiOverviewQuery,
10+
} from '../../../../store/reducers/overview/overview';
1011
import type {EPathType} from '../../../../types/api/schema';
11-
import type {IDescribeData} from '../../../../types/store/describe';
1212
import {cn} from '../../../../utils/cn';
1313
import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks';
1414
import {isEntityWithMergedImplementation} from '../../utils/schema';
@@ -26,8 +26,6 @@ interface IDescribeProps {
2626
type?: EPathType;
2727
}
2828

29-
const emptyObject: IDescribeData = {};
30-
3129
const Describe = ({path, database, type}: IDescribeProps) => {
3230
const [autoRefreshInterval] = useAutoRefreshInterval();
3331

@@ -44,37 +42,20 @@ const Describe = ({path, database, type}: IDescribeProps) => {
4442
} else if (mergedChildrenPaths) {
4543
paths = [path, ...mergedChildrenPaths];
4644
}
47-
const {currentDescribe, currentData, isFetching, error} = overviewApi.useGetOverviewQuery(
48-
paths.length ? {paths, database} : skipToken,
49-
{
50-
pollingInterval: autoRefreshInterval,
51-
selectFromResult: (props) => {
52-
const {currentData} = props;
53-
if (!currentData) {
54-
return {currentDescribe: emptyObject, ...props};
55-
}
56-
57-
const mergedData = [currentData.data, ...currentData.additionalData];
5845

59-
const data = mergedData.reduce<IDescribeData>((acc, item) => {
60-
if (item?.Path) {
61-
acc[item.Path] = item;
62-
}
63-
return acc;
64-
}, {});
65-
return {currentDescribe: data, ...props};
66-
},
67-
},
68-
);
69-
const loading = isFetching && currentData === undefined;
46+
const {mergedDescribe, loading, error} = useGetMultiOverviewQuery({
47+
paths,
48+
autoRefreshInterval,
49+
database,
50+
});
7051

7152
let preparedDescribeData: Object | undefined;
72-
if (currentDescribe) {
73-
const paths = Object.keys(currentDescribe);
53+
if (mergedDescribe) {
54+
const paths = Object.keys(mergedDescribe);
7455
if (paths.length === 1) {
75-
preparedDescribeData = currentDescribe[paths[0]];
56+
preparedDescribeData = mergedDescribe[paths[0]];
7657
} else {
77-
preparedDescribeData = currentDescribe;
58+
preparedDescribeData = mergedDescribe;
7859
}
7960
}
8061

src/containers/Tenant/Diagnostics/HotKeys/HotKeys.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,15 @@ export function HotKeys({path, database}: HotKeysProps) {
6262
const {currentData: data, isFetching, error} = hotKeysApi.useGetHotKeysQuery({path, database});
6363
const loading = isFetching && data === undefined;
6464
const [autoRefreshInterval] = useAutoRefreshInterval();
65-
const {currentData, isLoading: schemaLoading} = overviewApi.useGetOverviewQuery(
65+
const {currentData: schemaData, isLoading: schemaLoading} = overviewApi.useGetOverviewQuery(
6666
{
67-
paths: [path],
67+
path,
6868
database,
6969
},
7070
{
7171
pollingInterval: autoRefreshInterval,
7272
},
7373
);
74-
const {data: schemaData} = currentData ?? {};
7574
const keyColumnsIds = schemaData?.PathDescription?.Table?.KeyColumnNames;
7675

7776
const tableColumns = React.useMemo(() => {

src/containers/Tenant/Diagnostics/Overview/Overview.tsx

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React from 'react';
22

3-
import {skipToken} from '@reduxjs/toolkit/query';
43
import {shallowEqual} from 'react-redux';
54

65
import {ResponseError} from '../../../../components/Errors/ResponseError';
76
import {TableIndexInfo} from '../../../../components/InfoViewer/schemaInfo';
87
import {Loader} from '../../../../components/Loader';
9-
import {overviewApi} from '../../../../store/reducers/overview/overview';
10-
import {selectSchemaMergedChildrenPaths} from '../../../../store/reducers/schema/schema';
8+
import {
9+
selectSchemaMergedChildrenPaths,
10+
useGetMultiOverviewQuery,
11+
} from '../../../../store/reducers/overview/overview';
1112
import {EPathType} from '../../../../types/api/schema';
1213
import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks';
1314
import {ExternalDataSourceInfo} from '../../Info/ExternalDataSource/ExternalDataSource';
@@ -45,16 +46,17 @@ function Overview({type, path, database}: OverviewProps) {
4546
}
4647

4748
const {
48-
currentData,
49-
isFetching,
50-
error: overviewError,
51-
} = overviewApi.useGetOverviewQuery(paths.length ? {paths, database} : skipToken, {
52-
pollingInterval: autoRefreshInterval,
49+
mergedDescribe,
50+
loading: entityLoading,
51+
error,
52+
} = useGetMultiOverviewQuery({
53+
paths,
54+
database,
55+
autoRefreshInterval,
5356
});
54-
const overviewLoading = isFetching && currentData === undefined;
55-
const {data: rawData, additionalData} = currentData || {};
5657

57-
const entityLoading = overviewLoading;
58+
const rawData = mergedDescribe[path];
59+
5860
const entityNotReady = isEntityWithMergedImpl && !mergedChildrenPaths;
5961

6062
const renderContent = () => {
@@ -70,14 +72,20 @@ function Overview({type, path, database}: OverviewProps) {
7072
[EPathType.EPathTypeExtSubDomain]: undefined,
7173
[EPathType.EPathTypeColumnStore]: undefined,
7274
[EPathType.EPathTypeColumnTable]: undefined,
73-
[EPathType.EPathTypeCdcStream]: () => (
74-
<ChangefeedInfo
75-
path={path}
76-
database={database}
77-
data={data}
78-
topic={additionalData?.[0] ?? undefined}
79-
/>
80-
),
75+
[EPathType.EPathTypeCdcStream]: () => {
76+
const topicPath = mergedChildrenPaths?.[0];
77+
if (topicPath) {
78+
return (
79+
<ChangefeedInfo
80+
path={path}
81+
database={database}
82+
data={data}
83+
topic={mergedDescribe?.[topicPath] ?? undefined}
84+
/>
85+
);
86+
}
87+
return undefined;
88+
},
8189
[EPathType.EPathTypePersQueueGroup]: () => (
8290
<TopicInfo data={data} path={path} database={database} />
8391
),
@@ -96,8 +104,8 @@ function Overview({type, path, database}: OverviewProps) {
96104

97105
return (
98106
<React.Fragment>
99-
{overviewError ? <ResponseError error={overviewError} /> : null}
100-
{overviewError && !rawData ? null : renderContent()}
107+
{error ? <ResponseError error={error} /> : null}
108+
{error && !rawData ? null : renderContent()}
101109
</React.Fragment>
102110
);
103111
}

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ export function TenantOverview({
4545

4646
const tenantType = mapDatabaseTypeToDBName(Type);
4747
// FIXME: remove after correct data is added to tenantInfo
48-
const {currentData} = overviewApi.useGetOverviewQuery(
48+
const {currentData: tenantSchemaData} = overviewApi.useGetOverviewQuery(
4949
{
50-
paths: [tenantName],
50+
path: tenantName,
5151
database: tenantName,
5252
},
5353
{
5454
pollingInterval: autoRefreshInterval,
5555
},
5656
);
57-
const {data: tenantSchemaData} = currentData ?? {};
5857
const {Tables, Topics} =
5958
tenantSchemaData?.PathDescription?.DomainDescription?.DiskSpaceUsage || {};
6059

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,15 @@ export function ObjectSummary({
9393
ignoreQueryPrefix: true,
9494
});
9595

96-
const {currentData} = overviewApi.useGetOverviewQuery(
96+
const {currentData: currentObjectData} = overviewApi.useGetOverviewQuery(
9797
{
98-
paths: [path],
98+
path,
9999
database: tenantName,
100100
},
101101
{
102102
pollingInterval: autoRefreshInterval,
103103
},
104104
);
105-
const {data: currentObjectData} = currentData ?? {};
106105
const currentSchemaData = currentObjectData?.PathDescription?.Self;
107106

108107
React.useEffect(() => {

src/containers/Tenant/Schema/SchemaViewer/SchemaViewer.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,16 @@ interface SchemaViewerProps {
3838

3939
export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaViewerProps) => {
4040
const [autoRefreshInterval] = useAutoRefreshInterval();
41-
const {currentData, isLoading: loading} = overviewApi.useGetOverviewQuery(
41+
const {currentData: schemaData, isLoading: loading} = overviewApi.useGetOverviewQuery(
4242
{
43-
paths: [path],
43+
path,
4444
database: tenantName,
4545
},
4646
{
4747
pollingInterval: autoRefreshInterval,
4848
},
4949
);
5050

51-
const {data: schemaData} = currentData ?? {};
52-
5351
const viewSchemaRequestParams = isViewType(type) ? {path, database: tenantName} : skipToken;
5452

5553
const {data: viewColumnsData, isLoading: isViewSchemaLoading} =

src/containers/Tenant/Tenant.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ export function Tenant(props: TenantProps) {
7575

7676
const path = schema ?? tenantName;
7777

78-
const {currentData, error, isLoading} = overviewApi.useGetOverviewQuery(
79-
{paths: [path], database: tenantName},
78+
const {
79+
currentData: currentItem,
80+
error,
81+
isLoading,
82+
} = overviewApi.useGetOverviewQuery(
83+
{path, database: tenantName},
8084
{
8185
pollingInterval: autoRefreshInterval,
8286
},
8387
);
84-
const {data: currentItem} = currentData ?? {};
8588
const {PathType: currentPathType, PathSubType: currentPathSubType} =
8689
currentItem?.PathDescription?.Self || {};
8790

src/containers/Versions/Versions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const Versions = ({versionToColor, cluster}: VersionsProps) => {
2929
const [autoRefreshInterval] = useAutoRefreshInterval();
3030
const versionsValues = useGetVersionValues(cluster, versionToColor);
3131
const {currentData, isLoading: isNodesLoading} = nodesApi.useGetNodesQuery(
32-
{tablets: false},
32+
{tablets: false, fieldsRequired: ['SystemState']},
3333
{pollingInterval: autoRefreshInterval},
3434
);
3535

src/containers/Versions/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const useGetVersionValues = (cluster?: TClusterInfo, versionToColor?: Ver
1414
? skipToken
1515
: {
1616
tablets: false,
17+
fieldsRequired: ['SystemState'],
1718
group: 'Version',
1819
},
1920
);

0 commit comments

Comments
 (0)