Skip to content

Commit 14f3fa4

Browse files
fix: remove empty selectedConsumer from url (#1644)
1 parent 3b37565 commit 14f3fa4

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const Partitions = ({path, database}: PartitionsProps) => {
8282
selectedConsumer && consumers && !consumers.includes(selectedConsumer);
8383

8484
if (isTopicWithoutConsumers || wrongSelectedConsumer) {
85-
dispatch(setSelectedConsumer(''));
85+
dispatch(setSelectedConsumer(undefined));
8686
}
8787
}, [dispatch, topicLoading, selectedConsumer, consumers]);
8888

@@ -94,7 +94,7 @@ export const Partitions = ({path, database}: PartitionsProps) => {
9494
setHiddenColumns(newHiddenColumns);
9595
};
9696

97-
const handleSelectedConsumerChange = (value: string) => {
97+
const handleSelectedConsumerChange = (value?: string) => {
9898
dispatch(setSelectedConsumer(value));
9999
};
100100

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import type {PreparedPartitionDataWithHosts} from '../utils/types';
1313

1414
interface PartitionsControlsProps {
1515
consumers: string[] | undefined;
16-
selectedConsumer: string;
17-
onSelectedConsumerChange: (consumer: string) => void;
16+
selectedConsumer?: string;
17+
onSelectedConsumerChange: (consumer?: string) => void;
1818
selectDisabled: boolean;
1919
partitions: PreparedPartitionDataWithHosts[] | undefined;
2020
onSearchChange: (filteredPartitions: PreparedPartitionDataWithHosts[]) => void;
@@ -111,7 +111,8 @@ export const PartitionsControls = ({
111111
}, [initialColumnsIds, hiddenColumns]);
112112

113113
const handleConsumerSelectChange = (value: string[]) => {
114-
onSelectedConsumerChange(value[0]);
114+
// Do not set empty string to state
115+
onSelectedConsumerChange(value[0] || undefined);
115116
};
116117

117118
const handlePartitionIdSearchChange = (value: string) => {
@@ -151,7 +152,7 @@ export const PartitionsControls = ({
151152
className={b('consumer-select')}
152153
label={i18n('controls.consumerSelector')}
153154
options={consumersToSelect}
154-
value={[selectedConsumer]}
155+
value={[selectedConsumer || '']}
155156
onUpdate={handleConsumerSelectChange}
156157
filterable={consumers && consumers.length > 5}
157158
disabled={selectDisabled || !consumers || !consumers.length}

src/store/reducers/partitions/partitions.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ import type {PayloadAction} from '@reduxjs/toolkit';
33

44
import {api} from '../api';
55

6-
import type {PartitionsState} from './types';
76
import {prepareConsumerPartitions, prepareTopicPartitions} from './utils';
87

9-
const initialState: PartitionsState = {
10-
selectedConsumer: '',
11-
};
8+
const initialState: {
9+
selectedConsumer?: string;
10+
} = {};
1211

1312
const slice = createSlice({
1413
name: 'partitions',
1514
initialState,
1615
reducers: {
17-
setSelectedConsumer: (state, action: PayloadAction<string>) => {
16+
setSelectedConsumer: (state, action: PayloadAction<string | undefined>) => {
1817
state.selectedConsumer = action.payload;
1918
},
2019
},

src/store/reducers/partitions/types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,3 @@ export interface PreparedPartitionData {
2828
partitionNodeId: number;
2929
connectionNodeId?: number;
3030
}
31-
32-
export interface PartitionsState {
33-
selectedConsumer: string;
34-
}

0 commit comments

Comments
 (0)