Skip to content

Commit 78af278

Browse files
committed
fix: review
1 parent 295a87f commit 78af278

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed

src/components/FixedHeightQuery/FixedHeightQuery.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,36 @@ const b = cn('ydb-fixed-height-query');
1010
const FIXED_PADDING = 8;
1111
const LINE_HEIGHT = 20;
1212

13+
type FixedHeightQueryMode = 'fixed' | 'max';
14+
1315
interface FixedHeightQueryProps {
1416
value?: string;
1517
lines?: number;
1618
hasClipboardButton?: boolean;
1719
clipboardButtonAlwaysVisible?: boolean;
20+
mode?: FixedHeightQueryMode;
1821
}
1922

2023
export const FixedHeightQuery = ({
2124
value = '',
2225
lines = 4,
2326
hasClipboardButton,
2427
clipboardButtonAlwaysVisible,
28+
mode = 'fixed',
2529
}: FixedHeightQueryProps) => {
2630
const heightValue = `${lines * LINE_HEIGHT + FIXED_PADDING}px`;
2731

2832
// Remove empty lines from the beginning (lines with only whitespace are considered empty)
2933
const trimmedValue = value.replace(/^(\s*\n)+/, '');
3034

35+
const heightStyle = mode === 'fixed' ? {height: heightValue} : {maxHeight: heightValue};
36+
3137
return (
3238
<div
3339
className={b()}
3440
style={
3541
{
36-
height: heightValue,
42+
...heightStyle,
3743
'--line-clamp': lines,
3844
} as React.CSSProperties & {'--line-clamp': number}
3945
}

src/components/ShardsTable/columns.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const getCpuCoresColumn: GetShardsColumn = () => {
8080
<UsageLabel value={roundToPrecision(usage, 2)} theme={getUsageSeverity(usage)} />
8181
);
8282
},
83-
align: DataTable.RIGHT,
83+
align: DataTable.LEFT,
8484
width: 110,
8585
resizeMinWidth: 110,
8686
};

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

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,31 @@ const cpuTimeUsColumn: Column<KeyValueRow> = {
2727
align: DataTable.RIGHT,
2828
};
2929

30-
const getQueryTextColumn = (lines = 3) => {
31-
const queryTextColumn: Column<KeyValueRow> = {
32-
name: QUERIES_COLUMNS_IDS.QueryText,
33-
header: QUERIES_COLUMNS_TITLES.QueryText,
34-
render: ({row}) => (
35-
<div className={b('query')}>
36-
<FixedHeightQuery
37-
value={row.QueryText?.toString()}
38-
lines={lines}
39-
hasClipboardButton
40-
/>
41-
</div>
42-
),
43-
width: 500,
44-
};
45-
return queryTextColumn;
30+
const queryTextColumn: Column<KeyValueRow> = {
31+
name: QUERIES_COLUMNS_IDS.QueryText,
32+
header: QUERIES_COLUMNS_TITLES.QueryText,
33+
render: ({row}) => (
34+
<div className={b('query')}>
35+
<FixedHeightQuery value={row.QueryText?.toString()} lines={3} hasClipboardButton />
36+
</div>
37+
),
38+
width: 500,
39+
};
40+
41+
const queryTextColumnWithMaxHeight: Column<KeyValueRow> = {
42+
name: QUERIES_COLUMNS_IDS.QueryText,
43+
header: QUERIES_COLUMNS_TITLES.QueryText,
44+
render: ({row}) => (
45+
<div className={b('query')}>
46+
<FixedHeightQuery
47+
value={row.QueryText?.toString()}
48+
lines={6}
49+
hasClipboardButton
50+
mode="fixed"
51+
/>
52+
</div>
53+
),
54+
width: 500,
4655
};
4756

4857
const endTimeColumn: Column<KeyValueRow> = {
@@ -80,7 +89,7 @@ const userSIDColumn: Column<KeyValueRow> = {
8089
const queryHashColumn: Column<KeyValueRow> = {
8190
name: QUERIES_COLUMNS_IDS.QueryHash,
8291
header: QUERIES_COLUMNS_TITLES.QueryHash,
83-
render: ({row}) => <div className={b('query-hash')}>{generateHash(String(row.QueryText))}</div>,
92+
render: ({row}) => generateHash(String(row.QueryText)),
8493
width: 130,
8594
};
8695

@@ -121,7 +130,7 @@ export function getTopQueriesColumns() {
121130
durationColumn,
122131
readBytesColumn,
123132
requestUnitsColumn,
124-
getQueryTextColumn(),
133+
queryTextColumn,
125134
endTimeColumn,
126135
readRowsColumn,
127136
userSIDColumn,
@@ -135,14 +144,14 @@ export function getTopQueriesColumns() {
135144
}
136145

137146
export function getTenantOverviewTopQueriesColumns() {
138-
return [queryHashColumn, getQueryTextColumn(6), cpuTimeUsColumn];
147+
return [queryHashColumn, queryTextColumnWithMaxHeight, cpuTimeUsColumn];
139148
}
140149
export function getRunningQueriesColumns() {
141150
const columns = [
142151
queryHashColumn,
143152
userSIDColumn,
144153
queryStartColumn,
145-
getQueryTextColumn(),
154+
queryTextColumn,
146155
applicationColumn,
147156
];
148157

src/utils/hooks/useScrollPosition.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import {debounce} from 'lodash';
44
import {useHistory} from 'react-router-dom';
55

6-
const DEBAUNCE_DELAY = 100;
6+
const DEBOUNCE_DELAY = 100;
77

88
/**
99
* Hook for saving and restoring scroll position on navigation
@@ -65,7 +65,7 @@ export function useScrollPosition(
6565
() =>
6666
debounce((scrollTop: number) => {
6767
saveScrollPosition(scrollTop);
68-
}, DEBAUNCE_DELAY),
68+
}, DEBOUNCE_DELAY),
6969
[saveScrollPosition],
7070
);
7171

@@ -88,14 +88,15 @@ export function useScrollPosition(
8888

8989
// Handle location changes
9090
React.useLayoutEffect(() => {
91+
let timeoutId: number | undefined;
9192
if (isHistoryNavigation && shouldRestore) {
9293
// This is a browser back/forward navigation - restore position with timeout to ensure that content rendered
93-
const timeoutId = setTimeout(restoreScrollPosition, 100);
94-
return () => clearTimeout(timeoutId);
94+
timeoutId = window.setTimeout(restoreScrollPosition, 100);
9595
} else {
9696
// This is a regular navigation (tab click, page reload) - clear position
9797
clearScrollPosition();
9898
}
99+
return () => clearTimeout(timeoutId);
99100
}, [
100101
isHistoryNavigation,
101102
restoreScrollPosition,

0 commit comments

Comments
 (0)