Skip to content

Commit f4e68ed

Browse files
Copilotadameat
andcommitted
Add optional Tablets column to storage nodes and PDisks column to cluster nodes
Co-authored-by: adameat <[email protected]>
1 parent ee1430c commit f4e68ed

File tree

4 files changed

+81
-8
lines changed

4 files changed

+81
-8
lines changed

src/components/nodesColumns/NodesColumns.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,20 @@
33
&__column-cpu {
44
min-width: 40px;
55
}
6+
7+
&__pdisks-column {
8+
overflow: visible; // to enable stacked disks overflow the row
9+
}
10+
11+
&__pdisks-wrapper {
12+
display: flex;
13+
gap: 10px;
14+
15+
height: 40px;
16+
}
17+
18+
&__pdisks-item {
19+
display: flex;
20+
flex-shrink: 0;
21+
}
622
}

src/containers/Nodes/columns/columns.tsx

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import DataTable from '@gravity-ui/react-data-table';
2+
13
import {
24
getCpuColumn,
35
getDataCenterColumn,
@@ -14,10 +16,65 @@ import {
1416
getUptimeColumn,
1517
getVersionColumn,
1618
} from '../../../components/nodesColumns/columns';
17-
import {isSortableNodesColumn} from '../../../components/nodesColumns/constants';
19+
import {
20+
NODES_COLUMNS_IDS,
21+
NODES_COLUMNS_TITLES,
22+
isSortableNodesColumn,
23+
} from '../../../components/nodesColumns/constants';
1824
import type {GetNodesColumnsParams} from '../../../components/nodesColumns/types';
1925
import type {NodesPreparedEntity} from '../../../store/reducers/nodes/types';
26+
import type {TPDiskStateInfo} from '../../../types/api/pdisk';
27+
import type {TVDiskStateInfo} from '../../../types/api/vdisk';
28+
import {cn} from '../../../utils/cn';
29+
import {
30+
prepareWhiteboardPDiskData,
31+
prepareWhiteboardVDiskData,
32+
} from '../../../utils/disks/prepareDisks';
2033
import type {Column} from '../../../utils/tableUtils/types';
34+
import {PDisk} from '../../Storage/PDisk/PDisk';
35+
36+
const b = cn('ydb-nodes-columns');
37+
38+
// Extended type for nodes that may have disk information
39+
type NodeWithDisks = NodesPreparedEntity & {
40+
PDisks?: TPDiskStateInfo[];
41+
VDisks?: TVDiskStateInfo[];
42+
};
43+
44+
function getPDisksColumn(): Column<NodesPreparedEntity> {
45+
return {
46+
name: NODES_COLUMNS_IDS.PDisks,
47+
header: NODES_COLUMNS_TITLES.PDisks,
48+
className: b('pdisks-column'),
49+
render: ({row}) => {
50+
const nodeWithDisks = row as NodeWithDisks;
51+
return (
52+
<div className={b('pdisks-wrapper')}>
53+
{nodeWithDisks.PDisks?.map((pDisk) => {
54+
const preparedPDisk = prepareWhiteboardPDiskData(pDisk);
55+
const vDisks = nodeWithDisks.VDisks?.filter(
56+
(vdisk) => vdisk.PDiskId === pDisk.PDiskId,
57+
);
58+
const preparedVDisks = vDisks?.map(prepareWhiteboardVDiskData);
59+
60+
return (
61+
<div className={b('pdisks-item')} key={pDisk.PDiskId}>
62+
<PDisk
63+
data={preparedPDisk}
64+
vDisks={preparedVDisks}
65+
viewContext={{}}
66+
/>
67+
</div>
68+
);
69+
})}
70+
</div>
71+
);
72+
},
73+
align: DataTable.CENTER,
74+
sortable: false,
75+
resizeable: false,
76+
};
77+
}
2178

2279
export function getNodesColumns(params: GetNodesColumnsParams): Column<NodesPreparedEntity>[] {
2380
const columns = [
@@ -35,6 +92,7 @@ export function getNodesColumns(params: GetNodesColumnsParams): Column<NodesPrep
3592
getLoadAverageColumn<NodesPreparedEntity>(),
3693
getVersionColumn<NodesPreparedEntity>(),
3794
getTabletsColumn<NodesPreparedEntity>(params),
95+
getPDisksColumn(),
3896
];
3997

4098
return columns.map((column) => {

src/containers/Storage/PaginatedStorageNodesTable/columns/columns.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
getPoolsColumn,
1414
getRAMColumn,
1515
getRackColumn,
16+
getTabletsColumn,
1617
getUptimeColumn,
1718
getVersionColumn,
1819
} from '../../../../components/nodesColumns/columns';
@@ -97,6 +98,7 @@ export const getStorageNodesColumns = ({
9798
getDiskSpaceUsageColumn<PreparedStorageNode>(),
9899
getVersionColumn<PreparedStorageNode>(),
99100
getMissingDisksColumn<PreparedStorageNode>(),
101+
getTabletsColumn<PreparedStorageNode>({database}),
100102
getPDisksColumn({viewContext, columnsSettings}),
101103
];
102104

src/utils/yaMetrica.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import {uiFactory} from '../uiFactory/uiFactory';
22

33
/**
44
* Interface for a counter that provides methods for tracking metrics.
5-
*
6-
* @method hit - Tracks a hit event with optional arguments. https://yandex.ru/support/metrica/ru/objects/hit
7-
* @method params - Sets parameters for the counter with optional arguments. https://yandex.ru/support/metrica/ru/objects/params-method
8-
* @method userParams - Sets user-specific parameters for the counter with optional arguments. https://yandex.ru/support/metrica/ru/objects/user-params
9-
* @method reachGoal - Tracks a goal achievement event with optional arguments. https://yandex.ru/support/metrica/ru/objects/reachgoal
5+
* @function hit - Tracks a hit event with optional arguments. https://yandex.ru/support/metrica/ru/objects/hit
6+
* @function params - Sets parameters for the counter with optional arguments. https://yandex.ru/support/metrica/ru/objects/params-method
7+
* @function userParams - Sets user-specific parameters for the counter with optional arguments. https://yandex.ru/support/metrica/ru/objects/user-params
8+
* @function reachGoal - Tracks a goal achievement event with optional arguments. https://yandex.ru/support/metrica/ru/objects/reachgoal
109
*/
1110
export interface Counter {
1211
hit: (...args: unknown[]) => void;
@@ -21,7 +20,6 @@ const yaMetricaMap = uiFactory.yaMetricaMap;
2120
* A fake implementation of a counter metric for Yandex.Metrica.
2221
* This class is used when the actual Yandex.Metrica counter is not defined,
2322
* and it provides a warning message the first time any of its methods are called.
24-
*
2523
* @property name - The name of the counter.
2624
* @property warnShown - Flag to indicate if the warning has been shown.
2725
*/
@@ -61,7 +59,6 @@ class FakeMetrica implements Counter {
6159
/**
6260
* Retrieves a Yandex Metrica instance by name from the global window object.
6361
* If no instance is found for the given name, returns a FakeMetrica instance instead.
64-
*
6562
* @param name The name of the metrica to retrieve
6663
* @returns The Yandex Metrica instance if found, otherwise a FakeMetrica instance
6764
*/

0 commit comments

Comments
 (0)