Skip to content

Commit 70ad19f

Browse files
refactor(Storage): init additional nodes props inside components
1 parent 8bf1d13 commit 70ad19f

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

src/containers/Cluster/Cluster.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,7 @@ export function Cluster({
173173
getLocationObjectFromHref(getClusterPath(clusterTabsIds.storage)).pathname
174174
}
175175
>
176-
<StorageWrapper
177-
parentContainer={container.current}
178-
additionalNodesProps={additionalNodesProps}
179-
/>
176+
<StorageWrapper parentContainer={container.current} />
180177
</Route>
181178
<Route
182179
path={

src/containers/Storage/PaginatedStorage.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import {StringParam, useQueryParams} from 'use-query-params';
33
import {AccessDenied} from '../../components/Errors/403/AccessDenied';
44
import {ResponseError} from '../../components/Errors/ResponseError/ResponseError';
55
import type {RenderControls, RenderErrorMessage} from '../../components/PaginatedTable';
6+
import {useClusterBaseInfo} from '../../store/reducers/cluster/cluster';
67
import {VISIBLE_ENTITIES} from '../../store/reducers/storage/constants';
78
import {storageTypeSchema, visibleEntitiesSchema} from '../../store/reducers/storage/types';
89
import type {StorageType, VisibleEntities} from '../../store/reducers/storage/types';
9-
import type {AdditionalNodesProps} from '../../types/additionalProps';
1010
import {NodesUptimeFilterValues, nodesUptimeFilterValuesSchema} from '../../utils/nodes';
11+
import {useAdditionalNodeProps} from '../AppWithClusters/useClusterData';
1112

1213
import {StorageControls} from './StorageControls/StorageControls';
1314
import {PaginatedStorageGroups} from './StorageGroups/PaginatedStorageGroups';
@@ -19,15 +20,12 @@ interface PaginatedStorageProps {
1920
database?: string;
2021
nodeId?: string;
2122
parentContainer?: Element | null;
22-
additionalNodesProps?: AdditionalNodesProps;
2323
}
2424

25-
export const PaginatedStorage = ({
26-
database,
27-
nodeId,
28-
parentContainer,
29-
additionalNodesProps,
30-
}: PaginatedStorageProps) => {
25+
export const PaginatedStorage = ({database, nodeId, parentContainer}: PaginatedStorageProps) => {
26+
const {balancer} = useClusterBaseInfo();
27+
const additionalNodesProps = useAdditionalNodeProps({balancer});
28+
3129
const [queryParams, setQueryParams] = useQueryParams({
3230
type: StringParam,
3331
visible: StringParam,

src/containers/Storage/Storage.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
useCapabilitiesLoaded,
1111
useStorageGroupsHandlerAvailable,
1212
} from '../../store/reducers/capabilities/hooks';
13+
import {useClusterBaseInfo} from '../../store/reducers/cluster/cluster';
1314
import type {NodesSortParams} from '../../store/reducers/nodes/types';
1415
import {VISIBLE_ENTITIES} from '../../store/reducers/storage/constants';
1516
import {
@@ -24,10 +25,10 @@ import type {
2425
StorageType,
2526
VisibleEntities,
2627
} from '../../store/reducers/storage/types';
27-
import type {AdditionalNodesProps} from '../../types/additionalProps';
2828
import {DEFAULT_TABLE_SETTINGS} from '../../utils/constants';
2929
import {useAutoRefreshInterval, useTableSort} from '../../utils/hooks';
3030
import {NodesUptimeFilterValues, nodesUptimeFilterValuesSchema} from '../../utils/nodes';
31+
import {useAdditionalNodeProps} from '../AppWithClusters/useClusterData';
3132

3233
import {StorageControls} from './StorageControls/StorageControls';
3334
import {StorageGroups} from './StorageGroups/StorageGroups';
@@ -57,12 +58,14 @@ const UsageFilterParam = withDefault(
5758
);
5859

5960
interface StorageProps {
60-
additionalNodesProps?: AdditionalNodesProps;
6161
database?: string;
62-
nodeId?: string;
62+
nodeId?: string | number;
6363
}
6464

65-
export const Storage = ({additionalNodesProps, database, nodeId}: StorageProps) => {
65+
export const Storage = ({database, nodeId}: StorageProps) => {
66+
const {balancer} = useClusterBaseInfo();
67+
const additionalNodesProps = useAdditionalNodeProps({balancer});
68+
6669
const capabilitiesLoaded = useCapabilitiesLoaded();
6770
const groupsHandlerAvailable = useStorageGroupsHandlerAvailable();
6871
const [autoRefreshInterval] = useAutoRefreshInterval();

src/containers/Storage/StorageWrapper.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type {AdditionalNodesProps} from '../../types/additionalProps';
21
import {USE_PAGINATED_TABLES_KEY} from '../../utils/constants';
32
import {useSetting} from '../../utils/hooks';
43

@@ -9,7 +8,6 @@ interface StorageWrapperProps {
98
database?: string;
109
nodeId?: string;
1110
parentContainer?: Element | null;
12-
additionalNodesProps?: AdditionalNodesProps;
1311
}
1412

1513
export const StorageWrapper = ({parentContainer, ...props}: StorageWrapperProps) => {

0 commit comments

Comments
 (0)