Browse Source

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>
Kirill Morozov 3 years ago
parent
commit
a38077d9d7

+ 17 - 1
kafka-ui-react-app/src/components/Topics/Topic/Details/Messages/Filters/Filters.tsx

@@ -51,6 +51,7 @@ export interface FiltersProps {
   updateMeta(meta: TopicMessageConsuming): void;
   updateMeta(meta: TopicMessageConsuming): void;
   setIsFetching(status: boolean): void;
   setIsFetching(status: boolean): void;
 }
 }
+
 export interface MessageFilters {
 export interface MessageFilters {
   name: string;
   name: string;
   code: string;
   code: string;
@@ -165,6 +166,21 @@ const Filters: React.FC<FiltersProps> = ({
     };
     };
   }, [attempt, query, queryType, seekDirection, activeFilter]);
   }, [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(() => {
   const handleFiltersSubmit = React.useCallback(() => {
     setAttempt(attempt + 1);
     setAttempt(attempt + 1);
 
 
@@ -389,7 +405,7 @@ const Filters: React.FC<FiltersProps> = ({
             onChange={setSelectedPartitions}
             onChange={setSelectedPartitions}
             labelledBy="Select partitions"
             labelledBy="Select partitions"
           />
           />
-          <S.ClearAll>Clear all</S.ClearAll>
+          <S.ClearAll onClick={handleClearAllFilters}>Clear all</S.ClearAll>
           {isFetching ? (
           {isFetching ? (
             <Button
             <Button
               type="button"
               type="button"