mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Merge pull request #6582 from spalger/fix/6573
[filterbar] Only warn about non-filterable field when it's actually being filtered by
This commit is contained in:
commit
1ab4aeb0e8
3 changed files with 65 additions and 2 deletions
|
@ -16,7 +16,7 @@ function stubbedLogstashFields() {
|
|||
{ name: 'extension', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: 'machine.os', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: 'geo.src', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: '_type', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: '_type', type: 'string', indexed: false, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: '_id', type: 'string', indexed: false, analyzed: false, sortable: false, filterable: true},
|
||||
{ name: '_source', type: 'string', indexed: false, analyzed: false, sortable: false, filterable: false},
|
||||
{ name: 'custom_user_field', type: 'conflict', indexed: false, analyzed: false, sortable: false, filterable: true },
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
|
||||
import MockState from 'fixtures/mock_state';
|
||||
import notify from 'ui/notify';
|
||||
import AggConfigResult from 'ui/vis/agg_config_result';
|
||||
|
||||
import VisProvider from 'ui/vis';
|
||||
import StubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import FilterBarClickHandlerProvider from 'ui/filter_bar/filter_bar_click_handler';
|
||||
|
||||
describe('filterBarClickHandler', function () {
|
||||
let setup = null;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
setup = function () {
|
||||
const Vis = Private(VisProvider);
|
||||
const createClickHandler = Private(FilterBarClickHandlerProvider);
|
||||
const indexPattern = Private(StubbedLogstashIndexPatternProvider);
|
||||
|
||||
const vis = new Vis(indexPattern, {
|
||||
type: 'histogram',
|
||||
aggs: [
|
||||
{ type: 'count', schema: 'metric' },
|
||||
{
|
||||
type: 'terms',
|
||||
schema: 'segment',
|
||||
params: { field: '_type' }
|
||||
}
|
||||
]
|
||||
});
|
||||
const aggConfigResult = new AggConfigResult(vis.aggs[1], void 0, 'apache', 'apache');
|
||||
|
||||
const $state = new MockState({ filters: [] });
|
||||
const clickHandler = createClickHandler($state);
|
||||
|
||||
return { clickHandler, $state, aggConfigResult };
|
||||
};
|
||||
}));
|
||||
|
||||
afterEach(function () {
|
||||
notify._notifs.splice(0);
|
||||
});
|
||||
|
||||
context('on non-filterable fields', function () {
|
||||
it('warns about trying to filter on a non-filterable field', function () {
|
||||
const { clickHandler, aggConfigResult } = setup();
|
||||
expect(notify._notifs).to.have.length(0);
|
||||
clickHandler({ point: { aggConfigResult }});
|
||||
expect(notify._notifs).to.have.length(1);
|
||||
});
|
||||
|
||||
it('does not warn if the event is click is being simulated', function () {
|
||||
const { clickHandler, aggConfigResult } = setup();
|
||||
expect(notify._notifs).to.have.length(0);
|
||||
clickHandler({ point: { aggConfigResult }}, true);
|
||||
expect(notify._notifs).to.have.length(0);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -39,7 +39,9 @@ export default function (Notifier) {
|
|||
try {
|
||||
return result.createFilter();
|
||||
} catch (e) {
|
||||
notify.warning(e.message);
|
||||
if (!simulate) {
|
||||
notify.warning(e.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue