Skip to content

Commit e63d22b

Browse files
fix(PaginatedStorage): properly pass ids, display 1 node on Node page (#1382)
1 parent a4c24e1 commit e63d22b

File tree

9 files changed

+112
-24
lines changed

9 files changed

+112
-24
lines changed

src/containers/Storage/PaginatedStorage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import {useStorageQueryParams} from './useStorageQueryParams';
44

55
export interface PaginatedStorageProps {
66
database?: string;
7-
nodeId?: string;
8-
groupId?: string;
7+
nodeId?: string | number;
8+
groupId?: string | number;
9+
pDiskId?: string | number;
10+
911
parentContainer?: Element | null;
1012
}
1113

src/containers/Storage/PaginatedStorageGroups.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,18 @@ export function PaginatedStorageGroups(props: PaginatedStorageProps) {
4949
return <LoaderWrapper loading={!capabilitiesLoaded}>{renderContent()}</LoaderWrapper>;
5050
}
5151

52-
function StorageGroupsComponent({database, nodeId, parentContainer}: PaginatedStorageProps) {
52+
function StorageGroupsComponent({
53+
database,
54+
nodeId,
55+
groupId,
56+
pDiskId,
57+
parentContainer,
58+
}: PaginatedStorageProps) {
5359
const {searchValue, visibleEntities, handleShowAllGroups} = useStorageQueryParams();
5460

5561
const {columnsToShow, columnsToSelect, setColumns} = useStorageGroupsSelectedColumns({
5662
visibleEntities,
57-
nodeId,
63+
nodeId: nodeId?.toString(),
5864
});
5965

6066
const renderControls: RenderControls = ({totalEntities, foundEntities, inited}) => {
@@ -75,6 +81,8 @@ function StorageGroupsComponent({database, nodeId, parentContainer}: PaginatedSt
7581
<PaginatedStorageGroupsTable
7682
database={database}
7783
nodeId={nodeId}
84+
groupId={groupId}
85+
pDiskId={pDiskId}
7886
searchValue={searchValue}
7987
visibleEntities={visibleEntities}
8088
onShowAll={handleShowAllGroups}
@@ -86,14 +94,19 @@ function StorageGroupsComponent({database, nodeId, parentContainer}: PaginatedSt
8694
);
8795
}
8896

89-
function GroupedStorageGroupsComponent({database, groupId, nodeId}: PaginatedStorageProps) {
97+
function GroupedStorageGroupsComponent({
98+
database,
99+
nodeId,
100+
groupId,
101+
pDiskId,
102+
}: PaginatedStorageProps) {
90103
const [autoRefreshInterval] = useAutoRefreshInterval();
91104
const {searchValue, storageGroupsGroupByParam, visibleEntities, handleShowAllGroups} =
92105
useStorageQueryParams();
93106

94107
const {columnsToShow, columnsToSelect, setColumns} = useStorageGroupsSelectedColumns({
95108
visibleEntities,
96-
nodeId,
109+
nodeId: nodeId?.toString(),
97110
});
98111

99112
const {currentData, isFetching, error} = storageApi.useGetStorageGroupsInfoQuery(
@@ -102,6 +115,7 @@ function GroupedStorageGroupsComponent({database, groupId, nodeId}: PaginatedSto
102115
with: 'all',
103116
nodeId,
104117
groupId,
118+
pDiskId,
105119
filter: searchValue,
106120
shouldUseGroupsHandler: true,
107121
group: storageGroupsGroupByParam,
@@ -147,6 +161,8 @@ function GroupedStorageGroupsComponent({database, groupId, nodeId}: PaginatedSto
147161
<PaginatedStorageGroupsTable
148162
database={database}
149163
nodeId={nodeId}
164+
groupId={groupId}
165+
pDiskId={pDiskId}
150166
filterGroup={name}
151167
filterGroupBy={storageGroupsGroupByParam}
152168
searchValue={searchValue}

src/containers/Storage/PaginatedStorageNodes.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from '../../store/reducers/capabilities/hooks';
1111
import {useClusterBaseInfo} from '../../store/reducers/cluster/cluster';
1212
import {storageApi} from '../../store/reducers/storage/storage';
13-
import {valueIsDefined} from '../../utils';
1413
import {useAutoRefreshInterval} from '../../utils/hooks';
1514
import {NodesUptimeFilterValues} from '../../utils/nodes';
1615
import {useAdditionalNodeProps} from '../AppWithClusters/useClusterData';
@@ -57,13 +56,18 @@ export const PaginatedStorageNodes = (props: PaginatedStorageProps) => {
5756
return <LoaderWrapper loading={!capabilitiesLoaded}>{renderContent()}</LoaderWrapper>;
5857
};
5958

60-
function StorageNodesComponent({database, groupId, parentContainer}: PaginatedStorageProps) {
59+
function StorageNodesComponent({
60+
database,
61+
nodeId,
62+
groupId,
63+
parentContainer,
64+
}: PaginatedStorageProps) {
6165
const {searchValue, visibleEntities, nodesUptimeFilter, handleShowAllNodes} =
6266
useStorageQueryParams();
6367

6468
const {columnsToShow, columnsToSelect, setColumns} = useStorageNodesColumnsToSelect({
6569
database,
66-
groupId,
70+
groupId: groupId?.toString(),
6771
});
6872

6973
const renderControls: RenderControls = ({totalEntities, foundEntities, inited}) => {
@@ -83,6 +87,8 @@ function StorageNodesComponent({database, groupId, parentContainer}: PaginatedSt
8387
return (
8488
<PaginatedStorageNodesTable
8589
database={database}
90+
nodeId={nodeId}
91+
groupId={groupId}
8692
searchValue={searchValue}
8793
visibleEntities={visibleEntities}
8894
nodesUptimeFilter={nodesUptimeFilter}
@@ -102,7 +108,7 @@ function GroupedStorageNodesComponent({database, groupId, nodeId}: PaginatedStor
102108

103109
const {columnsToShow, columnsToSelect, setColumns} = useStorageNodesColumnsToSelect({
104110
database,
105-
groupId,
111+
groupId: groupId?.toString(),
106112
});
107113

108114
const {currentData, isFetching, error} = storageApi.useGetStorageNodesInfoQuery(
@@ -111,8 +117,7 @@ function GroupedStorageNodesComponent({database, groupId, nodeId}: PaginatedStor
111117
with: 'all',
112118
filter: searchValue,
113119
node_id: nodeId,
114-
// node_id and group_id params don't work together
115-
group_id: valueIsDefined(nodeId) ? undefined : groupId,
120+
group_id: groupId,
116121
group: storageNodesGroupByParam,
117122
},
118123
{
@@ -155,6 +160,8 @@ function GroupedStorageNodesComponent({database, groupId, nodeId}: PaginatedStor
155160
>
156161
<PaginatedStorageNodesTable
157162
database={database}
163+
nodeId={nodeId}
164+
groupId={groupId}
158165
searchValue={searchValue}
159166
visibleEntities={'all'}
160167
nodesUptimeFilter={NodesUptimeFilterValues.All}

src/containers/Storage/Storage.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {NodesSortParams} from '../../store/reducers/nodes/types';
1313
import {filterGroups, filterNodes} from '../../store/reducers/storage/selectors';
1414
import {storageApi} from '../../store/reducers/storage/storage';
1515
import type {StorageSortParams} from '../../store/reducers/storage/types';
16-
import {valueIsDefined} from '../../utils';
1716
import {useAutoRefreshInterval, useTableSort} from '../../utils/hooks';
1817
import {useAdditionalNodeProps} from '../AppWithClusters/useClusterData';
1918

@@ -90,8 +89,7 @@ export const Storage = ({database, nodeId, groupId, pDiskId}: StorageProps) => {
9089
database,
9190
with: visibleEntities,
9291
node_id: nodeId,
93-
// node_id and group_id params don't work together
94-
group_id: valueIsDefined(nodeId) ? undefined : groupId,
92+
group_id: groupId,
9593
},
9694
{
9795
skip: !isNodes,

src/containers/Storage/StorageGroups/PaginatedStorageGroupsTable.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ interface PaginatedStorageGroupsTableProps {
2121
columns: StorageGroupsColumn[];
2222

2323
database?: string;
24-
nodeId?: string;
24+
nodeId?: string | number;
25+
groupId?: string | number;
26+
pDiskId?: string | number;
2527

2628
filterGroup?: string;
2729
filterGroupBy?: GroupsGroupByField;
@@ -40,6 +42,8 @@ export const PaginatedStorageGroupsTable = ({
4042
columns,
4143
database,
4244
nodeId,
45+
groupId,
46+
pDiskId,
4347
filterGroup,
4448
filterGroupBy,
4549
searchValue,
@@ -56,8 +60,26 @@ export const PaginatedStorageGroupsTable = ({
5660
const fetchData = useGroupsGetter(groupsHandlerAvailable);
5761

5862
const tableFilters = React.useMemo(() => {
59-
return {searchValue, visibleEntities, database, nodeId, filterGroup, filterGroupBy};
60-
}, [searchValue, visibleEntities, database, nodeId, filterGroup, filterGroupBy]);
63+
return {
64+
searchValue,
65+
visibleEntities,
66+
database,
67+
nodeId,
68+
groupId,
69+
pDiskId,
70+
filterGroup,
71+
filterGroupBy,
72+
};
73+
}, [
74+
searchValue,
75+
visibleEntities,
76+
database,
77+
nodeId,
78+
groupId,
79+
pDiskId,
80+
filterGroup,
81+
filterGroupBy,
82+
]);
6183

6284
const renderEmptyDataMessage = () => {
6385
if (visibleEntities !== VISIBLE_ENTITIES.all) {

src/containers/Storage/StorageGroups/getGroups.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ export function useGroupsGetter(shouldUseGroupsHandler: boolean) {
1616
async (params) => {
1717
const {limit, offset, sortParams, filters} = params;
1818
const {sortOrder, columnId} = sortParams ?? {};
19-
const {searchValue, visibleEntities, database, nodeId, filterGroup, filterGroupBy} =
20-
filters ?? {};
19+
const {
20+
searchValue,
21+
visibleEntities,
22+
database,
23+
nodeId,
24+
groupId,
25+
pDiskId,
26+
filterGroup,
27+
filterGroupBy,
28+
} = filters ?? {};
2129

2230
const sort = isSortableStorageProperty(columnId)
2331
? prepareSortValue(columnId, sortOrder)
@@ -31,6 +39,8 @@ export function useGroupsGetter(shouldUseGroupsHandler: boolean) {
3139
with: visibleEntities,
3240
database,
3341
nodeId,
42+
groupId,
43+
pDiskId,
3444
filter_group: filterGroup,
3545
filter_group_by: filterGroupBy,
3646
shouldUseGroupsHandler,

src/containers/Storage/StorageNodes/PaginatedStorageNodesTable.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ interface PaginatedStorageNodesTableProps {
1818
columns: StorageNodesColumn[];
1919

2020
database?: string;
21+
nodeId?: string | number;
22+
groupId?: string | number;
2123

2224
filterGroup?: string;
2325
filterGroupBy?: NodesGroupByField;
@@ -36,6 +38,8 @@ interface PaginatedStorageNodesTableProps {
3638
export const PaginatedStorageNodesTable = ({
3739
columns,
3840
database,
41+
nodeId,
42+
groupId,
3943
filterGroup,
4044
filterGroupBy,
4145
searchValue,
@@ -53,10 +57,21 @@ export const PaginatedStorageNodesTable = ({
5357
visibleEntities,
5458
nodesUptimeFilter,
5559
database,
60+
nodeId,
61+
groupId,
5662
filterGroup,
5763
filterGroupBy,
5864
};
59-
}, [searchValue, visibleEntities, nodesUptimeFilter, database, filterGroup, filterGroupBy]);
65+
}, [
66+
searchValue,
67+
visibleEntities,
68+
nodesUptimeFilter,
69+
database,
70+
nodeId,
71+
groupId,
72+
filterGroup,
73+
filterGroupBy,
74+
]);
6075

6176
const renderEmptyDataMessage = () => {
6277
if (

src/containers/Storage/StorageNodes/getNodes.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ export const getStorageNodes: FetchData<
1414
Pick<NodesRequestParams, 'type' | 'storage'>
1515
> = async (params) => {
1616
const {type = 'static', storage = true, limit, offset, sortParams, filters} = params;
17-
const {searchValue, nodesUptimeFilter, visibleEntities, database, filterGroup, filterGroupBy} =
18-
filters ?? {};
17+
const {
18+
searchValue,
19+
nodesUptimeFilter,
20+
visibleEntities,
21+
database,
22+
nodeId,
23+
groupId,
24+
filterGroup,
25+
filterGroupBy,
26+
} = filters ?? {};
1927
const {sortOrder, columnId} = sortParams ?? {};
2028

2129
const sort = isSortableNodesProperty(columnId)
@@ -32,6 +40,8 @@ export const getStorageNodes: FetchData<
3240
uptime: getUptimeParamValue(nodesUptimeFilter),
3341
with: visibleEntities,
3442
database,
43+
node_id: nodeId,
44+
group_id: groupId,
3545
filter_group: filterGroup,
3646
filter_group_by: filterGroupBy,
3747
});

src/store/reducers/storage/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export interface PreparedStorageNodeFilters {
1818
searchValue: string;
1919
nodesUptimeFilter: NodesUptimeFilterValues;
2020
visibleEntities: VisibleEntities;
21+
2122
database?: string;
23+
nodeId?: string | number;
24+
groupId?: string | number;
25+
2226
filterGroup?: string;
2327
filterGroupBy?: NodesGroupByField;
2428
}
@@ -38,8 +42,12 @@ export interface PreparedStorageNode extends TSystemStateInfo {
3842
export interface PreparedStorageGroupFilters {
3943
searchValue: string;
4044
visibleEntities: VisibleEntities;
45+
4146
database?: string;
42-
nodeId?: string;
47+
nodeId?: string | number;
48+
groupId?: string | number;
49+
pDiskId?: string | number;
50+
4351
filterGroup?: string;
4452
filterGroupBy?: GroupsGroupByField;
4553
}

0 commit comments

Comments
 (0)