Skip to content

Commit 84e75ea

Browse files
authored
feat: improve tenant diagnostics - CPU (#2633)
1 parent 1c65975 commit 84e75ea

File tree

28 files changed

+527
-491
lines changed

28 files changed

+527
-491
lines changed

src/components/FixedHeightQuery/FixedHeightQuery.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
height: 100% !important;
2525
margin: 0 !important;
26-
padding: var(--g-spacing-2) !important;
26+
padding: 0 !important;
2727

2828
white-space: pre-wrap !important;
2929
text-overflow: ellipsis !important;
@@ -39,4 +39,8 @@
3939
word-break: break-word !important;
4040
}
4141
}
42+
.ydb-syntax-highlighter__copy {
43+
top: 0;
44+
right: 0;
45+
}
4246
}

src/components/FixedHeightQuery/FixedHeightQuery.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,39 @@ import './FixedHeightQuery.scss';
77

88
const b = cn('ydb-fixed-height-query');
99

10-
const FIXED_PADDING = 8;
10+
const FIXED_PADDING = 0;
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
}
@@ -47,6 +53,7 @@ export const FixedHeightQuery = ({
4753
alwaysVisible: clipboardButtonAlwaysVisible,
4854
copyText: value,
4955
withLabel: false,
56+
size: 'xs',
5057
}
5158
: false
5259
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {ArrowRight} from '@gravity-ui/icons';
2+
import {Flex, Icon, Text} from '@gravity-ui/uikit';
3+
4+
import {InternalLink} from '../InternalLink';
5+
6+
import i18n from './i18n';
7+
8+
interface SeeAllButtonProps {
9+
to: string;
10+
className?: string;
11+
onClick?: () => void;
12+
}
13+
14+
export function SeeAllButton({to, className, onClick}: SeeAllButtonProps) {
15+
return (
16+
<InternalLink className={className} to={to} onClick={onClick}>
17+
<Flex alignItems="center" gap={1}>
18+
<Text>{i18n('action_see-all')}</Text>
19+
<Icon data={ArrowRight} size={16} />
20+
</Flex>
21+
</InternalLink>
22+
);
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"action_see-all": "See all"
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {registerKeysets} from '../../../utils/i18n';
2+
3+
import en from './en.json';
4+
5+
const COMPONENT = 'ydb-see-all-button';
6+
7+
export default registerKeysets(COMPONENT, {en});

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/components/SyntaxHighlighter/YDBSyntaxHighlighter.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22

3+
import type {ButtonSize} from '@gravity-ui/uikit';
34
import {ClipboardButton} from '@gravity-ui/uikit';
45
import {nanoid} from '@reduxjs/toolkit';
56
import {PrismLight as ReactSyntaxHighlighter} from 'react-syntax-highlighter';
@@ -27,6 +28,7 @@ interface ClipboardButtonOptions {
2728
alwaysVisible?: boolean;
2829
copyText?: string;
2930
withLabel?: boolean;
31+
size?: ButtonSize;
3032
}
3133

3234
export type WithClipboardButtonProp = ClipboardButtonOptions | boolean;
@@ -58,28 +60,22 @@ export function YDBSyntaxHighlighter({
5860
registerLangAndUpdateKey();
5961
}, [language]);
6062

63+
const clipboardButtonProps =
64+
typeof withClipboardButton === 'object' ? withClipboardButton : undefined;
65+
6166
const renderCopyButton = () => {
6267
if (withClipboardButton) {
6368
return (
6469
<div className={b('sticky-container')} onClick={(e) => e.stopPropagation()}>
6570
<ClipboardButton
6671
view="flat-secondary"
67-
size="s"
72+
size={clipboardButtonProps?.size || 'xs'}
6873
className={b('copy', {
69-
visible:
70-
typeof withClipboardButton === 'object' &&
71-
withClipboardButton.alwaysVisible,
74+
visible: clipboardButtonProps?.alwaysVisible,
7275
})}
73-
text={
74-
(typeof withClipboardButton === 'object' &&
75-
withClipboardButton.copyText) ||
76-
text
77-
}
76+
text={clipboardButtonProps?.copyText || text}
7877
>
79-
{typeof withClipboardButton === 'object' &&
80-
withClipboardButton.withLabel === false
81-
? null
82-
: i18n('copy')}
78+
{clipboardButtonProps?.withLabel === false ? null : i18n('copy')}
8379
</ClipboardButton>
8480
</div>
8581
);

src/components/SyntaxHighlighter/themes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export const lightTransparent = {
77
...materialLight['pre[class*="language-"]'],
88
background: 'transparent',
99
margin: 0,
10+
lineHeight: '15px',
1011
},
1112
'code[class*="language-"]': {
1213
...materialLight['code[class*="language-"]'],
1314
background: 'transparent',
1415
color: 'var(--g-color-text-primary)',
1516
whiteSpace: 'pre-wrap' as const,
17+
fontSize: '13px',
1618
},
1719
comment: {
1820
color: '#969896',
@@ -49,12 +51,14 @@ export const darkTransparent = {
4951
...vscDarkPlus['pre[class*="language-"]'],
5052
background: 'transparent',
5153
margin: 0,
54+
lineHeight: '15px',
5255
},
5356
'code[class*="language-"]': {
5457
...vscDarkPlus['code[class*="language-"]'],
5558
background: 'transparent',
5659
color: 'var(--g-color-text-primary)',
5760
whiteSpace: 'pre-wrap' as const,
61+
fontSize: '13px',
5862
},
5963
comment: {
6064
color: '#969896',
@@ -91,10 +95,12 @@ const dark: Record<string, React.CSSProperties> = {
9195
...darkTransparent['pre[class*="language-"]'],
9296
background: vscDarkPlus['pre[class*="language-"]'].background,
9397
scrollbarColor: `var(--g-color-scroll-handle) transparent`,
98+
lineHeight: '15px',
9499
},
95100
'code[class*="language-"]': {
96101
...darkTransparent['code[class*="language-"]'],
97102
whiteSpace: 'pre',
103+
fontSize: '13px',
98104
},
99105
};
100106

@@ -104,10 +110,12 @@ const light: Record<string, React.CSSProperties> = {
104110
...lightTransparent['pre[class*="language-"]'],
105111
background: 'var(--g-color-base-misc-light)',
106112
scrollbarColor: `var(--g-color-scroll-handle) transparent`,
113+
lineHeight: '15px',
107114
},
108115
'code[class*="language-"]': {
109116
...lightTransparent['code[class*="language-"]'],
110117
whiteSpace: 'pre',
118+
fontSize: '13px',
111119
},
112120
};
113121

src/containers/Tenant/Diagnostics/Diagnostics.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {setDiagnosticsTab} from '../../../store/reducers/tenant/tenant';
1616
import type {AdditionalNodesProps, AdditionalTenantsProps} from '../../../types/additionalProps';
1717
import {uiFactory} from '../../../uiFactory/uiFactory';
1818
import {cn} from '../../../utils/cn';
19-
import {useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
19+
import {useScrollPosition, useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
2020
import {Heatmap} from '../../Heatmap';
2121
import {Nodes} from '../../Nodes/Nodes';
2222
import {Operations} from '../../Operations';
@@ -200,6 +200,12 @@ function Diagnostics(props: DiagnosticsProps) {
200200
);
201201
};
202202

203+
useScrollPosition(
204+
containerRef,
205+
`tenant-diagnostics-${tenantName}-${activeTab?.id}`,
206+
activeTab?.id === TENANT_DIAGNOSTICS_TABS_IDS.overview,
207+
);
208+
203209
return (
204210
<div className={b()}>
205211
{activeTab ? (
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.ydb-stats-wrapper {
2+
overflow: auto;
3+
4+
padding: var(--g-spacing-4);
5+
6+
border: 1px solid var(--g-color-line-generic);
7+
border-radius: var(--g-border-radius-xs);
8+
9+
&__header {
10+
position: sticky;
11+
top: 0;
12+
left: 0;
13+
}
14+
}

0 commit comments

Comments
 (0)