1
1
import React from 'react' ;
2
2
3
3
import type { ControlGroupOption } from '@gravity-ui/uikit' ;
4
- import { RadioButton , Tabs } from '@gravity-ui/uikit' ;
4
+ import { RadioButton , Tabs , Text } from '@gravity-ui/uikit' ;
5
5
import JSONTree from 'react-json-inspector' ;
6
6
7
7
import { ClipboardButton } from '../../../../components/ClipboardButton' ;
@@ -14,7 +14,7 @@ import {LoaderWrapper} from '../../../../components/LoaderWrapper/LoaderWrapper'
14
14
import { QueryExecutionStatus } from '../../../../components/QueryExecutionStatus' ;
15
15
import { QueryResultTable } from '../../../../components/QueryResultTable/QueryResultTable' ;
16
16
import { disableFullscreen } from '../../../../store/reducers/fullscreen' ;
17
- import type { ColumnType , KeyValueRow , TKqpStatsQuery } from '../../../../types/api/query' ;
17
+ import type { TKqpStatsQuery } from '../../../../types/api/query' ;
18
18
import type { ValueOf } from '../../../../types/common' ;
19
19
import type { ExecuteQueryResult } from '../../../../types/store/executeQuery' ;
20
20
import { getArray } from '../../../../utils' ;
@@ -74,8 +74,7 @@ export function ExecuteResult({
74
74
const stats : TKqpStatsQuery | undefined = data ?. stats ;
75
75
const resultsSetsCount = data ?. resultSets ?. length ;
76
76
const isMulti = resultsSetsCount && resultsSetsCount > 0 ;
77
- const currentResult = isMulti ? data ?. resultSets ?. [ selectedResultSet ] . result : data ?. result ;
78
- const currentColumns = isMulti ? data ?. resultSets ?. [ selectedResultSet ] . columns : data ?. columns ;
77
+ const currentResult = isMulti ? data ?. resultSets ?. [ selectedResultSet ] : data ;
79
78
const { plan, simplifiedPlan} = React . useMemo ( ( ) => getPlan ( data ) , [ data ] ) ;
80
79
81
80
const resultOptions : ControlGroupOption < SectionID > [ ] = [
@@ -104,13 +103,6 @@ export function ExecuteResult({
104
103
setActiveSection ( value ) ;
105
104
} ;
106
105
107
- const renderResultTable = (
108
- resultSet : KeyValueRow [ ] | undefined ,
109
- columns : ColumnType [ ] | undefined ,
110
- ) => {
111
- return < QueryResultTable data = { resultSet } columns = { columns } settings = { { sortable : false } } /> ;
112
- } ;
113
-
114
106
const renderResult = ( ) => {
115
107
return (
116
108
< div className = { b ( 'result-wrapper' ) } >
@@ -121,15 +113,29 @@ export function ExecuteResult({
121
113
size = "l"
122
114
items = { getArray ( resultsSetsCount ) . map ( ( item ) => ( {
123
115
id : String ( item ) ,
124
- title : `Result #${ item + 1 } ` ,
116
+ title : `Result #${ item + 1 } ${ data ?. resultSets ?. [ item ] ?. truncated ? ' (T)' : '' } ` ,
125
117
} ) ) }
126
118
activeTab = { String ( selectedResultSet ) }
127
119
onSelectTab = { ( tabId ) => setSelectedResultSet ( Number ( tabId ) ) }
128
120
/>
129
121
</ div >
130
122
) }
131
123
< div className = { b ( 'result' ) } >
132
- { renderResultTable ( currentResult , currentColumns ) }
124
+ { currentResult ?. truncated ? (
125
+ < div className = { b ( 'result-head' ) } >
126
+ < Text variant = "subheader-3" > { i18n ( 'truncated' ) } </ Text >
127
+ < Text
128
+ color = "secondary"
129
+ variant = "body-2"
130
+ className = { b ( 'row-count' ) }
131
+ > { `(${ currentResult ?. result ?. length } )` } </ Text >
132
+ </ div >
133
+ ) : null }
134
+ < QueryResultTable
135
+ data = { currentResult ?. result }
136
+ columns = { currentResult ?. columns }
137
+ settings = { { sortable : false } }
138
+ />
133
139
</ div >
134
140
</ div >
135
141
) ;
@@ -138,7 +144,7 @@ export function ExecuteResult({
138
144
const getStatsToCopy = ( ) => {
139
145
switch ( activeSection ) {
140
146
case resultOptionsIds . result : {
141
- const textResults = getPreparedResult ( currentResult ) ;
147
+ const textResults = getPreparedResult ( currentResult ?. result ) ;
142
148
return textResults ;
143
149
}
144
150
case resultOptionsIds . stats :
0 commit comments