From 1e679a0d64bc679fba367661feeda1e68080dfa6 Mon Sep 17 00:00:00 2001 From: Yunus M Date: Wed, 10 Jan 2024 14:07:23 +0530 Subject: [PATCH] fix: empty string search doesn't return all exceptions (#4346) * fix: empty string search doesn't return all exceptions * fix: add type --- frontend/src/container/AllError/index.tsx | 42 ++++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/frontend/src/container/AllError/index.tsx b/frontend/src/container/AllError/index.tsx index 4bc7d199e1..e8c13d88cd 100644 --- a/frontend/src/container/AllError/index.tsx +++ b/frontend/src/container/AllError/index.tsx @@ -48,6 +48,15 @@ import { urlKey, } from './utils'; +type QueryParams = { + order: string; + offset: number; + orderParam: string; + pageSize: number; + exceptionType?: string; + serviceName?: string; +}; + function AllErrors(): JSX.Element { const { maxTime, minTime, loading } = useSelector( (state) => state.globalTime, @@ -162,16 +171,23 @@ function AllErrors(): JSX.Element { filterKey, filterValue || '', ); - history.replace( - `${pathname}?${createQueryParams({ - order: updatedOrder, - offset: getUpdatedOffset, - orderParam: getUpdatedParams, - pageSize: getUpdatedPageSize, - exceptionType: exceptionFilterValue, - serviceName: serviceFilterValue, - })}`, - ); + + const queryParams: QueryParams = { + order: updatedOrder, + offset: getUpdatedOffset, + orderParam: getUpdatedParams, + pageSize: getUpdatedPageSize, + }; + + if (exceptionFilterValue && exceptionFilterValue !== 'undefined') { + queryParams.exceptionType = exceptionFilterValue; + } + + if (serviceFilterValue && serviceFilterValue !== 'undefined') { + queryParams.serviceName = serviceFilterValue; + } + + history.replace(`${pathname}?${createQueryParams(queryParams)}`); confirm(); }, [ @@ -198,8 +214,10 @@ function AllErrors(): JSX.Element { - setSelectedKeys(e.target.value ? [e.target.value] : []) + onChange={ + (e): void => setSelectedKeys(e.target.value ? [e.target.value] : []) + + // Need to fix this logic, when the value in empty, it's setting undefined string as value } allowClear defaultValue={getDefaultFilterValue(