1
- import React from 'react' ;
2
-
1
+ import { Code , Link , Xmark } from '@gravity-ui/icons' ;
3
2
import { Button , Icon } from '@gravity-ui/uikit' ;
4
3
4
+ import EnableFullscreenButton from '../../../../components/EnableFullscreenButton/EnableFullscreenButton' ;
5
+ import Fullscreen from '../../../../components/Fullscreen/Fullscreen' ;
5
6
import type { InfoViewerItem } from '../../../../components/InfoViewer' ;
6
7
import { InfoViewer } from '../../../../components/InfoViewer' ;
7
8
import { YDBSyntaxHighlighter } from '../../../../components/SyntaxHighlighter/YDBSyntaxHighlighter' ;
8
- import type { KeyValueRow } from '../../../../types/api/query' ;
9
9
import { cn } from '../../../../utils/cn' ;
10
- import { formatDateTime , formatNumber } from '../../../../utils/dataFormatters/dataFormatters' ;
11
- import { generateHash } from '../../../../utils/generateHash' ;
12
- import { formatToMs , parseUsToMs } from '../../../../utils/timeParsers' ;
13
10
14
11
import i18n from './i18n' ;
15
12
@@ -18,77 +15,60 @@ import './QueryDetails.scss';
18
15
const b = cn ( 'kv-query-details' ) ;
19
16
20
17
interface QueryDetailsProps {
21
- row : KeyValueRow ;
18
+ queryText : string ;
19
+ infoItems : InfoViewerItem [ ] ;
22
20
onClose : ( ) => void ;
23
21
onOpenInEditor : ( ) => void ;
24
22
}
25
23
26
- export const QueryDetails = ( { row, onClose, onOpenInEditor} : QueryDetailsProps ) => {
27
- const query = row . QueryText as string ;
28
- // Create info items for the InfoViewer with formatting matching the columns
29
- const infoItems : InfoViewerItem [ ] = React . useMemo ( ( ) => {
30
- return [
31
- { label : i18n ( 'query-details.query-hash' ) , value : generateHash ( String ( row . QueryText ) ) } ,
32
- {
33
- label : i18n ( 'query-details.cpu-time' ) ,
34
- value : formatToMs ( parseUsToMs ( row . CPUTimeUs ?? undefined ) ) ,
35
- } ,
36
- {
37
- label : i18n ( 'query-details.duration' ) ,
38
- value : formatToMs ( parseUsToMs ( row . Duration ?? undefined ) ) ,
39
- } ,
40
- { label : i18n ( 'query-details.read-bytes' ) , value : formatNumber ( row . ReadBytes ) } ,
41
- { label : i18n ( 'query-details.request-units' ) , value : formatNumber ( row . RequestUnits ) } ,
42
- {
43
- label : i18n ( 'query-details.end-time' ) ,
44
- value : row . EndTime
45
- ? formatDateTime ( new Date ( row . EndTime as string ) . getTime ( ) )
46
- : '–' ,
47
- } ,
48
- { label : i18n ( 'query-details.read-rows' ) , value : formatNumber ( row . ReadRows ) } ,
49
- { label : i18n ( 'query-details.user-sid' ) , value : row . UserSID || '–' } ,
50
- { label : i18n ( 'query-details.application-name' ) , value : row . ApplicationName || '–' } ,
51
- {
52
- label : i18n ( 'query-details.query-start-at' ) ,
53
- value : row . QueryStartAt
54
- ? formatDateTime ( new Date ( row . QueryStartAt as string ) . getTime ( ) )
55
- : '–' ,
56
- } ,
57
- ] ;
58
- } , [ row ] ) ;
59
-
24
+ export const QueryDetails = ( {
25
+ queryText,
26
+ infoItems,
27
+ onClose,
28
+ onOpenInEditor,
29
+ } : QueryDetailsProps ) => {
60
30
return (
61
31
< div className = { b ( ) } >
62
32
< div className = { b ( 'header' ) } >
63
33
< div className = { b ( 'title' ) } > Query</ div >
64
34
< div className = { b ( 'actions' ) } >
65
- < Button view = "flat" size = "l" onClick = { onClose } className = { b ( 'close-button' ) } >
66
- < Icon data = "close" size = { 16 } />
35
+ < Button view = "flat-secondary" onClick = { onClose } >
36
+ < Icon data = { Link } size = { 16 } />
37
+ </ Button >
38
+ < EnableFullscreenButton />
39
+ < Button view = "flat-secondary" onClick = { onClose } >
40
+ < Icon data = { Xmark } size = { 16 } />
67
41
</ Button >
68
42
</ div >
69
43
</ div >
70
44
71
- < div className = { b ( 'content' ) } >
72
- < InfoViewer info = { infoItems } />
45
+ < Fullscreen >
46
+ < div className = { b ( 'content' ) } >
47
+ < InfoViewer info = { infoItems } />
73
48
74
- < div className = { b ( 'query-section' ) } >
75
- < div className = { b ( 'query-header' ) } >
76
- < div className = { b ( 'query-title' ) } > { i18n ( 'query-details.query.title' ) } </ div >
77
- < Button
78
- view = "flat"
79
- size = "m"
80
- onClick = { onOpenInEditor }
81
- className = { b ( 'editor-button' ) }
82
- >
83
- < Icon data = "code" size = { 16 } />
84
- { i18n ( 'query-details.open-in-editor' ) }
85
- </ Button >
86
- </ div >
87
49
< div className = { b ( 'query-content' ) } >
88
- < YDBSyntaxHighlighter language = "yql" text = { query } withClipboardButton />
50
+ < div className = { b ( 'query-header' ) } >
51
+ < div className = { b ( 'query-title' ) } >
52
+ { i18n ( 'query-details.query.title' ) }
53
+ </ div >
54
+ < Button
55
+ view = "flat-secondary"
56
+ size = "m"
57
+ onClick = { onOpenInEditor }
58
+ className = { b ( 'editor-button' ) }
59
+ >
60
+ < Icon data = { Code } size = { 16 } />
61
+ { i18n ( 'query-details.open-in-editor' ) }
62
+ </ Button >
63
+ </ div >
64
+ < YDBSyntaxHighlighter
65
+ language = "yql"
66
+ text = { queryText }
67
+ withClipboardButton = { { alwaysVisible : true , withLabel : false } }
68
+ />
89
69
</ div >
90
70
</ div >
91
- </ div >
71
+ </ Fullscreen >
92
72
</ div >
93
73
) ;
94
74
} ;
0 commit comments