-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Don't prevent filterable rows from being filterable #11628
Conversation
b7472f7
to
2cfd7af
Compare
yo jenkins, i'd really appreciate it if you'd test this |
src/ui/public/directives/rows.js
Outdated
&& contents.aggConfig.getField().filterable; | ||
|
||
if (isCellContentFilterable) { | ||
if (contents.type === 'bucket') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran into a couple issues but I think they have an easy fix.
- This adds filter icons to agg buckets that don't support filtering, like geohash_grid:
We can check whether an agg type supports filtering with the following condition:
_.get(contents, 'aggConfig.type.createFilter')
- This also adds filter icons to fields that are aggregatable, but not filterable, which will thrown an error if you try to filter on them. It's probably not common, but it's possible if you had a mapping like this:
PUT aggnofilter
{
"mappings": {
"aggnofilter": {
"properties": {
"notindexed": {
"type": "integer",
"index": false
}
}
}
}
}
We can also check for this with the following condition:
(contents.aggConfig.getField() ? contents.aggConfig.getField().filterable : true);
Putting it altogether, we can write this condition as follows:
const isCellContentFilterable =
contents.type === 'bucket'
&& _.get(contents, 'aggConfig.type.createFilter')
&& (contents.aggConfig.getField() ? contents.aggConfig.getField().filterable : true);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @Bargs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I really need to check if contents.type === 'bucket'
if I'm checking _.get(contents, 'aggConfig.type.createFilter')
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure, but that sounds right.
Oh, one other thing, it would be really cool if the agg's filter labels became filter aliases. But that's just a nice to have, we could add it some time in a separate PR. |
@Bargs Ready for another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a neat addition!
minor comment, for your consideration
src/ui/public/directives/rows.js
Outdated
&& contents.aggConfig.getField() | ||
&& contents.aggConfig.getField().filterable; | ||
_.get(contents, 'aggConfig.type.createFilter') | ||
&& (!field || field.filterable); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider moving this check to the AggConfig
type instead. Then you could do something like if (aggConfig.isFilterable())
, and we don't need to ducktype this here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasolson lemme know if you wanna take a crack at this, if so I'll hold off on giving it another look. Otherwise I'll do another review first thing tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bargs Just fixed this. Feel free to take a look now. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked to me like the previous test run passed but s3 upload failed.
LGTM! Great stuff
* Don't prevent filterable rows just because they don't have a field * Don't allow filtering on unfilterable fields * Move isFilterable to aggConfig
Backported to 5.x (5.5.0) in f25f118. |
* Don't prevent filterable rows just because they don't have a field * Don't allow filtering on unfilterable fields * Move isFilterable to aggConfig
Fixes #8678.
For some reason, the data table has only ever allowed filtering on rows that have some sort of field associated, which meant that when you aggregate using the "filters" bucket agg, you were not able to filter on the associated row. This was strange because if you had created the same visualization as a vertical bar chart, you could click on the bar to filter.
This PR simply removes the check that the row has a field associated with it, which means you can now create filters from the "filters" bucket aggregation!
Summary: Data tables using the "Filters" aggregation now allow you to click on a row to create a filter.
Before:
After: