Skip to content

Commit

Permalink
Fix for index pattern update
Browse files Browse the repository at this point in the history
  • Loading branch information
jkelas committed Dec 5, 2024
1 parent bb2f34e commit e6017fd
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/

import React from 'react';
import React, { useMemo } from 'react';
import { cloneDeep } from 'lodash';
import { isEmpty } from 'lodash/fp';
import {
EuiDescriptionList,
Expand All @@ -24,6 +25,7 @@ import type { Filter } from '@kbn/es-query';
import type { SavedQuery } from '@kbn/data-plugin/public';
import { mapAndFlattenFilters } from '@kbn/data-plugin/public';
import { FilterItems } from '@kbn/unified-search-plugin/public';
import { isDataView } from '../../../../common/components/query_bar';
import type {
AlertSuppressionMissingFieldsStrategy,
EqlOptionalFields,
Expand Down Expand Up @@ -92,8 +94,16 @@ export const Filters = ({
? { dataViewId }
: { indexPatterns: index ?? defaultIndexPattern };
const { dataView } = useDataView(useDataViewParams);

const flattenedFilters = mapAndFlattenFilters(filters);
const isEsql = filters.some((filter) => filter?.query?.language === 'esql');
const searchBarFilters = useMemo(() => {
if (!index || isDataView(index) || isEsql) {
return filters;
}
const updatedFilters = cloneDeep(filters);
updatedFilters.forEach((filter) => (filter.meta.index = index.join(',')));
return updatedFilters;
}, [filters, index, isEsql]);
const flattenedFilters = mapAndFlattenFilters(searchBarFilters);
const styles = filtersStyles;

return (
Expand Down

0 comments on commit e6017fd

Please sign in to comment.