@@ -2,39 +2,36 @@ import React from 'react';
22
33import type { ControlGroupOption } from '@gravity-ui/uikit' ;
44import { ClipboardButton , RadioButton , Tabs , Text } from '@gravity-ui/uikit' ;
5- import JSONTree from 'react-json-inspector' ;
65
76import Divider from '../../../../components/Divider/Divider' ;
87import ElapsedTime from '../../../../components/ElapsedTime/ElapsedTime' ;
98import EnableFullscreenButton from '../../../../components/EnableFullscreenButton/EnableFullscreenButton' ;
109import Fullscreen from '../../../../components/Fullscreen/Fullscreen' ;
11- import { YDBGraph } from '../../../../components/Graph/Graph' ;
1210import { LoaderWrapper } from '../../../../components/LoaderWrapper/LoaderWrapper' ;
1311import { QueryExecutionStatus } from '../../../../components/QueryExecutionStatus' ;
1412import { QueryResultTable } from '../../../../components/QueryResultTable/QueryResultTable' ;
1513import { disableFullscreen } from '../../../../store/reducers/fullscreen' ;
1614import type { QueryResult } from '../../../../store/reducers/query/types' ;
17- import type { TKqpStatsQuery } from '../../../../types/api/query' ;
1815import type { ValueOf } from '../../../../types/common' ;
1916import { getArray } from '../../../../utils' ;
2017import { cn } from '../../../../utils/cn' ;
2118import { USE_SHOW_PLAN_SVG_KEY } from '../../../../utils/constants' ;
2219import { getStringifiedData } from '../../../../utils/dataFormatters/dataFormatters' ;
2320import { useSetting , useTypedDispatch } from '../../../../utils/hooks' ;
24- import { parseQueryError } from '../../../../utils/query' ;
2521import { PaneVisibilityToggleButtons } from '../../utils/paneVisibilityToggleHelpers' ;
2622import { CancelQueryButton } from '../CancelQueryButton/CancelQueryButton' ;
27- import { SimplifiedPlan } from '../ExplainResult/components/SimplifiedPlan/SimplifiedPlan' ;
28- import { ResultIssues } from '../Issues/Issues' ;
2923import { QueryDuration } from '../QueryDuration/QueryDuration' ;
3024import { QuerySettingsBanner } from '../QuerySettingsBanner/QuerySettingsBanner' ;
3125import { getPreparedResult } from '../utils/getPreparedResult' ;
3226import { isQueryCancelledError } from '../utils/isQueryCancelledError' ;
3327
34- import { PlanToSvgButton } from './PlanToSvgButton' ;
35- import { TraceButton } from './TraceButton' ;
28+ import { Graph } from './components/Graph/Graph' ;
29+ import { PlanToSvgButton } from './components/PlanToSvgButton/PlanToSvgButton' ;
30+ import { QueryJSONViewer } from './components/QueryJSONViewer/QueryJSONViewer' ;
31+ import { QueryResultError } from './components/QueryResultError/QueryResultError' ;
32+ import { SimplifiedPlan } from './components/SimplifiedPlan/SimplifiedPlan' ;
33+ import { TraceButton } from './components/TraceButton/TraceButton' ;
3634import i18n from './i18n' ;
37- import { getPlan } from './utils' ;
3835
3936import './ExecuteResult.scss' ;
4037
@@ -71,18 +68,17 @@ export function ExecuteResult({
7168 const dispatch = useTypedDispatch ( ) ;
7269 const [ useShowPlanToSvg ] = useSetting < boolean > ( USE_SHOW_PLAN_SVG_KEY ) ;
7370
74- const { error, isLoading, queryId, data} = result ;
71+ const { error, isLoading, queryId, data = { } } = result ;
72+ const { preparedPlan, simplifiedPlan, stats} = data ;
7573
76- const stats : TKqpStatsQuery | undefined = data ?. stats ;
7774 const resultsSetsCount = data ?. resultSets ?. length || 0 ;
7875 const currentResult = data ?. resultSets ?. [ selectedResultSet ] ;
79- const { plan, simplifiedPlan} = React . useMemo ( ( ) => getPlan ( data ) , [ data ] ) ;
8076
8177 const resultOptions : ControlGroupOption < SectionID > [ ] = [
8278 { value : resultOptionsIds . result , content : i18n ( 'action.result' ) } ,
8379 { value : resultOptionsIds . stats , content : i18n ( 'action.stats' ) } ,
8480 ] ;
85- if ( plan ) {
81+ if ( preparedPlan ) {
8682 resultOptions . push ( { value : resultOptionsIds . schema , content : i18n ( 'action.schema' ) } ) ;
8783 }
8884 if ( simplifiedPlan ?. plan ) {
@@ -92,8 +88,6 @@ export function ExecuteResult({
9288 } ) ;
9389 }
9490
95- const parsedError = parseQueryError ( error ) ;
96-
9791 React . useEffect ( ( ) => {
9892 return ( ) => {
9993 dispatch ( disableFullscreen ( ) ) ;
@@ -177,69 +171,21 @@ export function ExecuteResult({
177171 ) ;
178172 } ;
179173
180- const renderStats = ( ) => {
181- return (
182- < div className = { b ( 'inspector' ) } >
183- < JSONTree
184- data = { stats }
185- isExpanded = { ( ) => true }
186- searchOptions = { {
187- debounceTime : 300 ,
188- } }
189- />
190- </ div >
191- ) ;
192- } ;
193-
194- const renderSchema = ( ) => {
195- const isEnoughDataForGraph = plan ?. links && plan ?. nodes && plan ?. nodes . length ;
196-
197- if ( ! isEnoughDataForGraph ) {
198- return i18n ( 'description.graph-is-not-supported' ) ;
199- }
200-
201- return (
202- < div className = { b ( 'explain-canvas-container' ) } >
203- < YDBGraph key = { theme } data = { plan } />
204- </ div >
205- ) ;
206- } ;
207-
208- const renderSimplified = ( ) => {
209- const { plan} = simplifiedPlan ?? { } ;
210- if ( ! plan ) {
211- return null ;
212- }
213- return < SimplifiedPlan plan = { plan } /> ;
214- } ;
215-
216- const renderIssues = ( ) => {
217- if ( ! parsedError ) {
218- return null ;
219- }
220-
221- if ( typeof parsedError === 'object' ) {
222- return < ResultIssues data = { parsedError } /> ;
223- }
224-
225- return < div className = { b ( 'error' ) } > { parsedError } </ div > ;
226- } ;
227-
228174 const renderResultSection = ( ) => {
229- if ( error && ! isQueryCancelledError ( error ) ) {
230- return renderIssues ( ) ;
175+ if ( error ) {
176+ return < QueryResultError error = { error } /> ;
231177 }
232178 if ( activeSection === resultOptionsIds . result ) {
233179 return renderResult ( ) ;
234180 }
235181 if ( activeSection === resultOptionsIds . stats ) {
236- return renderStats ( ) ;
182+ return < QueryJSONViewer data = { stats } /> ;
237183 }
238184 if ( activeSection === resultOptionsIds . schema ) {
239- return renderSchema ( ) ;
185+ return < Graph theme = { theme } explain = { preparedPlan } /> ;
240186 }
241- if ( activeSection === resultOptionsIds . simplified ) {
242- return renderSimplified ( ) ;
187+ if ( activeSection === resultOptionsIds . simplified && simplifiedPlan ?. plan ) {
188+ return < SimplifiedPlan plan = { simplifiedPlan . plan } /> ;
243189 }
244190
245191 return null ;
0 commit comments