Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: clear filter is fixed (#2544)

Palash Gupta6c11c6d4da08
diff --git a/frontend/src/container/LogsSearchFilter/SearchFields/ActionBar.tsx b/frontend/src/container/LogsSearchFilter/SearchFields/ActionBar.tsx
index a8d5c777c9..05ba17b8f6 100644
--- a/frontend/src/container/LogsSearchFilter/SearchFields/ActionBar.tsx
+++ b/frontend/src/container/LogsSearchFilter/SearchFields/ActionBar.tsx
@@ -1,23 +1,15 @@
import { Button, Row } from 'antd';
import React from 'react';
-import { QueryFields } from './utils';
-
interface SearchFieldsActionBarProps {
- fieldsQuery: QueryFields[][];
- applyUpdate: () => void;
- clearFilters: () => void;
+ applyUpdate: VoidFunction;
+ clearFilters: VoidFunction;
}
export function SearchFieldsActionBar({
- fieldsQuery,
applyUpdate,
clearFilters,
}: SearchFieldsActionBarProps): JSX.Element | null {
- if (fieldsQuery.length === 0) {
- return null;
- }
-
return (
<Row style={{ justifyContent: 'flex-end', paddingRight: '2.4rem' }}>
<Button
diff --git a/frontend/src/container/LogsSearchFilter/SearchFields/index.tsx b/frontend/src/container/LogsSearchFilter/SearchFields/index.tsx
index 3fd74e9190..07662da8e2 100644
--- a/frontend/src/container/LogsSearchFilter/SearchFields/index.tsx
+++ b/frontend/src/container/LogsSearchFilter/SearchFields/index.tsx
@@ -1,4 +1,5 @@
import { useNotifications } from 'hooks/useNotifications';
+import { reverseParser } from 'lib/logql';
import { flatten } from 'lodash-es';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useSelector } from 'react-redux';
@@ -18,13 +19,13 @@ import {
} from './utils';
export interface SearchFieldsProps {
- updateParsedQuery: (query: QueryFields[]) => void;
onDropDownToggleHandler: (value: boolean) => VoidFunction;
+ updateQueryString: (value: string) => void;
}
function SearchFields({
- updateParsedQuery,
onDropDownToggleHandler,
+ updateQueryString,
}: SearchFieldsProps): JSX.Element {
const {
searchFilter: { parsedQuery },
@@ -90,15 +91,15 @@ function SearchFields({
}
keyPrefixRef.current = hashCode(JSON.stringify(flatParsedQuery));
- updateParsedQuery(flatParsedQuery);
+ updateQueryString(reverseParser(flatParsedQuery));
onDropDownToggleHandler(false)();
- }, [onDropDownToggleHandler, fieldsQuery, updateParsedQuery, notifications]);
+ }, [fieldsQuery, notifications, onDropDownToggleHandler, updateQueryString]);
const clearFilters = useCallback((): void => {
keyPrefixRef.current = hashCode(JSON.stringify([]));
- updateParsedQuery([]);
- onDropDownToggleHandler(false)();
- }, [onDropDownToggleHandler, updateParsedQuery]);
+ setFieldsQuery([]);
+ updateQueryString('');
+ }, [updateQueryString]);
return (
<>
@@ -113,7 +114,6 @@ function SearchFields({
<SearchFieldsActionBar
applyUpdate={applyUpdate}
clearFilters={clearFilters}
- fieldsQuery={fieldsQuery}
/>
<Suggestions applySuggestion={addSuggestedField} />
</>
diff --git a/frontend/src/container/LogsSearchFilter/index.tsx b/frontend/src/container/LogsSearchFilter/index.tsx
index 75f95769f1..efe7a39534 100644
--- a/frontend/src/container/LogsSearchFilter/index.tsx
+++ b/frontend/src/container/LogsSearchFilter/index.tsx
@@ -36,11 +36,7 @@ function SearchFilter({
getLogsAggregate,
getLogsFields,
}: SearchFilterProps): JSX.Element {
- const {
- updateParsedQuery,
- updateQueryString,
- queryString,
- } = useSearchParser();
+ const { updateQueryString, queryString } = useSearchParser();
const [searchText, setSearchText] = useState(queryString);
const [showDropDown, setShowDropDown] = useState(false);
const searchRef = useRef<InputRef>(null);
@@ -187,8 +183,8 @@ function SearchFilter({
content={
<DropDownContainer>
<SearchFields
+ updateQueryString={updateQueryString}
onDropDownToggleHandler={onDropDownToggleHandler}
- updateParsedQuery={updateParsedQuery as never}
/>
</DropDownContainer>
}
diff --git a/frontend/src/container/LogsSearchFilter/useSearchParser.ts b/frontend/src/container/LogsSearchFilter/useSearchParser.ts
index 20ecf39fb9..a3dab8a75c 100644
--- a/frontend/src/container/LogsSearchFilter/useSearchParser.ts
+++ b/frontend/src/container/LogsSearchFilter/useSearchParser.ts
@@ -1,8 +1,7 @@
import { getMinMax } from 'container/TopNav/AutoRefresh/config';
import useUrlQuery from 'hooks/useUrlQuery';
import history from 'lib/history';
-import { parseQuery, reverseParser } from 'lib/logql';
-import { ILogQLParsedQueryItem } from 'lib/logql/types';
+import { parseQuery } from 'lib/logql';
import isEqual from 'lodash-es/isEqual';
import { useCallback, useEffect, useMemo } from 'react';
import { useDispatch, useSelector } from 'react-redux';
@@ -21,7 +20,6 @@ import { getGlobalTime } from './utils';
export function useSearchParser(): {
queryString: string;
parsedQuery: unknown;
- updateParsedQuery: (arg0: ILogQLParsedQueryItem[]) => void;
updateQueryString: (arg0: string) => void;
} {
const dispatch = useDispatch<Dispatch<AppActions>>();
@@ -75,32 +73,9 @@ export function useSearchParser(): {
}
}, [queryString, updateQueryString, parsedFilters]);
- const updateParsedQuery = useCallback(
- (updatedParsedPayload: ILogQLParsedQueryItem[]) => {
- dispatch({
- type: SET_SEARCH_QUERY_PARSED_PAYLOAD,
- payload: updatedParsedPayload,
- });
- const reversedParsedQuery = reverseParser(updatedParsedPayload);
- if (
- !isEqual(queryString, reversedParsedQuery) ||
- (queryString === '' && reversedParsedQuery === '')
- ) {
- dispatch({
- type: SET_SEARCH_QUERY_STRING,
- payload: {
- searchQueryString: reversedParsedQuery,
- },
- });
- }
- },
- [dispatch, queryString],
- );
-
return {
queryString,
parsedQuery,
- updateParsedQuery,
updateQueryString,
};
}