Skip to content

Commit 49684fa

Browse files
authored
Merge branch 'main' into astandrik.add-controls-1415
2 parents 01de67b + e2f7a25 commit 49684fa

39 files changed

+451
-204
lines changed

CHANGELOG.md

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

3+
## [6.29.2](https://github.com/ydb-platform/ydb-embedded-ui/compare/v6.29.1...v6.29.2) (2024-10-28)
4+
5+
6+
### Bug Fixes
7+
8+
* **ClusterMetricsCores:** format value and capacity same way ([#1532](https://github.com/ydb-platform/ydb-embedded-ui/issues/1532)) ([4eb5c04](https://github.com/ydb-platform/ydb-embedded-ui/commit/4eb5c041f8b5615a2806bf5d5bd015afa963ac09))
9+
* **TabletsTable:** action icons coincide in tablet's page and in table ([#1549](https://github.com/ydb-platform/ydb-embedded-ui/issues/1549)) ([26f77a8](https://github.com/ydb-platform/ydb-embedded-ui/commit/26f77a8563e3c3a100001b198e3e7ee5f97ad7f9))
10+
311
## [6.29.1](https://github.com/ydb-platform/ydb-embedded-ui/compare/v6.29.0...v6.29.1) (2024-10-25)
412

513

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": "6.29.1",
3+
"version": "6.29.2",
44
"files": [
55
"dist"
66
],

src/components/ButtonWithConfirmDialog/ButtonWithConfirmDialog.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface ButtonWithConfirmDialogProps<T, K> {
1515
retryButtonText?: string;
1616
buttonDisabled?: ButtonProps['disabled'];
1717
buttonView?: ButtonProps['view'];
18+
buttonTitle?: ButtonProps['title'];
1819
buttonClassName?: ButtonProps['className'];
1920
withPopover?: boolean;
2021
popoverContent?: PopoverProps['content'];
@@ -31,6 +32,7 @@ export function ButtonWithConfirmDialog<T, K>({
3132
retryButtonText,
3233
buttonDisabled = false,
3334
buttonView = 'action',
35+
buttonTitle,
3436
buttonClassName,
3537
withPopover = false,
3638
popoverContent,
@@ -69,6 +71,7 @@ export function ButtonWithConfirmDialog<T, K>({
6971
disabled={buttonDisabled}
7072
loading={!buttonDisabled && buttonLoading}
7173
className={buttonClassName}
74+
title={buttonTitle}
7275
>
7376
{children}
7477
</Button>

src/components/FormattedBytes/FormattedBytes.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import type {FormatBytesArgs} from '../../utils/bytesParsers';
1+
import type {BytesSizes} from '../../utils/bytesParsers';
22
import {formatBytes} from '../../utils/bytesParsers';
3+
import type {FormatValuesArgs} from '../../utils/dataFormatters/common';
34

4-
type FormattedBytesProps = FormatBytesArgs;
5+
type FormattedBytesProps = FormatValuesArgs<BytesSizes>;
56

67
export const FormattedBytes = ({value, withSpeedLabel, ...params}: FormattedBytesProps) => {
78
const formatted = formatBytes({value, withSpeedLabel, ...params});

src/components/FormattedBytes/utils.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import type {FormatBytesArgs} from '../../utils/bytesParsers';
1+
import type {BytesSizes} from '../../utils/bytesParsers';
2+
import type {FormatValuesArgs} from '../../utils/dataFormatters/common';
23

34
import {FormattedBytes} from './FormattedBytes';
45

56
export const toFormattedSize = (
67
value: number | string | undefined,
7-
params?: Omit<FormatBytesArgs, 'value'>,
8+
params?: Omit<FormatValuesArgs<BytesSizes>, 'value'>,
89
) => {
910
if (!value) {
1011
return null;

src/components/PaginatedTable/PaginatedTable.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
position: relative;
3030
z-index: 1;
3131

32+
// Performance optimization for row hovering.
33+
// it actually works.
34+
transform: translateZ(0);
35+
3236
&:hover {
3337
background: var(--paginated-table-hover-color);
3438
}
@@ -177,6 +181,6 @@
177181
}
178182

179183
&__row-skeleton::after {
180-
animation-delay: 200ms;
184+
animation: none !important;
181185
}
182186
}

src/components/PaginatedTable/PaginatedTable.tsx

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

3-
import {getArray} from '../../utils';
43
import {TableWithControlsLayout} from '../TableWithControlsLayout/TableWithControlsLayout';
54

65
import {TableChunk} from './TableChunk';
@@ -32,7 +31,7 @@ export interface PaginatedTableProps<T, F> {
3231
columns: Column<T>[];
3332
getRowClassName?: GetRowClassName<T>;
3433
rowHeight?: number;
35-
parentRef?: React.RefObject<HTMLElement>;
34+
parentRef: React.RefObject<HTMLElement>;
3635
initialSortParams?: SortParams;
3736
onColumnsResize?: HandleTableColumnsResize;
3837
renderControls?: RenderControls;
@@ -42,7 +41,7 @@ export interface PaginatedTableProps<T, F> {
4241
}
4342

4443
export const PaginatedTable = <T, F>({
45-
limit,
44+
limit: chunkSize,
4645
initialEntitiesCount,
4746
fetchData,
4847
filters,
@@ -58,8 +57,8 @@ export const PaginatedTable = <T, F>({
5857
renderEmptyDataMessage,
5958
containerClassName,
6059
}: PaginatedTableProps<T, F>) => {
61-
const initialTotal = initialEntitiesCount || limit;
62-
const initialFound = initialEntitiesCount || 0;
60+
const initialTotal = initialEntitiesCount || 0;
61+
const initialFound = initialEntitiesCount || 1;
6362

6463
const [sortParams, setSortParams] = React.useState<SortParams | undefined>(initialSortParams);
6564
const [totalEntities, setTotalEntities] = React.useState(initialTotal);
@@ -69,12 +68,18 @@ export const PaginatedTable = <T, F>({
6968
const tableRef = React.useRef<HTMLDivElement>(null);
7069

7170
const activeChunks = useScrollBasedChunks({
72-
containerRef: parentRef ?? tableRef,
71+
parentRef,
72+
tableRef,
7373
totalItems: foundEntities,
74-
itemHeight: rowHeight,
75-
chunkSize: limit,
74+
rowHeight,
75+
chunkSize,
7676
});
7777

78+
const lastChunkSize = React.useMemo(
79+
() => foundEntities % chunkSize || chunkSize,
80+
[foundEntities, chunkSize],
81+
);
82+
7883
const handleDataFetched = React.useCallback((total: number, found: number) => {
7984
setTotalEntities(total);
8085
setFoundEntities(found);
@@ -88,10 +93,8 @@ export const PaginatedTable = <T, F>({
8893
setIsInitialLoad(true);
8994
if (parentRef?.current) {
9095
parentRef.current.scrollTo(0, 0);
91-
} else {
92-
tableRef.current?.scrollTo(0, 0);
9396
}
94-
}, [filters, initialFound, initialTotal, limit, parentRef]);
97+
}, [filters, initialFound, initialTotal, parentRef]);
9598

9699
const renderChunks = () => {
97100
if (!isInitialLoad && foundEntities === 0) {
@@ -104,15 +107,12 @@ export const PaginatedTable = <T, F>({
104107
);
105108
}
106109

107-
const totalLength = foundEntities || limit;
108-
const chunksCount = Math.ceil(totalLength / limit);
109-
110-
return getArray(chunksCount).map((value) => (
110+
return activeChunks.map((isActive, index) => (
111111
<TableChunk<T, F>
112-
key={value}
113-
id={value}
114-
limit={limit}
115-
totalLength={totalLength}
112+
key={index}
113+
id={index}
114+
calculatedCount={index === activeChunks.length - 1 ? lastChunkSize : chunkSize}
115+
chunkSize={chunkSize}
116116
rowHeight={rowHeight}
117117
columns={columns}
118118
fetchData={fetchData}
@@ -122,7 +122,7 @@ export const PaginatedTable = <T, F>({
122122
getRowClassName={getRowClassName}
123123
renderErrorMessage={renderErrorMessage}
124124
onDataFetched={handleDataFetched}
125-
isActive={activeChunks.includes(value)}
125+
isActive={isActive}
126126
/>
127127
));
128128
};

src/components/PaginatedTable/TableChunk.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import {ResponseError} from '../Errors/ResponseError';
88

99
import {EmptyTableRow, LoadingTableRow, TableRow} from './TableRow';
1010
import type {Column, FetchData, GetRowClassName, SortParams} from './types';
11+
import {typedMemo} from './utils';
1112

1213
const DEBOUNCE_TIMEOUT = 200;
1314

1415
interface TableChunkProps<T, F> {
1516
id: number;
16-
limit: number;
17-
totalLength: number;
17+
chunkSize: number;
1818
rowHeight: number;
19+
calculatedCount: number;
1920
columns: Column<T>[];
2021
filters?: F;
2122
sortParams?: SortParams;
@@ -29,10 +30,10 @@ interface TableChunkProps<T, F> {
2930
}
3031

3132
// Memoisation prevents chunks rerenders that could cause perfomance issues on big tables
32-
export const TableChunk = <T, F>({
33+
export const TableChunk = typedMemo(function TableChunk<T, F>({
3334
id,
34-
limit,
35-
totalLength,
35+
chunkSize,
36+
calculatedCount,
3637
rowHeight,
3738
columns,
3839
fetchData,
@@ -43,15 +44,15 @@ export const TableChunk = <T, F>({
4344
renderErrorMessage,
4445
onDataFetched,
4546
isActive,
46-
}: TableChunkProps<T, F>) => {
47+
}: TableChunkProps<T, F>) {
4748
const [isTimeoutActive, setIsTimeoutActive] = React.useState(true);
4849
const [autoRefreshInterval] = useAutoRefreshInterval();
4950

5051
const columnsIds = columns.map((column) => column.name);
5152

5253
const queryParams = {
53-
offset: id * limit,
54-
limit,
54+
offset: id * chunkSize,
55+
limit: chunkSize,
5556
fetchData: fetchData as FetchData<T, unknown>,
5657
filters,
5758
sortParams,
@@ -87,11 +88,7 @@ export const TableChunk = <T, F>({
8788
}
8889
}, [currentData, isActive, onDataFetched]);
8990

90-
const chunkOffset = id * limit;
91-
const remainingLength = totalLength - chunkOffset;
92-
const calculatedChunkLength = remainingLength < limit ? remainingLength : limit;
93-
94-
const dataLength = currentData?.data?.length || calculatedChunkLength;
91+
const dataLength = currentData?.data?.length || calculatedCount;
9592

9693
const renderContent = () => {
9794
if (!isActive) {
@@ -134,13 +131,11 @@ export const TableChunk = <T, F>({
134131
));
135132
};
136133

137-
const chunkHeight = dataLength ? dataLength * rowHeight : limit * rowHeight;
138-
139134
return (
140135
<tbody
141136
id={id.toString()}
142137
style={{
143-
height: `${chunkHeight}px`,
138+
height: `${dataLength * rowHeight}px`,
144139
// Default display: table-row-group doesn't work in Safari and breaks the table
145140
// display: block works in Safari, but disconnects thead and tbody cell grids
146141
// Hack to make it work in all cases
@@ -150,4 +145,4 @@ export const TableChunk = <T, F>({
150145
{renderContent()}
151146
</tbody>
152147
);
153-
};
148+
});

src/components/PaginatedTable/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export const DEFAULT_SORT_ORDER = DESCENDING;
1313
// Time in ms after which request will be sent
1414
export const DEFAULT_REQUEST_TIMEOUT = 200;
1515

16-
export const DEFAULT_TABLE_ROW_HEIGHT = 40;
16+
export const DEFAULT_TABLE_ROW_HEIGHT = 41;
1717

1818
export const DEFAULT_INTERSECTION_OBSERVER_MARGIN = '100%';

0 commit comments

Comments
 (0)