Merge pull request #1304 from SigNoz/417-search-filter

feat: search filter is added in the trace filter
This commit is contained in:
Palash 2022-06-24 00:23:22 +05:30 committed by GitHub
commit 5a34ce2221
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 12 deletions

View File

@ -39,16 +39,22 @@ function CommonCheckBox(props: CommonCheckBoxProps): JSX.Element {
}); });
}; };
const isMoreButtonAvilable = Boolean(
numberOfFilters && statusObj.length > numberOfFilters,
);
return ( return (
<> <>
<Search {statusObj.length > 0 && (
value={searchFilter} <Search
onChange={(e): void => setSearchFilter(e.target.value)} value={searchFilter}
style={{ onChange={(e): void => setSearchFilter(e.target.value)}
padding: '0 3%', style={{
}} padding: '0 3%',
placeholder="Filter Values" }}
/> placeholder="Filter Values"
/>
)}
{statusObj {statusObj
.sort((a, b) => { .sort((a, b) => {
@ -60,13 +66,15 @@ function CommonCheckBox(props: CommonCheckBoxProps): JSX.Element {
} }
return countA - countB; return countA - countB;
}) })
.filter((_, index) => index < numberOfFilters)
.filter((filter) => { .filter((filter) => {
if (searchFilter.length === 0) { if (searchFilter.length === 0) {
return true; return true;
} }
return filter.includes(searchFilter); return filter
.toLocaleLowerCase()
.includes(searchFilter.toLocaleLowerCase());
}) })
.filter((_, index) => index < numberOfFilters)
.map((e) => ( .map((e) => (
<CheckBoxComponent <CheckBoxComponent
key={e} key={e}
@ -78,7 +86,7 @@ function CommonCheckBox(props: CommonCheckBoxProps): JSX.Element {
/> />
))} ))}
{numberOfFilters && statusObj.length > numberOfFilters && ( {isMoreButtonAvilable && (
<Button onClick={onClickMoreHandler} type="link"> <Button onClick={onClickMoreHandler} type="link">
More More
</Button> </Button>

View File

@ -24,7 +24,7 @@ import {
} from 'types/actions/trace'; } from 'types/actions/trace';
import { TraceFilterEnum, TraceReducer } from 'types/reducer/trace'; import { TraceFilterEnum, TraceReducer } from 'types/reducer/trace';
export const INITIAL_FILTER_VALUE = 4; export const INITIAL_FILTER_VALUE = 8;
const initialValue: TraceReducer = { const initialValue: TraceReducer = {
filter: new Map(), filter: new Map(),