Skip to content

Commit 1a3a2ee

Browse files
authored
Merge branch 'main' into astandrik.display-a-list-of-operations-1414
2 parents 3393edf + 78cd713 commit 1a3a2ee

36 files changed

+526
-368
lines changed

CHANGELOG.md

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

3+
## [6.24.0](https://github.com/ydb-platform/ydb-embedded-ui/compare/v6.23.1...v6.24.0) (2024-10-10)
4+
5+
6+
### Features
7+
8+
* add dimming to vdisk page (nodes) and pdisk page (vdisks) ([#1397](https://github.com/ydb-platform/ydb-embedded-ui/issues/1397)) ([deb2a88](https://github.com/ydb-platform/ydb-embedded-ui/commit/deb2a88d86ac0ad84f13acf1b7a3bf89289f5722))
9+
* **Databases:** use balancer + /node/:id as backend endpoint ([#1418](https://github.com/ydb-platform/ydb-embedded-ui/issues/1418)) ([f8a0db1](https://github.com/ydb-platform/ydb-embedded-ui/commit/f8a0db18fa01b9e9198e7c1ad4a656ba17de5922))
10+
* **Storage:** add disk space usage column ([#1425](https://github.com/ydb-platform/ydb-embedded-ui/issues/1425)) ([d254ee2](https://github.com/ydb-platform/ydb-embedded-ui/commit/d254ee2bd71b5028eb48b4d34c30bc5ea48fa484))
11+
* **StorageNodes:** add columns, use the same nodes columns ([#1396](https://github.com/ydb-platform/ydb-embedded-ui/issues/1396)) ([90a3403](https://github.com/ydb-platform/ydb-embedded-ui/commit/90a34037c8ea8e7fe8e680a47d6e1323b9fd9ff2))
12+
* **VDisk:** show VDisk donors inside popup ([#1422](https://github.com/ydb-platform/ydb-embedded-ui/issues/1422)) ([fc12a38](https://github.com/ydb-platform/ydb-embedded-ui/commit/fc12a38156e117e43e89b301b58df59408a98928))
13+
14+
15+
### Bug Fixes
16+
17+
* **Authentication:** handle login error properly ([#1426](https://github.com/ydb-platform/ydb-embedded-ui/issues/1426)) ([10f817e](https://github.com/ydb-platform/ydb-embedded-ui/commit/10f817ef9879ce8fc3beddda1377a03ca285bc5f))
18+
* autocomplete not working in standalone version ([#1405](https://github.com/ydb-platform/ydb-embedded-ui/issues/1405)) ([8f516be](https://github.com/ydb-platform/ydb-embedded-ui/commit/8f516becf0fc0cfdd25d10abf00a41dc6953a326))
19+
* **cluster:** infoV2 check ([#1401](https://github.com/ydb-platform/ydb-embedded-ui/issues/1401)) ([6dbe56d](https://github.com/ydb-platform/ydb-embedded-ui/commit/6dbe56db0e3a85c44852b85477e2027f8e1754b4))
20+
* nodes list stops working on sort by uptime scroll down ([#1424](https://github.com/ydb-platform/ydb-embedded-ui/issues/1424)) ([5ecaecb](https://github.com/ydb-platform/ydb-embedded-ui/commit/5ecaecbfdedd47d39539e871cca8a7cf5a45e1f0))
21+
* **StorageGroups:** display full pool name with left cut ([#1421](https://github.com/ydb-platform/ydb-embedded-ui/issues/1421)) ([09599c1](https://github.com/ydb-platform/ydb-embedded-ui/commit/09599c1d920fc691e2e8f97ced5ccf057651ca53))
22+
* **StorageGroups:** fix latency column ([#1403](https://github.com/ydb-platform/ydb-embedded-ui/issues/1403)) ([5e1961c](https://github.com/ydb-platform/ydb-embedded-ui/commit/5e1961c72d2904be7a7700259c1b517c5fa997db))
23+
* **Storage:** prevent duplicating vdisks when no whiteboard ([#1420](https://github.com/ydb-platform/ydb-embedded-ui/issues/1420)) ([73e9e6b](https://github.com/ydb-platform/ydb-embedded-ui/commit/73e9e6bf939873c497b900286f8557ba12621917))
24+
* tracelevel none by default ([#1432](https://github.com/ydb-platform/ydb-embedded-ui/issues/1432)) ([1c786cb](https://github.com/ydb-platform/ydb-embedded-ui/commit/1c786cb2b62e2470b79193b6b2d10b46ed384ff6))
25+
* use babel loader from create-react-app ([#1409](https://github.com/ydb-platform/ydb-embedded-ui/issues/1409)) ([0a4734e](https://github.com/ydb-platform/ydb-embedded-ui/commit/0a4734ebc54c036c422fd269e8e6b691af5a6b5d))
26+
327
## [6.23.1](https://github.com/ydb-platform/ydb-embedded-ui/compare/v6.23.0...v6.23.1) (2024-10-03)
428

529

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

src/components/PaginatedTable/PaginatedTable.tsx

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import type {
1919
RenderErrorMessage,
2020
SortParams,
2121
} from './types';
22-
import {useIntersectionObserver} from './useIntersectionObserver';
22+
import {useScrollBasedChunks} from './useScrollBasedChunks';
2323

2424
import './PaginatedTable.scss';
2525

@@ -32,7 +32,7 @@ export interface PaginatedTableProps<T, F> {
3232
columns: Column<T>[];
3333
getRowClassName?: GetRowClassName<T>;
3434
rowHeight?: number;
35-
parentContainer?: Element | null;
35+
parentRef?: React.RefObject<HTMLElement>;
3636
initialSortParams?: SortParams;
3737
onColumnsResize?: HandleTableColumnsResize;
3838
renderControls?: RenderControls;
@@ -50,7 +50,7 @@ export const PaginatedTable = <T, F>({
5050
columns,
5151
getRowClassName,
5252
rowHeight = DEFAULT_TABLE_ROW_HEIGHT,
53-
parentContainer,
53+
parentRef,
5454
initialSortParams,
5555
onColumnsResize,
5656
renderControls,
@@ -64,46 +64,36 @@ export const PaginatedTable = <T, F>({
6464
const [sortParams, setSortParams] = React.useState<SortParams | undefined>(initialSortParams);
6565
const [totalEntities, setTotalEntities] = React.useState(initialTotal);
6666
const [foundEntities, setFoundEntities] = React.useState(initialFound);
67-
const [activeChunks, setActiveChunks] = React.useState<number[]>([]);
6867
const [isInitialLoad, setIsInitialLoad] = React.useState(true);
6968

70-
const tableContainer = React.useRef<HTMLDivElement>(null);
69+
const tableRef = React.useRef<HTMLDivElement>(null);
70+
71+
const activeChunks = useScrollBasedChunks({
72+
containerRef: parentRef ?? tableRef,
73+
totalItems: foundEntities,
74+
itemHeight: rowHeight,
75+
chunkSize: limit,
76+
});
7177

7278
const handleDataFetched = React.useCallback((total: number, found: number) => {
7379
setTotalEntities(total);
7480
setFoundEntities(found);
7581
setIsInitialLoad(false);
7682
}, []);
7783

78-
const onEntry = React.useCallback((id: string) => {
79-
setActiveChunks((prev) => [...new Set([...prev, Number(id)])]);
80-
}, []);
81-
82-
const onLeave = React.useCallback((id: string) => {
83-
setActiveChunks((prev) => prev.filter((chunk) => chunk !== Number(id)));
84-
}, []);
85-
86-
const observer = useIntersectionObserver({onEntry, onLeave, parentContainer});
87-
8884
// reset table on filters change
8985
React.useLayoutEffect(() => {
9086
setTotalEntities(initialTotal);
9187
setFoundEntities(initialFound);
9288
setIsInitialLoad(true);
93-
if (parentContainer) {
94-
parentContainer.scrollTo(0, 0);
89+
if (parentRef?.current) {
90+
parentRef.current.scrollTo(0, 0);
9591
} else {
96-
tableContainer.current?.scrollTo(0, 0);
92+
tableRef.current?.scrollTo(0, 0);
9793
}
98-
99-
setActiveChunks([0]);
100-
}, [filters, initialFound, initialTotal, limit, parentContainer]);
94+
}, [filters, initialFound, initialTotal, limit, parentRef]);
10195

10296
const renderChunks = () => {
103-
if (!observer) {
104-
return null;
105-
}
106-
10797
if (!isInitialLoad && foundEntities === 0) {
10898
return (
10999
<tbody>
@@ -133,7 +123,6 @@ export const PaginatedTable = <T, F>({
133123
renderErrorMessage={renderErrorMessage}
134124
onDataFetched={handleDataFetched}
135125
isActive={activeChunks.includes(value)}
136-
observer={observer}
137126
/>
138127
));
139128
};
@@ -161,7 +150,7 @@ export const PaginatedTable = <T, F>({
161150
};
162151

163152
return (
164-
<div ref={tableContainer} className={b(null, containerClassName)}>
153+
<div ref={tableRef} className={b(null, containerClassName)}>
165154
{renderContent()}
166155
</div>
167156
);

src/components/PaginatedTable/TableChunk.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import type {Column, FetchData, GetRowClassName, SortParams} from './types';
1111

1212
const DEBOUNCE_TIMEOUT = 200;
1313

14-
// With original memo generic types are lost
15-
const typedMemo: <T>(Component: T) => T = React.memo;
16-
1714
interface TableChunkProps<T, F> {
1815
id: number;
1916
limit: number;
@@ -22,7 +19,6 @@ interface TableChunkProps<T, F> {
2219
columns: Column<T>[];
2320
filters?: F;
2421
sortParams?: SortParams;
25-
observer: IntersectionObserver;
2622
isActive: boolean;
2723
tableName: string;
2824

@@ -33,7 +29,7 @@ interface TableChunkProps<T, F> {
3329
}
3430

3531
// Memoisation prevents chunks rerenders that could cause perfomance issues on big tables
36-
export const TableChunk = typedMemo(function TableChunk<T, F>({
32+
export const TableChunk = <T, F>({
3733
id,
3834
limit,
3935
totalLength,
@@ -43,13 +39,11 @@ export const TableChunk = typedMemo(function TableChunk<T, F>({
4339
tableName,
4440
filters,
4541
sortParams,
46-
observer,
4742
getRowClassName,
4843
renderErrorMessage,
4944
onDataFetched,
5045
isActive,
51-
}: TableChunkProps<T, F>) {
52-
const ref = React.useRef<HTMLTableSectionElement>(null);
46+
}: TableChunkProps<T, F>) => {
5347
const [isTimeoutActive, setIsTimeoutActive] = React.useState(true);
5448
const [autoRefreshInterval] = useAutoRefreshInterval();
5549

@@ -83,19 +77,6 @@ export const TableChunk = typedMemo(function TableChunk<T, F>({
8377
};
8478
}, [isActive, isTimeoutActive]);
8579

86-
React.useEffect(() => {
87-
const el = ref.current;
88-
if (el) {
89-
observer.observe(el);
90-
}
91-
92-
return () => {
93-
if (el) {
94-
observer.unobserve(el);
95-
}
96-
};
97-
}, [observer]);
98-
9980
React.useEffect(() => {
10081
if (currentData && isActive) {
10182
const {total = 0, found = 0} = currentData;
@@ -154,7 +135,6 @@ export const TableChunk = typedMemo(function TableChunk<T, F>({
154135

155136
return (
156137
<tbody
157-
ref={ref}
158138
id={id.toString()}
159139
style={{
160140
height: `${chunkHeight}px`,
@@ -167,4 +147,4 @@ export const TableChunk = typedMemo(function TableChunk<T, F>({
167147
{renderContent()}
168148
</tbody>
169149
);
170-
});
150+
};

src/components/PaginatedTable/useIntersectionObserver.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from 'react';
2+
3+
import {throttle} from 'lodash';
4+
5+
import {getArray} from '../../utils';
6+
7+
interface UseScrollBasedChunksProps {
8+
containerRef: React.RefObject<HTMLElement>;
9+
totalItems: number;
10+
itemHeight: number;
11+
chunkSize: number;
12+
}
13+
14+
const THROTTLE_DELAY = 100;
15+
const CHUNKS_AHEAD_COUNT = 1;
16+
17+
export const useScrollBasedChunks = ({
18+
containerRef,
19+
totalItems,
20+
itemHeight,
21+
chunkSize,
22+
}: UseScrollBasedChunksProps): number[] => {
23+
const [activeChunks, setActiveChunks] = React.useState<number[]>(
24+
getArray(1 + CHUNKS_AHEAD_COUNT).map((index) => index),
25+
);
26+
27+
const calculateActiveChunks = React.useCallback(() => {
28+
const container = containerRef.current;
29+
if (!container) {
30+
return;
31+
}
32+
33+
const {scrollTop, clientHeight} = container;
34+
const visibleStartIndex = Math.floor(scrollTop / itemHeight);
35+
const visibleEndIndex = Math.min(
36+
Math.ceil((scrollTop + clientHeight) / itemHeight),
37+
totalItems - 1,
38+
);
39+
40+
const startChunk = Math.floor(visibleStartIndex / chunkSize);
41+
const endChunk = Math.floor(visibleEndIndex / chunkSize);
42+
43+
const newActiveChunks = getArray(endChunk - startChunk + 1 + CHUNKS_AHEAD_COUNT).map(
44+
(index) => startChunk + index,
45+
);
46+
47+
setActiveChunks(newActiveChunks);
48+
}, [chunkSize, containerRef, itemHeight, totalItems]);
49+
50+
const throttledCalculateActiveChunks = React.useMemo(
51+
() => throttle(calculateActiveChunks, THROTTLE_DELAY),
52+
[calculateActiveChunks],
53+
);
54+
55+
React.useEffect(() => {
56+
const container = containerRef.current;
57+
if (!container) {
58+
return undefined;
59+
}
60+
61+
container.addEventListener('scroll', throttledCalculateActiveChunks);
62+
return () => {
63+
container.removeEventListener('scroll', throttledCalculateActiveChunks);
64+
throttledCalculateActiveChunks.cancel();
65+
};
66+
}, [containerRef, throttledCalculateActiveChunks]);
67+
68+
return activeChunks;
69+
};

src/components/VDisk/VDisk.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
border-radius: 4px; // to match interactive area with disk shape
33

44
&__content {
5+
display: block;
6+
57
border-radius: 4px; // to match interactive area with disk shape
68
}
79
}

0 commit comments

Comments
 (0)