-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4948 from epixa/4862-scripted-field-range-filters
Support infinite ranges on filters
- Loading branch information
Showing
26 changed files
with
138 additions
and
8 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
describe('ui/filter_bar/lib', function () { | ||
describe('mapMatchAll()', function () { | ||
const expect = require('expect.js'); | ||
const ngMock = require('ngMock'); | ||
let $rootScope; | ||
let mapMatchAll; | ||
let filter; | ||
|
||
|
||
beforeEach(ngMock.module('kibana')); | ||
beforeEach(ngMock.inject(function (Private, _$rootScope_) { | ||
$rootScope = _$rootScope_; | ||
mapMatchAll = Private(require('ui/filter_bar/lib/mapMatchAll')); | ||
filter = { | ||
match_all: {}, | ||
meta: { | ||
field: 'foo', | ||
formattedValue: 'bar' | ||
} | ||
}; | ||
})); | ||
|
||
describe('when given a filter that is not match_all', function () { | ||
it('filter is rejected', function (done) { | ||
delete filter.match_all; | ||
mapMatchAll(filter).catch(result => { | ||
expect(result).to.be(filter); | ||
done(); | ||
}); | ||
$rootScope.$apply(); | ||
}); | ||
}); | ||
|
||
describe('when given a match_all filter', function () { | ||
let result; | ||
beforeEach(function () { | ||
mapMatchAll(filter).then(r => result = r); | ||
$rootScope.$apply(); | ||
}); | ||
|
||
it('key is set to meta field', function () { | ||
expect(result).to.have.property('key', filter.meta.field); | ||
}); | ||
|
||
it('value is set to meta formattedValue', function () { | ||
expect(result).to.have.property('value', filter.meta.formattedValue); | ||
}); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
define(function (require) { | ||
return function mapMatchAllProvider(Promise) { | ||
return function (filter) { | ||
if (filter.match_all) { | ||
const key = filter.meta.field; | ||
const value = filter.meta.formattedValue || 'all'; | ||
return Promise.resolve({ key, value }); | ||
} | ||
return Promise.reject(filter); | ||
}; | ||
}; | ||
}); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters