Skip to content

Commit b1206e6

Browse files
committed
feat: drawer table scroll
1 parent 56d3db8 commit b1206e6

File tree

3 files changed

+103
-7
lines changed

3 files changed

+103
-7
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
};

src/containers/Tenant/Diagnostics/TopQueries/columns/columns.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import DataTable from '@gravity-ui/react-data-table';
22
import type {Column, OrderType} from '@gravity-ui/react-data-table';
33

4+
import {FixedHeightQuery} from '../../../../../components/FixedHeightQuery/FixedHeightQuery';
45
import {YDBSyntaxHighlighter} from '../../../../../components/SyntaxHighlighter/YDBSyntaxHighlighter';
5-
import {TruncatedQuery} from '../../../../../components/TruncatedQuery/TruncatedQuery';
66
import type {KeyValueRow} from '../../../../../types/api/query';
77
import {cn} from '../../../../../utils/cn';
88
import {formatDateTime, formatNumber} from '../../../../../utils/dataFormatters/dataFormatters';
99
import {generateHash} from '../../../../../utils/generateHash';
1010
import {formatToMs, parseUsToMs} from '../../../../../utils/timeParsers';
11-
import {MAX_QUERY_HEIGHT} from '../../../utils/constants';
1211

1312
import {
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,

0 commit comments

Comments
 (0)