From 98c6fb739f17bea0469ac6d37c7abb2b05b279ca Mon Sep 17 00:00:00 2001 From: vikrantgupta25 Date: Wed, 11 Sep 2024 13:53:48 +0530 Subject: [PATCH 1/2] chore: update the filter in / filter out operators --- frontend/src/components/Logs/AddToQueryHOC.tsx | 2 +- frontend/src/container/LogDetailedView/TableView.tsx | 4 ++-- .../LogDetailedView/TableView/TableViewActions.tsx | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Logs/AddToQueryHOC.tsx b/frontend/src/components/Logs/AddToQueryHOC.tsx index df222b7552..d7e2c7156e 100644 --- a/frontend/src/components/Logs/AddToQueryHOC.tsx +++ b/frontend/src/components/Logs/AddToQueryHOC.tsx @@ -15,7 +15,7 @@ function AddToQueryHOC({ }: AddToQueryHOCProps): JSX.Element { const handleQueryAdd = (event: MouseEvent): void => { event.stopPropagation(); - onAddToQuery(fieldKey, fieldValue, OPERATORS.IN); + onAddToQuery(fieldKey, fieldValue, OPERATORS['=']); }; const popOverContent = useMemo(() => Add to query: {fieldKey}, [ diff --git a/frontend/src/container/LogDetailedView/TableView.tsx b/frontend/src/container/LogDetailedView/TableView.tsx index 591109ac3c..45e8417659 100644 --- a/frontend/src/container/LogDetailedView/TableView.tsx +++ b/frontend/src/container/LogDetailedView/TableView.tsx @@ -122,10 +122,10 @@ function TableView({ fieldValue: string, ) => (): void => { handleClick(operator, fieldKey, fieldValue); - if (operator === OPERATORS.IN) { + if (operator === OPERATORS['=']) { setIsFilterInLoading(true); } - if (operator === OPERATORS.NIN) { + if (operator === OPERATORS['!=']) { setIsFilterOutLoading(true); } }; diff --git a/frontend/src/container/LogDetailedView/TableView/TableViewActions.tsx b/frontend/src/container/LogDetailedView/TableView/TableViewActions.tsx index 74b30bf6de..57ceea5072 100644 --- a/frontend/src/container/LogDetailedView/TableView/TableViewActions.tsx +++ b/frontend/src/container/LogDetailedView/TableView/TableViewActions.tsx @@ -139,7 +139,7 @@ export function TableViewActions( ) } - onClick={onClickHandler(OPERATORS.IN, fieldFilterKey, fieldData.value)} + onClick={onClickHandler(OPERATORS['='], fieldFilterKey, fieldData.value)} /> @@ -152,7 +152,11 @@ export function TableViewActions( ) } - onClick={onClickHandler(OPERATORS.NIN, fieldFilterKey, fieldData.value)} + onClick={onClickHandler( + OPERATORS['!='], + fieldFilterKey, + fieldData.value, + )} /> {!isOldLogsExplorerOrLiveLogsPage && ( From 9939371c9d9d3d0fe6090354d91ecb4b482d61e2 Mon Sep 17 00:00:00 2001 From: vikrantgupta25 Date: Wed, 11 Sep 2024 16:28:22 +0530 Subject: [PATCH 2/2] fix: handle cases for old logs explorer --- frontend/src/container/LogDetailedView/index.tsx | 7 +++++-- frontend/src/hooks/logs/useActiveLog.ts | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/src/container/LogDetailedView/index.tsx b/frontend/src/container/LogDetailedView/index.tsx index 4ff7ab6a99..1b2ecddc08 100644 --- a/frontend/src/container/LogDetailedView/index.tsx +++ b/frontend/src/container/LogDetailedView/index.tsx @@ -1,6 +1,7 @@ import LogDetail from 'components/LogDetail'; import { VIEW_TYPES } from 'components/LogDetail/constants'; import ROUTES from 'constants/routes'; +import { getOldLogsOperatorFromNew } from 'hooks/logs/useActiveLog'; import { getGeneratedFilterQueryString } from 'lib/getGeneratedFilterQueryString'; import getStep from 'lib/getStep'; import { getIdConditions } from 'pages/Logs/utils'; @@ -57,10 +58,11 @@ function LogDetailedView({ const handleAddToQuery = useCallback( (fieldKey: string, fieldValue: string, operator: string) => { + const newOperator = getOldLogsOperatorFromNew(operator); const updatedQueryString = getGeneratedFilterQueryString( fieldKey, fieldValue, - operator, + newOperator, queryString, ); @@ -71,10 +73,11 @@ function LogDetailedView({ const handleClickActionItem = useCallback( (fieldKey: string, fieldValue: string, operator: string): void => { + const newOperator = getOldLogsOperatorFromNew(operator); const updatedQueryString = getGeneratedFilterQueryString( fieldKey, fieldValue, - operator, + newOperator, queryString, ); diff --git a/frontend/src/hooks/logs/useActiveLog.ts b/frontend/src/hooks/logs/useActiveLog.ts index 0a968c4650..d7cc498f9f 100644 --- a/frontend/src/hooks/logs/useActiveLog.ts +++ b/frontend/src/hooks/logs/useActiveLog.ts @@ -1,6 +1,6 @@ import { getAggregateKeys } from 'api/queryBuilder/getAttributeKeys'; import { SOMETHING_WENT_WRONG } from 'constants/api'; -import { QueryBuilderKeys } from 'constants/queryBuilder'; +import { OPERATORS, QueryBuilderKeys } from 'constants/queryBuilder'; import ROUTES from 'constants/routes'; import { getOperatorValue } from 'container/QueryBuilder/filters/QueryBuilderSearch/utils'; import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder'; @@ -24,6 +24,16 @@ import { v4 as uuid } from 'uuid'; import { UseActiveLog } from './types'; +export function getOldLogsOperatorFromNew(operator: string): string { + switch (operator) { + case OPERATORS['=']: + return OPERATORS.IN; + case OPERATORS['!=']: + return OPERATORS.NIN; + default: + return operator; + } +} export const useActiveLog = (): UseActiveLog => { const dispatch = useDispatch(); @@ -178,10 +188,11 @@ export const useActiveLog = (): UseActiveLog => { ); const onAddToQueryLogs = useCallback( (fieldKey: string, fieldValue: string, operator: string) => { + const newOperator = getOldLogsOperatorFromNew(operator); const updatedQueryString = getGeneratedFilterQueryString( fieldKey, fieldValue, - operator, + newOperator, queryString, );