Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Allow filters without index #68225

Merged
merged 3 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 normally', async function () {
const noIndexPatternFilter = await filterBar.hasFilter('banana', 'yellow', true);
expect(noIndexPatternFilter).to.be(true);
});
});
});
}
Binary file not shown.