11import { ClipboardButton } from '@gravity-ui/uikit' ;
2- import { skipToken } from '@reduxjs/toolkit/query' ;
32import JSONTree from 'react-json-inspector' ;
43import { shallowEqual } from 'react-redux' ;
54
65import { ResponseError } from '../../../../components/Errors/ResponseError' ;
76import { 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' ;
1011import type { EPathType } from '../../../../types/api/schema' ;
11- import type { IDescribeData } from '../../../../types/store/describe' ;
1212import { cn } from '../../../../utils/cn' ;
1313import { useAutoRefreshInterval , useTypedSelector } from '../../../../utils/hooks' ;
1414import { isEntityWithMergedImplementation } from '../../utils/schema' ;
@@ -26,8 +26,6 @@ interface IDescribeProps {
2626 type ?: EPathType ;
2727}
2828
29- const emptyObject : IDescribeData = { } ;
30-
3129const 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
0 commit comments