Skip to content

fix: remove empty selectedConsumer from url #1644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/containers/Tenant/Diagnostics/Partitions/Partitions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const Partitions = ({path, database}: PartitionsProps) => {
selectedConsumer && consumers && !consumers.includes(selectedConsumer);

if (isTopicWithoutConsumers || wrongSelectedConsumer) {
dispatch(setSelectedConsumer(''));
dispatch(setSelectedConsumer(undefined));
}
}, [dispatch, topicLoading, selectedConsumer, consumers]);

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

const handleSelectedConsumerChange = (value: string) => {
const handleSelectedConsumerChange = (value?: string) => {
dispatch(setSelectedConsumer(value));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import type {PreparedPartitionDataWithHosts} from '../utils/types';

interface PartitionsControlsProps {
consumers: string[] | undefined;
selectedConsumer: string;
onSelectedConsumerChange: (consumer: string) => void;
selectedConsumer?: string;
onSelectedConsumerChange: (consumer?: string) => void;
selectDisabled: boolean;
partitions: PreparedPartitionDataWithHosts[] | undefined;
onSearchChange: (filteredPartitions: PreparedPartitionDataWithHosts[]) => void;
Expand Down Expand Up @@ -111,7 +111,8 @@ export const PartitionsControls = ({
}, [initialColumnsIds, hiddenColumns]);

const handleConsumerSelectChange = (value: string[]) => {
onSelectedConsumerChange(value[0]);
// Do not set empty string to state
onSelectedConsumerChange(value[0] || undefined);
};

const handlePartitionIdSearchChange = (value: string) => {
Expand Down Expand Up @@ -151,7 +152,7 @@ export const PartitionsControls = ({
className={b('consumer-select')}
label={i18n('controls.consumerSelector')}
options={consumersToSelect}
value={[selectedConsumer]}
value={[selectedConsumer || '']}
onUpdate={handleConsumerSelectChange}
filterable={consumers && consumers.length > 5}
disabled={selectDisabled || !consumers || !consumers.length}
Expand Down
9 changes: 4 additions & 5 deletions src/store/reducers/partitions/partitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import type {PayloadAction} from '@reduxjs/toolkit';

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

import type {PartitionsState} from './types';
import {prepareConsumerPartitions, prepareTopicPartitions} from './utils';

const initialState: PartitionsState = {
selectedConsumer: '',
};
const initialState: {
selectedConsumer?: string;
} = {};

const slice = createSlice({
name: 'partitions',
initialState,
reducers: {
setSelectedConsumer: (state, action: PayloadAction<string>) => {
setSelectedConsumer: (state, action: PayloadAction<string | undefined>) => {
state.selectedConsumer = action.payload;
},
},
Expand Down
4 changes: 0 additions & 4 deletions src/store/reducers/partitions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,3 @@ export interface PreparedPartitionData {
partitionNodeId: number;
connectionNodeId?: number;
}

export interface PartitionsState {
selectedConsumer: string;
}
Loading