File tree Expand file tree Collapse file tree 3 files changed +103
-7
lines changed
components/FixedHeightQuery
containers/Tenant/Diagnostics/TopQueries/columns Expand file tree Collapse file tree 3 files changed +103
-7
lines changed Original file line number Diff line number Diff line change 1+ .kv-fixed-height-query {
2+ position : relative ;
3+
4+ overflow : hidden ;
5+
6+ max-width : 100% ;
7+
8+ // Target the YDBSyntaxHighlighter wrapper
9+ > div {
10+ display : box ;
11+ -webkit-box-orient : vertical ;
12+ -webkit-line-clamp : var (--line-clamp , 4 );
13+ overflow : hidden ;
14+
15+ height : 100% ;
16+
17+ text-overflow : ellipsis ;
18+
19+ // Target the ReactSyntaxHighlighter pre element
20+ pre {
21+ display : flex !important ;
22+ overflow : hidden !important ;
23+ align-items : center !important ;
24+
25+ height : 100% !important ;
26+ margin : 0 !important ;
27+ padding : 8px !important ;
28+
29+ white-space : pre-wrap !important ;
30+ word-break : break-word !important ;
31+ }
32+
33+ // Target code elements within
34+ code {
35+ display : box !important ;
36+ -webkit-box-orient : vertical !important ;
37+ -webkit-line-clamp : var (--line-clamp , 4 ) !important ;
38+ overflow : hidden !important ;
39+
40+ white-space : pre-wrap !important ;
41+ text-overflow : ellipsis !important ;
42+ word-break : break-word !important ;
43+ }
44+ }
45+ }
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ import { cn } from '../../utils/cn' ;
4+ import { YDBSyntaxHighlighter } from '../SyntaxHighlighter/YDBSyntaxHighlighter' ;
5+
6+ import './FixedHeightQuery.scss' ;
7+
8+ const b = cn ( 'kv-fixed-height-query' ) ;
9+
10+ const FIXED_PADDING = 8 ;
11+ const LINE_HEIGHT = 20 ;
12+
13+ interface FixedHeightQueryProps {
14+ value ?: string ;
15+ lines ?: number ;
16+ hasClipboardButton ?: boolean ;
17+ clipboardButtonAlwaysVisible ?: boolean ;
18+ }
19+
20+ export const FixedHeightQuery = ( {
21+ value = '' ,
22+ lines = 4 ,
23+ hasClipboardButton,
24+ clipboardButtonAlwaysVisible,
25+ } : FixedHeightQueryProps ) => {
26+ const heightValue = `${ lines * LINE_HEIGHT + FIXED_PADDING } px` ;
27+
28+ // Remove empty lines from the beginning (lines with only whitespace are considered empty)
29+ const trimmedValue = value . replace ( / ^ ( \s * \n ) + / , '' ) ;
30+
31+ return (
32+ < div
33+ className = { b ( ) }
34+ style = {
35+ {
36+ height : heightValue ,
37+ '--line-clamp' : lines ,
38+ } as React . CSSProperties & { '--line-clamp' : number }
39+ }
40+ >
41+ < YDBSyntaxHighlighter
42+ language = "yql"
43+ text = { trimmedValue }
44+ withClipboardButton = {
45+ hasClipboardButton
46+ ? {
47+ alwaysVisible : clipboardButtonAlwaysVisible ,
48+ copyText : value ,
49+ withLabel : false ,
50+ }
51+ : false
52+ }
53+ />
54+ </ div >
55+ ) ;
56+ } ;
Original file line number Diff line number Diff line change 11import DataTable from '@gravity-ui/react-data-table' ;
22import type { Column , OrderType } from '@gravity-ui/react-data-table' ;
33
4+ import { FixedHeightQuery } from '../../../../../components/FixedHeightQuery/FixedHeightQuery' ;
45import { YDBSyntaxHighlighter } from '../../../../../components/SyntaxHighlighter/YDBSyntaxHighlighter' ;
5- import { TruncatedQuery } from '../../../../../components/TruncatedQuery/TruncatedQuery' ;
66import type { KeyValueRow } from '../../../../../types/api/query' ;
77import { cn } from '../../../../../utils/cn' ;
88import { formatDateTime , formatNumber } from '../../../../../utils/dataFormatters/dataFormatters' ;
99import { generateHash } from '../../../../../utils/generateHash' ;
1010import { formatToMs , parseUsToMs } from '../../../../../utils/timeParsers' ;
11- import { MAX_QUERY_HEIGHT } from '../../../utils/constants' ;
1211
1312import {
1413 QUERIES_COLUMNS_IDS ,
@@ -34,11 +33,7 @@ const queryTextColumn: Column<KeyValueRow> = {
3433 header : QUERIES_COLUMNS_TITLES . QueryText ,
3534 render : ( { row} ) => (
3635 < div className = { b ( 'query' ) } >
37- < TruncatedQuery
38- value = { row . QueryText ?. toString ( ) }
39- maxQueryHeight = { MAX_QUERY_HEIGHT }
40- hasClipboardButton
41- />
36+ < FixedHeightQuery value = { row . QueryText ?. toString ( ) } lines = { 4 } hasClipboardButton />
4237 </ div >
4338 ) ,
4439 width : 500 ,
You can’t perform that action at this time.
0 commit comments