[FIX] Allow filters without index (#68225)

* Allow filters without index

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

* Adjust test result
This commit is contained in:
Liza Katz 2020-06-04 20:42:52 +03:00 committed by GitHub
parent edc4d58e12
commit 537d2f2de1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View file

@ -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]);
@ -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;

View file

@ -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);
});
});
});
}