diff --git a/src/core_plugins/kbn_doc_views/public/views/table.html b/src/core_plugins/kbn_doc_views/public/views/table.html index d98f5be7512a5..7de7695318d35 100644 --- a/src/core_plugins/kbn_doc_views/public/views/table.html +++ b/src/core_plugins/kbn_doc_views/public/views/table.html @@ -1,6 +1,6 @@
{
expect(searchSourceStub.fetch.calledOnce).to.be(true);
});
});
it('should configure the SearchSource to not inherit from the implicit root', function () {
- const indexPatternStub = createIndexPatternStub('index1');
const searchSourceStub = new SearchSourceStub();
- return fetchAnchor(indexPatternStub, 'UID', { '@timestamp': 'desc' })
+ return fetchAnchor('INDEX_PATTERN_ID', 'UID', { '@timestamp': 'desc' })
.then(() => {
const inheritsSpy = searchSourceStub.inherits;
expect(inheritsSpy.calledOnce).to.be(true);
@@ -46,22 +48,20 @@ describe('context app', function () {
});
it('should set the SearchSource index pattern', function () {
- const indexPatternStub = createIndexPatternStub('index1');
const searchSourceStub = new SearchSourceStub();
- return fetchAnchor(indexPatternStub, 'UID', { '@timestamp': 'desc' })
+ return fetchAnchor('INDEX_PATTERN_ID', 'UID', { '@timestamp': 'desc' })
.then(() => {
const setIndexSpy = searchSourceStub.set.withArgs('index');
expect(setIndexSpy.calledOnce).to.be(true);
- expect(setIndexSpy.firstCall.args[1]).to.eql(indexPatternStub);
+ expect(setIndexSpy.firstCall.args[1]).to.eql({ id: 'INDEX_PATTERN_ID' });
});
});
it('should set the SearchSource version flag to true', function () {
- const indexPatternStub = createIndexPatternStub('index1');
const searchSourceStub = new SearchSourceStub();
- return fetchAnchor(indexPatternStub, 'UID', { '@timestamp': 'desc' })
+ return fetchAnchor('INDEX_PATTERN_ID', 'UID', { '@timestamp': 'desc' })
.then(() => {
const setVersionSpy = searchSourceStub.set.withArgs('version');
expect(setVersionSpy.calledOnce).to.be(true);
@@ -70,10 +70,9 @@ describe('context app', function () {
});
it('should set the SearchSource size to 1', function () {
- const indexPatternStub = createIndexPatternStub('index1');
const searchSourceStub = new SearchSourceStub();
- return fetchAnchor(indexPatternStub, 'UID', { '@timestamp': 'desc' })
+ return fetchAnchor('INDEX_PATTERN_ID', 'UID', { '@timestamp': 'desc' })
.then(() => {
const setSizeSpy = searchSourceStub.set.withArgs('size');
expect(setSizeSpy.calledOnce).to.be(true);
@@ -82,10 +81,9 @@ describe('context app', function () {
});
it('should set the SearchSource query to a _uid terms query', function () {
- const indexPatternStub = createIndexPatternStub('index1');
const searchSourceStub = new SearchSourceStub();
- return fetchAnchor(indexPatternStub, 'UID', { '@timestamp': 'desc' })
+ return fetchAnchor('INDEX_PATTERN_ID', 'UID', { '@timestamp': 'desc' })
.then(() => {
const setQuerySpy = searchSourceStub.set.withArgs('query');
expect(setQuerySpy.calledOnce).to.be(true);
@@ -98,10 +96,9 @@ describe('context app', function () {
});
it('should set the SearchSource sort order', function () {
- const indexPatternStub = createIndexPatternStub('index1');
const searchSourceStub = new SearchSourceStub();
- return fetchAnchor(indexPatternStub, 'UID', { '@timestamp': 'desc' })
+ return fetchAnchor('INDEX_PATTERN_ID', 'UID', { '@timestamp': 'desc' })
.then(() => {
const setSortSpy = searchSourceStub.set.withArgs('sort');
expect(setSortSpy.calledOnce).to.be(true);
@@ -113,11 +110,10 @@ describe('context app', function () {
});
it('should reject with an error when no hits were found', function () {
- const indexPatternStub = createIndexPatternStub('index1');
const searchSourceStub = new SearchSourceStub();
searchSourceStub._stubHits = [];
- return fetchAnchor(indexPatternStub, 'UID', { '@timestamp': 'desc' })
+ return fetchAnchor('INDEX_PATTERN_ID', 'UID', { '@timestamp': 'desc' })
.then(
() => {
expect().fail('expected the promise to be rejected');
@@ -129,14 +125,13 @@ describe('context app', function () {
});
it('should return the first hit after adding an anchor marker', function () {
- const indexPatternStub = createIndexPatternStub('index1');
const searchSourceStub = new SearchSourceStub();
searchSourceStub._stubHits = [
{ property1: 'value1' },
{ property2: 'value2' },
];
- return fetchAnchor(indexPatternStub, 'UID', { '@timestamp': 'desc' })
+ return fetchAnchor('INDEX_PATTERN_ID', 'UID', { '@timestamp': 'desc' })
.then((anchorDocument) => {
expect(anchorDocument).to.have.property('property1', 'value1');
expect(anchorDocument).to.have.property('$$_isAnchor', true);
@@ -146,12 +141,13 @@ describe('context app', function () {
});
-function createIndexPatternStub(indices) {
+function createCourierStub() {
return {
- getComputedFields: sinon.stub()
- .returns({}),
- toIndexList: sinon.stub()
- .returns(indices),
+ indexPatterns: {
+ get: sinon.spy((indexPatternId) => Promise.resolve({
+ id: indexPatternId,
+ })),
+ },
};
}
@@ -160,6 +156,7 @@ function createSearchSourceStubProvider(hits) {
_stubHits: hits,
};
+ searchSourceStub.filter = sinon.stub().returns(searchSourceStub);
searchSourceStub.inherits = sinon.stub().returns(searchSourceStub);
searchSourceStub.set = sinon.stub().returns(searchSourceStub);
searchSourceStub.fetch = sinon.spy(() => Promise.resolve({
diff --git a/src/core_plugins/kibana/public/context/api/anchor.js b/src/core_plugins/kibana/public/context/api/anchor.js
index 4c395473cba4b..66c6784674753 100644
--- a/src/core_plugins/kibana/public/context/api/anchor.js
+++ b/src/core_plugins/kibana/public/context/api/anchor.js
@@ -3,10 +3,12 @@ import _ from 'lodash';
import { SearchSourceProvider } from 'ui/courier/data_source/search_source';
-function fetchAnchorProvider(Private) {
+function fetchAnchorProvider(courier, Private) {
const SearchSource = Private(SearchSourceProvider);
- return async function fetchAnchor(indexPattern, uid, sort) {
+ return async function fetchAnchor(indexPatternId, uid, sort) {
+ const indexPattern = await courier.indexPatterns.get(indexPatternId);
+
const searchSource = new SearchSource()
.inherits(false)
.set('index', indexPattern)
diff --git a/src/core_plugins/kibana/public/context/api/context.js b/src/core_plugins/kibana/public/context/api/context.js
index 808457566291b..bd5d678d768dd 100644
--- a/src/core_plugins/kibana/public/context/api/context.js
+++ b/src/core_plugins/kibana/public/context/api/context.js
@@ -5,7 +5,7 @@ import { SearchSourceProvider } from 'ui/courier/data_source/search_source';
import { reverseSortDirective } from './utils/sorting';
-function fetchContextProvider(Private) {
+function fetchContextProvider(courier, Private) {
const SearchSource = Private(SearchSourceProvider);
return {
@@ -13,37 +13,43 @@ function fetchContextProvider(Private) {
fetchSuccessors,
};
- async function fetchSuccessors(indexPattern, anchorDocument, contextSort, size) {
+ async function fetchSuccessors(indexPatternId, anchorDocument, contextSort, size, filters) {
const successorsSort = [contextSort, { _uid: 'asc' }];
- const successorsSearchSource = createSearchSource(
- indexPattern,
+ const successorsSearchSource = await createSearchSource(
+ indexPatternId,
anchorDocument,
successorsSort,
size,
+ filters,
);
const results = await performQuery(successorsSearchSource);
return results;
}
- async function fetchPredecessors(indexPattern, anchorDocument, contextSort, size) {
+ async function fetchPredecessors(indexPatternId, anchorDocument, contextSort, size, filters) {
const predecessorsSort = [reverseSortDirective(contextSort), { _uid: 'desc' }];
- const predecessorsSearchSource = createSearchSource(
- indexPattern,
+ const predecessorsSearchSource = await createSearchSource(
+ indexPatternId,
anchorDocument,
predecessorsSort,
size,
+ filters,
);
const reversedResults = await performQuery(predecessorsSearchSource);
const results = reversedResults.slice().reverse();
return results;
}
- function createSearchSource(indexPattern, anchorDocument, sort, size) {
+ async function createSearchSource(indexPatternId, anchorDocument, sort, size, filters) {
+
+ const indexPattern = await courier.indexPatterns.get(indexPatternId);
+
return new SearchSource()
.inherits(false)
.set('index', indexPattern)
.set('version', true)
.set('size', size)
+ .set('filter', filters)
.set('query', {
match_all: {},
})
diff --git a/src/core_plugins/kibana/public/context/app.html b/src/core_plugins/kibana/public/context/app.html
index 5a0b193ebc972..fef98142f1ce2 100644
--- a/src/core_plugins/kibana/public/context/app.html
+++ b/src/core_plugins/kibana/public/context/app.html
@@ -2,7 +2,7 @@
- Surrounding Documents in {{ contextApp.state.queryParameters.indexPattern.id }}
+ Surrounding Documents in {{ contextApp.state.queryParameters.indexPatternId }}
Searchingcolumns="state.columns" infinite-scroll="true" filter="filterQuery" + filters="state.filters" data-shared-item data-title="{{opts.savedSearch.lastSavedTitle}}" data-description="{{opts.savedSearch.description}}" diff --git a/src/ui/public/doc_table/components/table_row.js b/src/ui/public/doc_table/components/table_row.js index f474e35011ada..6ba4827162311 100644 --- a/src/ui/public/doc_table/components/table_row.js +++ b/src/ui/public/doc_table/components/table_row.js @@ -11,6 +11,8 @@ import { noWhiteSpace } from 'ui/utils/no_white_space'; import openRowHtml from 'ui/doc_table/components/table_row/open.html'; import detailsHtml from 'ui/doc_table/components/table_row/details.html'; import { uiModules } from 'ui/modules'; +import { disableFilter } from 'ui/filter_bar'; + const module = uiModules.get('app/discover'); @@ -35,6 +37,7 @@ module.directive('kbnTableRow', function ($compile, $httpParamSerializer, kbnUrl scope: { columns: '=', filter: '=', + filters: '=?', indexPattern: '=', row: '=kbnTableRow', onAddColumn: '=?', @@ -102,6 +105,7 @@ module.directive('kbnTableRow', function ($compile, $httpParamSerializer, kbnUrl const hash = $httpParamSerializer({ _a: rison.encode({ columns: $scope.columns, + filters: ($scope.filters || []).map(disableFilter), }), }); return `${path}?${hash}`; diff --git a/src/ui/public/doc_table/doc_table.html b/src/ui/public/doc_table/doc_table.html index 96b9ab144768a..bab9514e1d2ac 100644 --- a/src/ui/public/doc_table/doc_table.html +++ b/src/ui/public/doc_table/doc_table.html @@ -43,6 +43,7 @@ sorting="sorting" index-pattern="indexPattern" filter="filter" + filters="filters" class="discover-table-row" on-add-column="onAddColumn" on-change-sort-order="onChangeSortOrder" @@ -92,6 +93,7 @@ sorting="sorting" index-pattern="indexPattern" filter="filter" + filters="filters" class="discover-table-row" ng-class="{'discover-table-row--highlight': row['$$_isAnchor']}" data-test-subj="docTableRow{{ row['$$_isAnchor'] ? ' docTableAnchorRow' : ''}}" diff --git a/src/ui/public/doc_table/doc_table.js b/src/ui/public/doc_table/doc_table.js index 98589f5aa9069..be11e2a729b06 100644 --- a/src/ui/public/doc_table/doc_table.js +++ b/src/ui/public/doc_table/doc_table.js @@ -23,6 +23,7 @@ uiModules.get('kibana') searchSource: '=?', infiniteScroll: '=?', filter: '=?', + filters: '=?', onAddColumn: '=?', onChangeSortOrder: '=?', onMoveColumn: '=?', diff --git a/src/ui/public/filter_bar/filter_bar.html b/src/ui/public/filter_bar/filter_bar.html index ca5ba6fa4bf1d..4598d28cddba4 100644 --- a/src/ui/public/filter_bar/filter_bar.html +++ b/src/ui/public/filter_bar/filter_bar.html @@ -23,7 +23,12 @@ |