Skip to content

Commit 94e1cc5

Browse files
committed
fix: selfreview
1 parent eb542d5 commit 94e1cc5

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed

src/containers/Tenant/Diagnostics/TenantOverview/TenantMemory/MemoryDetailsSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function MemoryDetailsSection({memoryStats}: MemoryDetailsSectionProps) {
5050
{i18n('text_memory-details')}
5151
</Text>
5252
</div>
53-
<Flex direction="column" alignItems="flex-start" gap="4">
53+
<Flex direction="column" alignItems="flex-start" gap="4" width="100%">
5454
<div className={b('main-progress')}>
5555
<ProgressWrapper
5656
stack={memorySegments}

src/containers/Tenant/Diagnostics/TenantOverview/TenantMemory/MemorySegmentItem.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import {DefinitionList, Flex, Progress, Text} from '@gravity-ui/uikit';
44

55
import type {MemorySegment} from '../../../../../components/MemoryViewer/utils';
66
import {getMemorySegmentColor} from '../../../../../components/MemoryViewer/utils';
7+
import i18n from '../../../../../components/ProgressWrapper/i18n';
78
import {cn} from '../../../../../utils/cn';
8-
import {formatSegmentValue} from '../../../../../utils/progress';
9+
import {formatStorageValuesToGb} from '../../../../../utils/dataFormatters/dataFormatters';
910

1011
const b = cn('memory-details');
1112

@@ -19,7 +20,13 @@ export function MemorySegmentItem({segment}: MemorySegmentItemProps) {
1920
}, [segment.key]);
2021

2122
const valueText = React.useMemo(() => {
22-
return formatSegmentValue(segment.value, segment.capacity);
23+
const [valueFormatted, capacityFormatted] = formatStorageValuesToGb(
24+
segment.value,
25+
segment.capacity,
26+
);
27+
return segment.capacity
28+
? i18n('context_capacity-usage', {value: valueFormatted, capacity: capacityFormatted})
29+
: valueFormatted;
2330
}, [segment.value, segment.capacity]);
2431

2532
const progressValue = React.useMemo(() => {

src/utils/progress.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {formatBytes} from './bytesParsers';
21
import {DEFAULT_DANGER_THRESHOLD, DEFAULT_WARNING_THRESHOLD} from './constants';
32
import {formatNumber, roundToPrecision} from './dataFormatters/dataFormatters';
43

@@ -17,31 +16,6 @@ export const defaultFormatProgressValues: FormatProgressViewerValues = (value, t
1716
return [formatValue(value), formatValue(total)];
1817
};
1918

20-
export function formatSegmentValue(value: number, capacity?: number): string {
21-
if (capacity) {
22-
const usedValue = formatBytes({
23-
value,
24-
size: 'tb',
25-
withSizeLabel: false,
26-
precision: 2,
27-
});
28-
const totalValue = formatBytes({
29-
value: capacity,
30-
size: 'tb',
31-
withSizeLabel: true,
32-
precision: 0,
33-
});
34-
return `${usedValue} of ${totalValue}`;
35-
}
36-
37-
return formatBytes({
38-
value,
39-
size: 'gb',
40-
withSizeLabel: true,
41-
precision: 1,
42-
});
43-
}
44-
4519
interface CalculateProgressStatusProps {
4620
inverseColorize?: boolean;
4721
dangerThreshold?: number;

0 commit comments

Comments
 (0)