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

Don't prevent filterable rows from being filterable #11628

Merged
merged 5 commits into from
May 9, 2017
Merged
Changes from 1 commit
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
7 changes: 1 addition & 6 deletions src/ui/public/directives/rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ module.directive('kbnRows', function ($compile, $rootScope, getAppState, Private
let $cellContent;

if (contents instanceof AggConfigResult) {
const isCellContentFilterable =
contents.type === 'bucket'
&& contents.aggConfig.getField()
&& contents.aggConfig.getField().filterable;

if (isCellContentFilterable) {
if (contents.type === 'bucket') {
Copy link
Contributor

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:

screen shot 2017-05-05 at 4 07 26 pm

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks @Bargs

Copy link
Member Author

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')?

Copy link
Contributor

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.

$cell = createFilterableCell(contents);
$cellContent = $cell.find('[data-cell-content]');
} else {
Expand Down