Added functionality to ClearAll button (#1813)

* Added functionality to ClearAll button

* Added updating count of partitions in URL

* Comments removed

* Added SeekDirection reset

* White spaces removed

Co-authored-by: k.morozov <k.morozov@ffin.ru>
This commit is contained in:
Kirill Morozov 2022-04-12 20:09:46 +03:00 committed by GitHub
parent 30e0238bd1
commit a38077d9d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,6 +51,7 @@ export interface FiltersProps {
updateMeta(meta: TopicMessageConsuming): void;
setIsFetching(status: boolean): void;
}
export interface MessageFilters {
name: string;
code: string;
@ -165,6 +166,21 @@ const Filters: React.FC<FiltersProps> = ({
};
}, [attempt, query, queryType, seekDirection, activeFilter]);
const handleClearAllFilters = () => {
setCurrentSeekType(SeekType.OFFSET);
setQuery('');
changeSeekDirection(SeekDirection.FORWARD);
getSelectedPartitionsFromSeekToParam(searchParams, partitions);
setSelectedPartitions(
partitions.map((partition: Partition) => {
return {
value: partition.partition,
label: String(partition.partition),
};
})
);
};
const handleFiltersSubmit = React.useCallback(() => {
setAttempt(attempt + 1);
@ -389,7 +405,7 @@ const Filters: React.FC<FiltersProps> = ({
onChange={setSelectedPartitions}
labelledBy="Select partitions"
/>
<S.ClearAll>Clear all</S.ClearAll>
<S.ClearAll onClick={handleClearAllFilters}>Clear all</S.ClearAll>
{isFetching ? (
<Button
type="button"