Skip to content

Commit da315ee

Browse files
authored
Merge branch 'main' into astandrik.1607
2 parents 66c28e3 + 0e8bdd8 commit da315ee

File tree

13 files changed

+64
-106
lines changed

13 files changed

+64
-106
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "8.6.0"
2+
".": "8.7.0"
33
}

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## [8.7.0](https://github.com/ydb-platform/ydb-embedded-ui/compare/v8.6.0...v8.7.0) (2025-01-31)
4+
5+
6+
### Features
7+
8+
* **MetricChart:** add legend to some charts ([#1893](https://github.com/ydb-platform/ydb-embedded-ui/issues/1893)) ([b190e24](https://github.com/ydb-platform/ydb-embedded-ui/commit/b190e2461b6b3edecc272a804597415fbe0742f5))
9+
* **SchemaViewer:** calculate column width based on data ([#1885](https://github.com/ydb-platform/ydb-embedded-ui/issues/1885)) ([85f19c3](https://github.com/ydb-platform/ydb-embedded-ui/commit/85f19c3d579a2d365056a69be43856a82bd5a9e4))
10+
11+
12+
### Bug Fixes
13+
14+
* add additional timeout for flaky tests ([#1884](https://github.com/ydb-platform/ydb-embedded-ui/issues/1884)) ([9a502d2](https://github.com/ydb-platform/ydb-embedded-ui/commit/9a502d27e592522ee93f296be6b9047e7e87032e))
15+
* avoid confusion with information interpretation ([#1871](https://github.com/ydb-platform/ydb-embedded-ui/issues/1871)) ([54c7091](https://github.com/ydb-platform/ydb-embedded-ui/commit/54c7091184d4cc1993bb735a4df9673fc2c32873))
16+
* disable autorefresh for ydb_ru ([#1890](https://github.com/ydb-platform/ydb-embedded-ui/issues/1890)) ([a0ba20f](https://github.com/ydb-platform/ydb-embedded-ui/commit/a0ba20f68b288bb8be9fa4a12effeea1d00cd9b6))
17+
* **Storage:** tune popups for vdisk and pdisk ([#1883](https://github.com/ydb-platform/ydb-embedded-ui/issues/1883)) ([ae115d9](https://github.com/ydb-platform/ydb-embedded-ui/commit/ae115d97dedf4dcb353cf3c53d0418131550bb19))
18+
* **Tenant:** fix tabs reset on schema object change ([#1881](https://github.com/ydb-platform/ydb-embedded-ui/issues/1881)) ([4dd053d](https://github.com/ydb-platform/ydb-embedded-ui/commit/4dd053deb240823780a0c87aa88d3628631f26da))
19+
320
## [8.6.0](https://github.com/ydb-platform/ydb-embedded-ui/compare/v8.5.0...v8.6.0) (2025-01-27)
421

522

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ydb-embedded-ui",
3-
"version": "8.6.0",
3+
"version": "8.7.0",
44
"files": [
55
"dist"
66
],

src/components/FormattedBytes/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export const toFormattedSize = (
1111
return null;
1212
}
1313

14-
return <FormattedBytes value={value} significantDigits={2} {...params} />;
14+
return <FormattedBytes value={value} {...params} />;
1515
};

src/containers/Cluster/ClusterInfo/components/DiskGroupsStatsBars/DiskGroupsStatsBars.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {DefinitionList} from '@gravity-ui/components';
22

33
import {ContentWithPopup} from '../../../../../components/ContentWithPopup/ContentWithPopup';
44
import type {DiskErasureGroupsStats} from '../../../../../store/reducers/cluster/types';
5-
import {formatBytes, getSizeWithSignificantDigits} from '../../../../../utils/bytesParsers';
5+
import {formatBytes, getBytesSizeUnit} from '../../../../../utils/bytesParsers';
66
import {cn} from '../../../../../utils/cn';
77
import i18n from '../../../i18n';
88

@@ -36,7 +36,7 @@ interface GroupsStatsPopupContentProps {
3636
function GroupsStatsPopupContent({stats}: GroupsStatsPopupContentProps) {
3737
const {diskType, erasure, allocatedSize, availableSize} = stats;
3838

39-
const sizeToConvert = getSizeWithSignificantDigits(Math.max(allocatedSize, availableSize), 2);
39+
const sizeToConvert = getBytesSizeUnit(Math.max(allocatedSize, availableSize));
4040

4141
const convertedAllocatedSize = formatBytes({value: allocatedSize, size: sizeToConvert});
4242
const convertedAvailableSize = formatBytes({value: availableSize, size: sizeToConvert});

src/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TopTables.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {CellWithPopover} from '../../../../../components/CellWithPopover/CellWit
66
import {LinkToSchemaObject} from '../../../../../components/LinkToSchemaObject/LinkToSchemaObject';
77
import {topTablesApi} from '../../../../../store/reducers/tenantOverview/executeTopTables/executeTopTables';
88
import type {KeyValueRow} from '../../../../../types/api/query';
9-
import {formatBytes, getSizeWithSignificantDigits} from '../../../../../utils/bytesParsers';
9+
import {formatBytes, getBytesSizeUnit} from '../../../../../utils/bytesParsers';
1010
import {useAutoRefreshInterval} from '../../../../../utils/hooks';
1111
import {parseQueryErrorToString} from '../../../../../utils/query';
1212
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
@@ -35,7 +35,7 @@ export function TopTables({path}: TopTablesProps) {
3535
const data = currentData?.resultSets?.[0]?.result || [];
3636

3737
const formatSize = (value?: number) => {
38-
const size = getSizeWithSignificantDigits(data?.length ? Number(data[0].Size) : 0, 0);
38+
const size = getBytesSizeUnit(data?.length ? Number(data[0].Size) : 0);
3939

4040
return formatBytes({value, size, precision: 1});
4141
};

src/utils/bytesParsers/__test__/formatBytes.test.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@ describe('formatBytes', () => {
3333
`100${UNBREAKABLE_GAP}000${UNBREAKABLE_GAP}B/s`,
3434
);
3535
});
36-
it('should return fixed amount of significant digits', () => {
37-
expect(formatBytes({value: 99_000, significantDigits: 2})).toEqual(
38-
`99${UNBREAKABLE_GAP}000${UNBREAKABLE_GAP}B`,
39-
);
40-
expect(formatBytes({value: 100_000, significantDigits: 2})).toEqual(
41-
`100${UNBREAKABLE_GAP}KB`,
42-
);
43-
expect(formatBytes({value: 99_000_000_000_000, significantDigits: 2})).toEqual(
44-
`99${UNBREAKABLE_GAP}000${UNBREAKABLE_GAP}GB`,
45-
);
46-
expect(formatBytes({value: 100_000_000_000_000, significantDigits: 2})).toEqual(
47-
`100${UNBREAKABLE_GAP}TB`,
48-
);
49-
});
5036
it('should return empty string on invalid data', () => {
5137
expect(formatBytes({value: undefined})).toEqual('');
5238
expect(formatBytes({value: null})).toEqual('');

src/utils/bytesParsers/formatBytes.ts

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,23 @@ const sizes = {
2626
value: TERABYTE,
2727
label: i18n('tb'),
2828
},
29-
};
29+
} as const;
3030

3131
export type BytesSizes = keyof typeof sizes;
3232

33-
/**
34-
* This function is needed to keep more than 3 digits of the same size.
35-
*
36-
* @param significantDigits - number of digits above 3
37-
* @returns size to format value to get required number of digits
38-
*
39-
* By default value converted to the next size when it's above 1000,
40-
* so we have 900mb and 1gb. To extend it additional significantDigits could be set
41-
*
42-
* significantDigits value added above default 3
43-
*
44-
* significantDigits = 1 - 9 000 mb and 10 gb
45-
*
46-
* significantDigits = 2 - 90 000 mb and 100 gb
47-
*
48-
* significantDigits = 3 - 900 000 mb and 1000 gb
49-
*/
50-
export const getSizeWithSignificantDigits = (value: number, significantDigits: number) => {
51-
const multiplier = 10 ** significantDigits;
52-
53-
const tbLevel = sizes.tb.value * multiplier;
54-
const gbLevel = sizes.gb.value * multiplier;
55-
const mbLevel = sizes.mb.value * multiplier;
56-
const kbLevel = sizes.kb.value * multiplier;
57-
33+
export const getBytesSizeUnit = (value: number) => {
5834
let size: BytesSizes = 'b';
5935

60-
if (value >= kbLevel) {
36+
if (value >= sizes.kb.value) {
6137
size = 'kb';
6238
}
63-
if (value >= mbLevel) {
39+
if (value >= sizes.mb.value) {
6440
size = 'mb';
6541
}
66-
if (value >= gbLevel) {
42+
if (value >= sizes.gb.value) {
6743
size = 'gb';
6844
}
69-
if (value >= tbLevel) {
45+
if (value >= sizes.tb.value) {
7046
size = 'tb';
7147
}
7248

@@ -87,15 +63,11 @@ const addSpeedLabel = (result: string, size: BytesSizes) => {
8763
return addSizeLabel(result, size) + i18n('perSecond');
8864
};
8965

90-
/**
91-
* @param significantDigits - number of digits above 3
92-
*/
9366
export const formatBytes = ({
9467
value,
9568
size,
9669
withSpeedLabel = false,
9770
withSizeLabel = true,
98-
significantDigits = 0,
9971
delimiter,
10072
...params
10173
}: FormatValuesArgs<BytesSizes>) => {
@@ -105,7 +77,7 @@ export const formatBytes = ({
10577

10678
const numValue = Number(value);
10779

108-
const sizeToConvert = size ?? getSizeWithSignificantDigits(numValue, significantDigits);
80+
const sizeToConvert = size ?? getBytesSizeUnit(numValue);
10981

11082
const result = formatToSize({value: numValue, size: sizeToConvert, ...params});
11183

src/utils/dataFormatters/__test__/formatNumbers.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ describe('formatNumericValues', () => {
2121
const result = formatNumericValues(1024, 2048);
2222
expect(result).toEqual(['1', `2${UNBREAKABLE_GAP}k`]);
2323
});
24+
25+
it('should format values without units (less than 1000)', () => {
26+
const result1 = formatNumericValues(10, 20);
27+
expect(result1).toEqual(['10', `20`]);
28+
});
29+
2430
it('should format value with label if set', () => {
2531
const result = formatNumericValues(1024, 2048, undefined, undefined, true);
2632
expect(result).toEqual([`1${UNBREAKABLE_GAP}k`, `2${UNBREAKABLE_GAP}k`]);

0 commit comments

Comments
 (0)