Skip to content

Commit 3af0c68

Browse files
refactor: move selectedConsumer to partitions
1 parent 0843a49 commit 3af0c68

File tree

7 files changed

+22
-130
lines changed

7 files changed

+22
-130
lines changed

src/containers/Tenant/Diagnostics/Partitions/Partitions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {useAutofetcher, useTypedSelector, useSetting} from '../../../../utils/ho
88
import {DEFAULT_TABLE_SETTINGS, PARTITIONS_HIDDEN_COLUMNS_KEY} from '../../../../utils/constants';
99

1010
import {getNodesList, selectNodesMap} from '../../../../store/reducers/nodesList';
11-
import {setSelectedConsumer} from '../../../../store/reducers/consumer';
1211
import {
1312
cleanTopicData,
1413
getTopic,
@@ -18,6 +17,7 @@ import {
1817
import {
1918
getPartitions,
2019
setDataWasNotLoaded as setPartitionsDataWasNotLoaded,
20+
setSelectedConsumer,
2121
} from '../../../../store/reducers/partitions/partitions';
2222

2323
import {TableSkeleton} from '../../../../components/TableSkeleton/TableSkeleton';
@@ -52,12 +52,12 @@ export const Partitions = ({path}: PartitionsProps) => {
5252
const consumers = useTypedSelector(selectConsumersNames);
5353
const nodesMap = useTypedSelector(selectNodesMap);
5454
const {autorefresh} = useTypedSelector((state) => state.schema);
55-
const {selectedConsumer} = useTypedSelector((state) => state.consumer);
5655
const {
5756
loading: partitionsLoading,
5857
wasLoaded: partitionsWasLoaded,
5958
error: partitionsError,
6059
partitions: rawPartitions,
60+
selectedConsumer,
6161
} = useTypedSelector((state) => state.partitions);
6262
const {
6363
loading: topicLoading,

src/store/reducers/consumer.ts

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/store/reducers/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import pool from './pool';
1818
import tenants from './tenants/tenants';
1919
import tablet from './tablet';
2020
import topic from './topic';
21-
import consumer from './consumer';
2221
import partitions from './partitions/partitions';
2322
import executeQuery from './executeQuery';
2423
import explainQuery from './explainQuery';
@@ -59,7 +58,6 @@ export const rootReducer = {
5958
tenants,
6059
tablet,
6160
topic,
62-
consumer,
6361
partitions,
6462
executeQuery,
6563
explainQuery,

src/store/reducers/partitions/partitions.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import {prepareConsumerPartitions, prepareTopicPartitions} from './utils';
99

1010
export const FETCH_PARTITIONS = createRequestActionTypes('partitions', 'FETCH_PARTITIONS');
1111

12+
const SET_SELECTED_CONSUMER = 'partitions/SET_SELECTED_CONSUMER';
1213
const SET_DATA_WAS_NOT_LOADED = 'partitions/SET_DATA_WAS_NOT_LOADED';
1314

1415
const initialState = {
1516
loading: false,
1617
wasLoaded: false,
18+
selectedConsumer: undefined,
1719
};
1820

1921
const partitions: Reducer<PartitionsState, PartitionsAction> = (state = initialState, action) => {
@@ -44,6 +46,12 @@ const partitions: Reducer<PartitionsState, PartitionsAction> = (state = initialS
4446
loading: false,
4547
};
4648
}
49+
case SET_SELECTED_CONSUMER: {
50+
return {
51+
...state,
52+
selectedConsumer: action.data,
53+
};
54+
}
4755
case SET_DATA_WAS_NOT_LOADED: {
4856
return {
4957
...state,
@@ -55,6 +63,13 @@ const partitions: Reducer<PartitionsState, PartitionsAction> = (state = initialS
5563
}
5664
};
5765

66+
export const setSelectedConsumer = (value?: string) => {
67+
return {
68+
type: SET_SELECTED_CONSUMER,
69+
data: value,
70+
} as const;
71+
};
72+
5873
export const setDataWasNotLoaded = () => {
5974
return {
6075
type: SET_DATA_WAS_NOT_LOADED,

src/store/reducers/partitions/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {IResponseError} from '../../../types/api/error';
22
import type {IProcessSpeedStats} from '../../../utils/bytesParsers';
33
import type {ApiRequestAction} from '../../utils';
44

5-
import {FETCH_PARTITIONS, setDataWasNotLoaded} from './partitions';
5+
import {FETCH_PARTITIONS, setDataWasNotLoaded, setSelectedConsumer} from './partitions';
66

77
// Fields that could be undefined corresponds to partitions without consumers
88
export interface PreparedPartitionData {
@@ -36,10 +36,12 @@ export interface PreparedPartitionData {
3636
export interface PartitionsState {
3737
loading: boolean;
3838
wasLoaded: boolean;
39+
selectedConsumer: string | undefined;
3940
partitions?: PreparedPartitionData[];
4041
error?: IResponseError;
4142
}
4243

4344
export type PartitionsAction =
4445
| ApiRequestAction<typeof FETCH_PARTITIONS, PreparedPartitionData[], IResponseError>
45-
| ReturnType<typeof setDataWasNotLoaded>;
46+
| ReturnType<typeof setDataWasNotLoaded>
47+
| ReturnType<typeof setSelectedConsumer>;

src/store/state-url-mapping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const paramSetup = {
6868
type: 'number',
6969
},
7070
selectedConsumer: {
71-
stateKey: 'consumer.selectedConsumer',
71+
stateKey: 'partitions.selectedConsumer',
7272
},
7373
},
7474
};

src/types/store/consumer.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)