Skip to content

Commit

Permalink
[FIX] Allow filters without index (#68225) (#68349)
Browse files Browse the repository at this point in the history
* Allow filters without index

* Explicitly return true from isFilterApplicable id no index patterns were provided

* Adjust test result
  • Loading branch information
lizozom authored Jun 5, 2020
1 parent 1714128 commit df3821c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/plugins/data/public/ui/filter_bar/filter_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export function FilterItem(props: Props) {
setIndexPatternExists(false);
});
} else {
setIndexPatternExists(false);
// Allow filters without an index pattern and don't validate them.
setIndexPatternExists(true);
}
}, [props.filter.meta.index]);

Expand Down Expand Up @@ -244,6 +245,9 @@ export function FilterItem(props: Props) {
* This function makes this behavior explicit, but it needs to be revised.
*/
function isFilterApplicable() {
// Any filter is applicable if no index patterns were provided to FilterBar.
if (!props.indexPatterns.length) return true;

const ip = getIndexPatternFromFilter(filter, indexPatterns);
if (ip) return true;

Expand Down
5 changes: 5 additions & 0 deletions test/functional/apps/dashboard/dashboard_filter_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ export default function ({ getService, getPageObjects }) {
const hasWarningFieldFilter = await filterBar.hasFilter('extension', 'warn', true);
expect(hasWarningFieldFilter).to.be(true);
});

it('filter without an index pattern is rendred as a warning, if the dashboard has an index pattern', async function () {
const noIndexPatternFilter = await filterBar.hasFilter('banana', 'warn', true);
expect(noIndexPatternFilter).to.be(true);
});
});
});
}
Binary file not shown.

0 comments on commit df3821c

Please sign in to comment.