Commit 46540f31 by Ivana Huckova Committed by GitHub

Fix strict null errors that resulted from search (#25950)

parent 4bb3f665
...@@ -346,7 +346,7 @@ export function filterQueriesBySearchFilter(queries: RichHistoryQuery[], searchF ...@@ -346,7 +346,7 @@ export function filterQueriesBySearchFilter(queries: RichHistoryQuery[], searchF
const listOfMatchingQueries = query.queries.filter(query => const listOfMatchingQueries = query.queries.filter(query =>
// Remove fields in which we don't want to be searching // Remove fields in which we don't want to be searching
Object.values(_.omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some(value => Object.values(_.omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some((value: any) =>
value.toString().includes(searchFilter) value.toString().includes(searchFilter)
) )
); );
...@@ -356,7 +356,7 @@ export function filterQueriesBySearchFilter(queries: RichHistoryQuery[], searchF ...@@ -356,7 +356,7 @@ export function filterQueriesBySearchFilter(queries: RichHistoryQuery[], searchF
} }
export function filterQueriesByDataSource(queries: RichHistoryQuery[], listOfDatasourceFilters: string[] | null) { export function filterQueriesByDataSource(queries: RichHistoryQuery[], listOfDatasourceFilters: string[] | null) {
return listOfDatasourceFilters?.length > 0 return listOfDatasourceFilters && listOfDatasourceFilters.length > 0
? queries.filter(q => listOfDatasourceFilters.includes(q.datasourceName)) ? queries.filter(q => listOfDatasourceFilters.includes(q.datasourceName))
: queries; : queries;
} }
......
...@@ -138,7 +138,7 @@ export function RichHistoryQueriesTab(props: Props) { ...@@ -138,7 +138,7 @@ export function RichHistoryQueriesTab(props: Props) {
} = props; } = props;
const [timeFilter, setTimeFilter] = useState<[number, number]>([0, retentionPeriod]); const [timeFilter, setTimeFilter] = useState<[number, number]>([0, retentionPeriod]);
const [filteredQueries, setFilteredQueries] = useState([]); const [filteredQueries, setFilteredQueries] = useState<RichHistoryQuery[]>([]);
const [searchInput, setSearchInput] = useState(''); const [searchInput, setSearchInput] = useState('');
const theme = useTheme(); const theme = useTheme();
...@@ -153,7 +153,7 @@ export function RichHistoryQueriesTab(props: Props) { ...@@ -153,7 +153,7 @@ export function RichHistoryQueriesTab(props: Props) {
filterAndSortQueries( filterAndSortQueries(
queries, queries,
sortOrder, sortOrder,
datasourceFilters?.map(d => d.value), datasourceFilters?.map(d => d.value) as string[] | null,
searchValue, searchValue,
timeFilter timeFilter
) )
...@@ -167,7 +167,7 @@ export function RichHistoryQueriesTab(props: Props) { ...@@ -167,7 +167,7 @@ export function RichHistoryQueriesTab(props: Props) {
filterAndSortQueries( filterAndSortQueries(
queries, queries,
sortOrder, sortOrder,
datasourceFilters?.map(d => d.value), datasourceFilters?.map(d => d.value) as string[] | null,
searchInput, searchInput,
timeFilter timeFilter
) )
......
...@@ -83,7 +83,7 @@ export function RichHistoryStarredTab(props: Props) { ...@@ -83,7 +83,7 @@ export function RichHistoryStarredTab(props: Props) {
exploreId, exploreId,
} = props; } = props;
const [filteredQueries, setFilteredQueries] = useState([]); const [filteredQueries, setFilteredQueries] = useState<RichHistoryQuery[]>([]);
const [searchInput, setSearchInput] = useState(''); const [searchInput, setSearchInput] = useState('');
const theme = useTheme(); const theme = useTheme();
...@@ -99,7 +99,7 @@ export function RichHistoryStarredTab(props: Props) { ...@@ -99,7 +99,7 @@ export function RichHistoryStarredTab(props: Props) {
filterAndSortQueries( filterAndSortQueries(
starredQueries, starredQueries,
sortOrder, sortOrder,
datasourceFilters?.map(d => d.value), datasourceFilters?.map(d => d.value) as string[] | null,
searchValue searchValue
) )
); );
...@@ -112,7 +112,7 @@ export function RichHistoryStarredTab(props: Props) { ...@@ -112,7 +112,7 @@ export function RichHistoryStarredTab(props: Props) {
filterAndSortQueries( filterAndSortQueries(
starredQueries, starredQueries,
sortOrder, sortOrder,
datasourceFilters?.map(d => d.value), datasourceFilters?.map(d => d.value) as string[] | null,
searchInput searchInput
) )
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment