Skip to content

Commit 9158050

Browse files
feat: use VirtualTable in Nodes and Diagnostics (#678)
1 parent c206c8d commit 9158050

File tree

8 files changed

+32
-20
lines changed

8 files changed

+32
-20
lines changed

src/components/VirtualTable/useIntersectionObserver.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {DEFAULT_INTERSECTION_OBSERVER_MARGIN} from './constants';
66
interface UseIntersectionObserverProps {
77
onEntry: OnEntry;
88
onLeave: OnLeave;
9+
/** Intersection observer calculate margins based on container element properties */
910
parentContainer?: Element | null;
1011
}
1112

src/containers/Node/Node.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import {useEffect, useMemo, useRef} from 'react';
22
import {useLocation, useRouteMatch} from 'react-router';
33
import cn from 'bem-cn-lite';
44
import {useDispatch} from 'react-redux';
@@ -8,7 +8,7 @@ import {Link} from 'react-router-dom';
88

99
import {TABLETS, STORAGE, NODE_PAGES, OVERVIEW, STRUCTURE} from './NodePages';
1010
import {Tablets} from '../Tablets';
11-
import {Storage} from '../Storage/Storage';
11+
import {StorageWrapper} from '../Storage/StorageWrapper';
1212
import NodeStructure from './NodeStructure/NodeStructure';
1313
import {Loader} from '../../components/Loader';
1414
import {BasicNodeViewer} from '../../components/BasicNodeViewer';
@@ -38,6 +38,8 @@ interface NodeProps {
3838
}
3939

4040
function Node(props: NodeProps) {
41+
const container = useRef<HTMLDivElement>(null);
42+
4143
const dispatch = useDispatch();
4244
const location = useLocation();
4345

@@ -50,7 +52,7 @@ function Node(props: NodeProps) {
5052
const {id: nodeId, activeTab} = match.params;
5153
const {tenantName: tenantNameFromQuery} = parseQuery(location);
5254

53-
const {activeTabVerified, nodeTabs} = React.useMemo(() => {
55+
const {activeTabVerified, nodeTabs} = useMemo(() => {
5456
const hasStorage = node?.Roles?.find((el) => el === STORAGE_ROLE);
5557

5658
let actualActiveTab = activeTab;
@@ -69,7 +71,7 @@ function Node(props: NodeProps) {
6971
return {activeTabVerified: actualActiveTab, nodeTabs: actualNodeTabs};
7072
}, [activeTab, node]);
7173

72-
React.useEffect(() => {
74+
useEffect(() => {
7375
const tenantName = node?.Tenants?.[0] || tenantNameFromQuery?.toString();
7476

7577
dispatch(
@@ -81,7 +83,7 @@ function Node(props: NodeProps) {
8183
);
8284
}, [dispatch, node, nodeId, tenantNameFromQuery]);
8385

84-
React.useEffect(() => {
86+
useEffect(() => {
8587
const fetchData = () => dispatch(getNodeInfo(nodeId));
8688
fetchData();
8789
autofetcher.start();
@@ -119,7 +121,7 @@ function Node(props: NodeProps) {
119121
case STORAGE: {
120122
return (
121123
<div className={b('storage')}>
122-
<Storage nodeId={nodeId} />
124+
<StorageWrapper nodeId={nodeId} parentContainer={container.current} />
123125
</div>
124126
);
125127
}
@@ -146,7 +148,7 @@ function Node(props: NodeProps) {
146148
} else {
147149
if (node) {
148150
return (
149-
<div className={b(null, props.className)}>
151+
<div className={b(null, props.className)} ref={container}>
150152
<BasicNodeViewer
151153
node={node}
152154
additionalNodesProps={props.additionalNodesProps}

src/containers/Nodes/NodesWrapper.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {VirtualNodes} from './VirtualNodes';
66
import {Nodes} from './Nodes';
77

88
interface NodesWrapperProps {
9+
path?: string;
910
parentContainer?: Element | null;
1011
additionalNodesProps?: AdditionalNodesProps;
1112
}

src/containers/Nodes/VirtualNodes.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,36 @@ import './Nodes.scss';
3838
const b = cn('ydb-nodes');
3939

4040
interface NodesProps {
41+
path?: string;
4142
parentContainer?: Element | null;
4243
additionalNodesProps?: AdditionalNodesProps;
4344
}
4445

45-
export const VirtualNodes = ({parentContainer, additionalNodesProps}: NodesProps) => {
46+
export const VirtualNodes = ({path, parentContainer, additionalNodesProps}: NodesProps) => {
4647
const [searchValue, setSearchValue] = useState('');
4748
const [problemFilter, setProblemFilter] = useState<ProblemFilterValue>(ProblemFilterValues.ALL);
4849
const [uptimeFilter, setUptimeFilter] = useState<NodesUptimeFilterValues>(
4950
NodesUptimeFilterValues.All,
5051
);
5152

5253
const filters = useMemo(() => {
53-
return [searchValue, problemFilter, uptimeFilter];
54-
}, [searchValue, problemFilter, uptimeFilter]);
54+
return [path, searchValue, problemFilter, uptimeFilter];
55+
}, [path, searchValue, problemFilter, uptimeFilter]);
5556

5657
const fetchData = useCallback<FetchData<NodesPreparedEntity>>(
5758
async (limit, offset, {sortOrder, columnId} = {}) => {
5859
return await getNodes({
5960
limit,
6061
offset,
62+
path,
6163
filter: searchValue,
6264
problems_only: getProblemParamValue(problemFilter),
6365
uptime: getUptimeParamValue(uptimeFilter),
6466
sortOrder,
6567
sortValue: columnId as NodesSortValue,
6668
});
6769
},
68-
[problemFilter, searchValue, uptimeFilter],
70+
[path, problemFilter, searchValue, uptimeFilter],
6971
);
7072

7173
const getRowClassName: GetRowClassName<NodesPreparedEntity> = (row) => {

src/containers/Tenant/Diagnostics/Diagnostics.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
padding-top: 0;
4646
}
4747

48-
.data-table__sticky_moving {
48+
.data-table__sticky_moving,
49+
.ydb-virtual-table__head {
4950
top: 46px !important;
5051
}
5152
}

src/containers/Tenant/Diagnostics/Diagnostics.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useMemo} from 'react';
1+
import {useMemo, useRef} from 'react';
22
import qs from 'qs';
33
import cn from 'bem-cn-lite';
44
import {Link} from 'react-router-dom';
@@ -20,8 +20,8 @@ import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../store/reducers/tenant/consta
2020
import {Loader} from '../../../components/Loader';
2121

2222
import {Heatmap} from '../../Heatmap';
23-
import {Nodes} from '../../Nodes';
24-
import {Storage} from '../../Storage/Storage';
23+
import {NodesWrapper} from '../../Nodes/NodesWrapper';
24+
import {StorageWrapper} from '../../Storage/StorageWrapper';
2525
import {Tablets} from '../../Tablets';
2626

2727
import Describe from './Describe/Describe';
@@ -49,6 +49,8 @@ interface DiagnosticsProps {
4949
const b = cn('kv-tenant-diagnostics');
5050

5151
function Diagnostics(props: DiagnosticsProps) {
52+
const container = useRef<HTMLDivElement>(null);
53+
5254
const dispatch = useDispatch();
5355
const {currentSchemaPath, autorefresh, wasLoaded} = useSelector((state: any) => state.schema);
5456
const {diagnosticsTab = TENANT_DIAGNOSTICS_TABS_IDS.overview} = useTypedSelector(
@@ -121,17 +123,20 @@ function Diagnostics(props: DiagnosticsProps) {
121123
}
122124
case TENANT_DIAGNOSTICS_TABS_IDS.nodes: {
123125
return (
124-
<Nodes
126+
<NodesWrapper
125127
path={currentSchemaPath}
126128
additionalNodesProps={props.additionalNodesProps}
129+
parentContainer={container.current}
127130
/>
128131
);
129132
}
130133
case TENANT_DIAGNOSTICS_TABS_IDS.tablets: {
131134
return <Tablets path={currentSchemaPath} />;
132135
}
133136
case TENANT_DIAGNOSTICS_TABS_IDS.storage: {
134-
return <Storage tenant={tenantNameString} />;
137+
return (
138+
<StorageWrapper tenant={tenantNameString} parentContainer={container.current} />
139+
);
135140
}
136141
case TENANT_DIAGNOSTICS_TABS_IDS.network: {
137142
return <Network path={tenantNameString} />;
@@ -196,7 +201,7 @@ function Diagnostics(props: DiagnosticsProps) {
196201
}
197202

198203
return (
199-
<div className={b()}>
204+
<div className={b()} ref={container}>
200205
{renderTabs()}
201206
<div className={b('page-wrapper')}>{renderTabContent()}</div>
202207
</div>

src/containers/UserSettings/i18n/en.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"settings.useNodesEndpoint.title": "Break the Nodes tab in Diagnostics",
2020
"settings.useNodesEndpoint.popover": "Use /viewer/json/nodes endpoint for Nodes Tab in diagnostics. It could return incorrect data on some versions",
2121

22-
"settings.useVirtualTables.title": "Use table with data load on scroll for Nodes and Storage cluster tabs",
22+
"settings.useVirtualTables.title": "Use table with data load on scroll for Nodes and Storage tabs",
2323
"settings.useVirtualTables.popover": "It will increase performance, but could work unstable",
2424

2525
"settings.queryUseMultiSchema.title": "Allow queries with multiple result sets",

src/containers/UserSettings/i18n/ru.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"settings.useNodesEndpoint.title": "Сломать вкладку Nodes в диагностике",
2020
"settings.useNodesEndpoint.popover": "Использовать эндпоинт /viewer/json/nodes для вкладки Nodes в диагностике. Может возвращать некорректные данные на некоторых версиях",
2121

22-
"settings.useVirtualTables.title": "Использовать таблицу с загрузкой данных по скроллу для вкладок Nodes и Storage кластера",
22+
"settings.useVirtualTables.title": "Использовать таблицу с загрузкой данных по скроллу для вкладок Nodes и Storage",
2323
"settings.useVirtualTables.popover": "Это улучшит производительность, но может работать нестабильно",
2424

2525
"settings.queryUseMultiSchema.title": "Разрешить запросы с несколькими результатами",

0 commit comments

Comments
 (0)