Skip to content

Commit 31d13d1

Browse files
refactor(TruncatedQuery): migrate to ts (#454)
1 parent 1f2fc08 commit 31d13d1

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import React from 'react';
21
import cn from 'bem-cn-lite';
32

43
import './TruncatedQuery.scss';
54

65
const b = cn('kv-truncated-query');
76

8-
function TruncatedQuery({value, maxQueryHeight}) {
7+
interface TruncatedQueryProps {
8+
value: string | undefined;
9+
maxQueryHeight?: number;
10+
}
11+
12+
export const TruncatedQuery = ({value = '', maxQueryHeight = 6}: TruncatedQueryProps) => {
913
const lines = value.split('\n');
1014
const truncated = lines.length > maxQueryHeight;
1115

@@ -14,13 +18,11 @@ function TruncatedQuery({value, maxQueryHeight}) {
1418
const message =
1519
'\n...\nThe request was truncated. Click on the line to show the full query on the query tab';
1620
return (
17-
<React.Fragment>
21+
<>
1822
<span className={b()}>{content}</span>
1923
<span className={b('message', {color: 'secondary'})}>{message}</span>
20-
</React.Fragment>
24+
</>
2125
);
2226
}
23-
return value;
24-
}
25-
26-
export default TruncatedQuery;
27+
return <>{value}</>;
28+
};

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {Loader} from '@gravity-ui/uikit';
99

1010
import {DateRange, DateRangeValues} from '../../../../components/DateRange';
1111
import {Search} from '../../../../components/Search';
12-
import TruncatedQuery from '../../../../components/TruncatedQuery/TruncatedQuery';
12+
import {TruncatedQuery} from '../../../../components/TruncatedQuery/TruncatedQuery';
1313

1414
import {changeUserInput} from '../../../../store/reducers/executeQuery';
1515
import {
@@ -23,7 +23,11 @@ import type {EPathType} from '../../../../types/api/schema';
2323
import type {ITopQueriesFilters} from '../../../../types/store/executeTopQueries';
2424
import type {IQueryResult} from '../../../../types/store/query';
2525

26-
import {TENANT_PAGE, TENANT_PAGES_IDS, TENANT_QUERY_TABS_ID} from '../../../../store/reducers/tenant/constants';
26+
import {
27+
TENANT_PAGE,
28+
TENANT_PAGES_IDS,
29+
TENANT_QUERY_TABS_ID,
30+
} from '../../../../store/reducers/tenant/constants';
2731
import {formatDateTime, formatNumber} from '../../../../utils';
2832
import {HOUR_IN_SECONDS} from '../../../../utils/constants';
2933
import {useAutofetcher, useTypedSelector} from '../../../../utils/hooks';
@@ -50,7 +54,10 @@ const COLUMNS: Column<KeyValueRow>[] = [
5054
sortable: false,
5155
render: ({row}) => (
5256
<div className={b('query')}>
53-
<TruncatedQuery value={row.QueryText} maxQueryHeight={MAX_QUERY_HEIGHT} />
57+
<TruncatedQuery
58+
value={row.QueryText?.toString()}
59+
maxQueryHeight={MAX_QUERY_HEIGHT}
60+
/>
5461
</div>
5562
),
5663
},

src/containers/Tenant/Query/QueriesHistory/QueriesHistory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import block from 'bem-cn-lite';
33

44
import DataTable, {Column} from '@gravity-ui/react-data-table';
55

6-
import TruncatedQuery from '../../../../components/TruncatedQuery/TruncatedQuery';
6+
import {TruncatedQuery} from '../../../../components/TruncatedQuery/TruncatedQuery';
77
import {setQueryTab} from '../../../../store/reducers/tenant/tenant';
88
import {TENANT_QUERY_TABS_ID} from '../../../../store/reducers/tenant/constants';
99
import {useTypedSelector} from '../../../../utils/hooks';

src/containers/Tenant/Query/SavedQueries/SavedQueries.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {setQueryNameToEdit} from '../../../../store/reducers/saveQuery';
1010
import {setQueryTab} from '../../../../store/reducers/tenant/tenant';
1111
import {TENANT_QUERY_TABS_ID} from '../../../../store/reducers/tenant/constants';
1212

13-
import TruncatedQuery from '../../../../components/TruncatedQuery/TruncatedQuery';
13+
import {TruncatedQuery} from '../../../../components/TruncatedQuery/TruncatedQuery';
1414
import {IconWrapper} from '../../../../components/Icon';
1515

1616
import {MAX_QUERY_HEIGHT, QUERY_TABLE_SETTINGS} from '../../utils/constants';

0 commit comments

Comments
 (0)