Skip to content

Commit d9a049f

Browse files
fix: require ConnectStatus only for network table (#2510)
1 parent f3b573a commit d9a049f

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

src/components/NetworkTable/columns.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
getConnectionsColumn,
66
getCpuColumn,
77
getDataCenterColumn,
8-
getHostColumn,
8+
getNetworkHostColumn,
99
getNetworkUtilizationColumn,
1010
getNodeIdColumn,
1111
getPingTimeColumn,
@@ -21,7 +21,7 @@ import type {GetNodesColumnsParams} from '../nodesColumns/types';
2121
export function getNetworkTableNodesColumns(params: GetNodesColumnsParams) {
2222
const columns: Column<NodesPreparedEntity>[] = [
2323
getNodeIdColumn(),
24-
getHostColumn(params, {statusForIcon: 'ConnectStatus'}),
24+
getNetworkHostColumn(params),
2525
getDataCenterColumn(),
2626
getRackColumn(),
2727
getUptimeColumn(),

src/components/NodeHostWrapper/NodeHostWrapper.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,18 @@ export type NodeHostData = NodeAddress &
1616
TenantName?: string;
1717
};
1818

19-
export type StatusForIcon = 'SystemState' | 'ConnectStatus';
20-
2119
interface NodeHostWrapperProps {
2220
node: NodeHostData;
2321
getNodeRef?: GetNodeRefFunc;
2422
database?: string;
25-
statusForIcon?: StatusForIcon;
23+
statusForIcon?: 'SystemState' | 'ConnectStatus';
2624
}
2725

2826
export const NodeHostWrapper = ({
2927
node,
3028
getNodeRef,
3129
database,
32-
statusForIcon,
30+
statusForIcon = 'SystemState',
3331
}: NodeHostWrapperProps) => {
3432
if (!node.Host) {
3533
return <span></span>;

src/components/nodesColumns/columns.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {bytesToSpeed, isNumeric} from '../../utils/utils';
1717
import {CellWithPopover} from '../CellWithPopover/CellWithPopover';
1818
import {MemoryViewer} from '../MemoryViewer/MemoryViewer';
1919
import {NodeHostWrapper} from '../NodeHostWrapper/NodeHostWrapper';
20-
import type {NodeHostData, StatusForIcon} from '../NodeHostWrapper/NodeHostWrapper';
20+
import type {NodeHostData} from '../NodeHostWrapper/NodeHostWrapper';
2121
import {PoolsGraph} from '../PoolsGraph/PoolsGraph';
2222
import {ProgressViewer} from '../ProgressViewer/ProgressViewer';
2323
import {TabletsStatistic} from '../TabletsStatistic';
@@ -44,20 +44,38 @@ export function getNodeIdColumn<T extends {NodeId?: string | number}>(): Column<
4444
align: DataTable.RIGHT,
4545
};
4646
}
47-
export function getHostColumn<T extends NodeHostData>(
48-
{getNodeRef, database}: GetNodesColumnsParams,
49-
{statusForIcon = 'SystemState'}: {statusForIcon?: StatusForIcon} = {},
50-
): Column<T> {
47+
export function getHostColumn<T extends NodeHostData>({
48+
getNodeRef,
49+
database,
50+
}: GetNodesColumnsParams): Column<T> {
5151
return {
5252
name: NODES_COLUMNS_IDS.Host,
5353
header: NODES_COLUMNS_TITLES.Host,
54+
render: ({row}) => {
55+
return <NodeHostWrapper node={row} getNodeRef={getNodeRef} database={database} />;
56+
},
57+
width: 350,
58+
align: DataTable.LEFT,
59+
};
60+
}
61+
62+
// Different column for different set of required fields
63+
// ConnectStatus is required here, it makes handler to return network stats
64+
// On versions before 25-1-2 ConnectStatus also makes handler to return peers - it can significantly increase response size
65+
export function getNetworkHostColumn<T extends NodeHostData>({
66+
getNodeRef,
67+
database,
68+
}: GetNodesColumnsParams): Column<T> {
69+
return {
70+
name: NODES_COLUMNS_IDS.NetworkHost,
71+
header: NODES_COLUMNS_TITLES.NetworkHost,
5472
render: ({row}) => {
5573
return (
5674
<NodeHostWrapper
5775
node={row}
5876
getNodeRef={getNodeRef}
5977
database={database}
60-
statusForIcon={statusForIcon}
78+
statusForIcon={'ConnectStatus'}
6179
/>
6280
);
6381
},

src/components/nodesColumns/constants.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const NODES_COLUMNS_WIDTH_LS_KEY = 'nodesTableColumnsWidth';
88
export const NODES_COLUMNS_IDS = {
99
NodeId: 'NodeId',
1010
Host: 'Host',
11+
NetworkHost: 'NetworkHost',
1112
Database: 'Database',
1213
NodeName: 'NodeName',
1314
DC: 'DC',
@@ -51,6 +52,9 @@ export const NODES_COLUMNS_TITLES = {
5152
get Host() {
5253
return i18n('host');
5354
},
55+
get NetworkHost() {
56+
return i18n('host');
57+
},
5458
get Database() {
5559
return i18n('database');
5660
},
@@ -178,7 +182,8 @@ export function getNodesGroupByFieldTitle(groupByField: NodesGroupByField) {
178182
// Also for some columns we may use more than one field
179183
export const NODES_COLUMNS_TO_DATA_FIELDS: Record<NodesColumnId, NodesRequiredField[]> = {
180184
NodeId: ['NodeId'],
181-
Host: ['Host', 'Rack', 'Database', 'SystemState', 'ConnectStatus'],
185+
Host: ['Host', 'Rack', 'Database', 'SystemState'],
186+
NetworkHost: ['Host', 'Rack', 'Database', 'SystemState', 'ConnectStatus'],
182187
Database: ['Database'],
183188
NodeName: ['NodeName'],
184189
DC: ['DC'],
@@ -207,6 +212,7 @@ export const NODES_COLUMNS_TO_DATA_FIELDS: Record<NodesColumnId, NodesRequiredFi
207212
const NODES_COLUMNS_TO_SORT_FIELDS: Record<NodesColumnId, NodesSortValue | undefined> = {
208213
NodeId: 'NodeId',
209214
Host: 'Host',
215+
NetworkHost: 'Host',
210216
Database: 'Database',
211217
NodeName: 'NodeName',
212218
DC: 'DC',

0 commit comments

Comments
 (0)