Skip to content

Commit 51f1375

Browse files
author
Liza K
committed
Merge remote-tracking branch 'upstream/master' into move-index-patterns-to-new-plugins-2
2 parents a3df345 + ce127d2 commit 51f1375

File tree

134 files changed

+2865
-1919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+2865
-1919
lines changed

packages/eslint-config-kibana/typescript.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ module.exports = {
116116
}],
117117
'@typescript-eslint/consistent-type-assertions': 'error',
118118
'@typescript-eslint/no-empty-interface': 'error',
119+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
119120
'@typescript-eslint/no-misused-new': 'error',
120121
'@typescript-eslint/no-namespace': 'error',
121122
'@typescript-eslint/triple-slash-reference': ['error', {
@@ -167,6 +168,7 @@ module.exports = {
167168
'object-shorthand': 'error',
168169
'one-var': [ 'error', 'never' ],
169170
'prefer-const': 'error',
171+
'prefer-rest-params': 'error',
170172
'quotes': ['error', 'double', { 'avoidEscape': true }],
171173
'quote-props': ['error', 'consistent-as-needed'],
172174
'radix': 'error',

src/legacy/core_plugins/kibana/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ export default function (kibana) {
6262

6363
uiExports: {
6464
hacks: [
65+
'plugins/kibana/discover',
6566
'plugins/kibana/dev_tools',
6667
],
6768
savedObjectTypes: [
6869
'plugins/kibana/visualize/saved_visualizations/saved_visualization_register',
69-
'plugins/kibana/discover/saved_searches/saved_search_register',
7070
'plugins/kibana/dashboard/saved_dashboard/saved_dashboard_register',
7171
],
7272
app: {

src/legacy/core_plugins/kibana/public/dashboard/dashboard_config.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,26 @@
2020
import { uiModules } from 'ui/modules';
2121
import { capabilities } from 'ui/capabilities';
2222

23-
uiModules.get('kibana')
24-
.provider('dashboardConfig', () => {
25-
let hideWriteControls = !capabilities.get().dashboard.showWriteControls;
23+
export function dashboardConfigProvider() {
24+
let hideWriteControls = !capabilities.get().dashboard.showWriteControls;
25+
26+
return {
27+
/**
28+
* Part of the exposed plugin API - do not remove without careful consideration.
29+
* @type {boolean}
30+
*/
31+
turnHideWriteControlsOn() {
32+
hideWriteControls = true;
33+
},
34+
$get() {
35+
return {
36+
getHideWriteControls() {
37+
return hideWriteControls;
38+
}
39+
};
40+
}
41+
};
42+
}
2643

27-
return {
28-
/**
29-
* Part of the exposed plugin API - do not remove without careful consideration.
30-
* @type {boolean}
31-
*/
32-
turnHideWriteControlsOn() {
33-
hideWriteControls = true;
34-
},
35-
$get() {
36-
return {
37-
getHideWriteControls() {
38-
return hideWriteControls;
39-
}
40-
};
41-
}
42-
};
43-
});
44+
uiModules.get('kibana')
45+
.provider('dashboardConfig', dashboardConfigProvider);

src/legacy/core_plugins/kibana/public/discover/__tests__/directives/discover_field.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import _ from 'lodash';
2323
import sinon from 'sinon';
2424
import ngMock from 'ng_mock';
2525
import expect from '@kbn/expect';
26-
import '../../components/field_chooser/discover_field';
26+
import { pluginInstance } from 'plugins/kibana/discover/index';
2727
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
2828

2929
// Load the kibana app dependencies.
@@ -32,8 +32,9 @@ describe('discoverField', function () {
3232
let $scope;
3333
let indexPattern;
3434
let $elem;
35-
36-
beforeEach(ngMock.module('kibana'));
35+
beforeEach(() => pluginInstance.initializeServices(true));
36+
beforeEach(() => pluginInstance.initializeInnerAngular());
37+
beforeEach(ngMock.module('app/discover'));
3738
beforeEach(ngMock.inject(function (Private, $rootScope, $compile) {
3839
$elem = angular.element(`
3940
<discover-field

src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_calculator.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020

2121
import _ from 'lodash';
22+
import { pluginInstance } from 'plugins/kibana/discover/index';
2223
import ngMock from 'ng_mock';
2324
import { fieldCalculator } from '../../components/field_chooser/lib/field_calculator';
2425
import expect from '@kbn/expect';
@@ -29,7 +30,8 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta
2930
let indexPattern;
3031

3132
describe('fieldCalculator', function () {
32-
beforeEach(ngMock.module('kibana'));
33+
beforeEach(() => pluginInstance.initializeInnerAngular());
34+
beforeEach(ngMock.module('app/discover'));
3335
beforeEach(ngMock.inject(function (Private) {
3436
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
3537
}));

src/legacy/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import _ from 'lodash';
2323
import sinon from 'sinon';
2424
import expect from '@kbn/expect';
2525
import $ from 'jquery';
26-
import '../../components/field_chooser/field_chooser';
26+
import { pluginInstance } from 'plugins/kibana/discover/index';
2727
import FixturesHitsProvider from 'fixtures/hits';
2828
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
2929
import { SimpleSavedObject } from '../../../../../../../core/public';
@@ -70,8 +70,10 @@ describe('discover field chooser directives', function () {
7070
on-remove-field="removeField"
7171
></disc-field-chooser>
7272
`);
73+
beforeEach(() => pluginInstance.initializeServices(true));
74+
beforeEach(() => pluginInstance.initializeInnerAngular());
7375

74-
beforeEach(ngMock.module('kibana', ($provide) => {
76+
beforeEach(ngMock.module('app/discover', ($provide) => {
7577
$provide.decorator('config', ($delegate) => {
7678
// disable shortDots for these tests
7779
$delegate.get = _.wrap($delegate.get, function (origGet, name) {

src/legacy/core_plugins/kibana/public/discover/_index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@import 'embeddable/index';
2121

2222
// Doc Viewer
23-
@import 'doc_viewer/index';
23+
@import 'components/doc_viewer/index';
2424

2525
// Context styles
2626
@import 'angular/context/index';

src/legacy/core_plugins/kibana/public/discover/angular/context.js

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919

2020
import _ from 'lodash';
2121
import { i18n } from '@kbn/i18n';
22-
import { getServices, subscribeWithScope } from './../kibana_services';
22+
import { getAngularModule, getServices, subscribeWithScope } from './../kibana_services';
2323

2424
import './context_app';
2525
import contextAppRouteTemplate from './context.html';
26-
import { getRootBreadcrumbs } from '../breadcrumbs';
27-
const { FilterBarQueryFilterProvider, uiRoutes, chrome } = getServices();
26+
import { getRootBreadcrumbs } from '../helpers/breadcrumbs';
27+
import { FilterStateManager } from '../../../../data/public/filter/filter_manager';
28+
const { chrome } = getServices();
2829

2930
const k7Breadcrumbs = $route => {
3031
const { indexPattern } = $route.current.locals;
@@ -44,26 +45,33 @@ const k7Breadcrumbs = $route => {
4445
];
4546
};
4647

47-
uiRoutes
48-
// deprecated route, kept for compatibility
49-
// should be removed in the future
50-
.when('/context/:indexPatternId/:type/:id*', {
51-
redirectTo: '/context/:indexPatternId/:id',
52-
})
53-
.when('/context/:indexPatternId/:id*', {
54-
controller: ContextAppRouteController,
55-
k7Breadcrumbs,
56-
controllerAs: 'contextAppRoute',
57-
resolve: {
58-
indexPattern: function ($route, indexPatterns) {
59-
return indexPatterns.get($route.current.params.indexPatternId);
48+
getAngularModule().config($routeProvider => {
49+
$routeProvider
50+
// deprecated route, kept for compatibility
51+
// should be removed in the future
52+
.when('/discover/context/:indexPatternId/:type/:id*', {
53+
redirectTo: '/discover/context/:indexPatternId/:id',
54+
})
55+
.when('/discover/context/:indexPatternId/:id*', {
56+
controller: ContextAppRouteController,
57+
k7Breadcrumbs,
58+
controllerAs: 'contextAppRoute',
59+
resolve: {
60+
indexPattern: ($route, Promise) => {
61+
const indexPattern = getServices().indexPatterns.get(
62+
$route.current.params.indexPatternId
63+
);
64+
return Promise.props({ ip: indexPattern });
65+
},
6066
},
61-
},
62-
template: contextAppRouteTemplate,
63-
});
67+
template: contextAppRouteTemplate,
68+
});
69+
});
6470

65-
function ContextAppRouteController($routeParams, $scope, AppState, config, indexPattern, Private) {
66-
const queryFilter = Private(FilterBarQueryFilterProvider);
71+
function ContextAppRouteController($routeParams, $scope, AppState, config, $route, getAppState, globalState) {
72+
const filterManager = getServices().filterManager;
73+
const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager);
74+
const indexPattern = $route.current.locals.indexPattern.ip;
6775

6876
this.state = new AppState(createDefaultAppState(config, indexPattern));
6977
this.state.save(true);
@@ -77,19 +85,20 @@ function ContextAppRouteController($routeParams, $scope, AppState, config, index
7785
() => this.state.save(true)
7886
);
7987

80-
const updateSubsciption = subscribeWithScope($scope, queryFilter.getUpdates$(), {
88+
const updateSubsciption = subscribeWithScope($scope, filterManager.getUpdates$(), {
8189
next: () => {
82-
this.filters = _.cloneDeep(queryFilter.getFilters());
90+
this.filters = _.cloneDeep(filterManager.getFilters());
8391
},
8492
});
8593

86-
$scope.$on('$destroy', function () {
94+
$scope.$on('$destroy', () => {
95+
filterStateManager.destroy();
8796
updateSubsciption.unsubscribe();
8897
});
8998
this.anchorId = $routeParams.id;
9099
this.indexPattern = indexPattern;
91100
this.discoverUrl = chrome.navLinks.get('kibana:discover').url;
92-
this.filters = _.cloneDeep(queryFilter.getFilters());
101+
this.filters = _.cloneDeep(filterManager.getFilters());
93102
}
94103

95104
function createDefaultAppState(config, indexPattern) {

src/legacy/core_plugins/kibana/public/discover/angular/context/api/__tests__/anchor.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919

2020
import expect from '@kbn/expect';
2121
import ngMock from 'ng_mock';
22+
import { pluginInstance } from 'plugins/kibana/discover/index';
2223

2324
import { createIndexPatternsStub, createSearchSourceStub } from './_stubs';
2425

2526
import { fetchAnchorProvider } from '../anchor';
2627

2728
describe('context app', function () {
28-
beforeEach(ngMock.module('kibana'));
29+
beforeEach(() => pluginInstance.initializeInnerAngular());
30+
beforeEach(ngMock.module('app/discover'));
2931

3032
describe('function fetchAnchor', function () {
3133
let fetchAnchor;
@@ -35,11 +37,11 @@ describe('context app', function () {
3537
$provide.value('indexPatterns', createIndexPatternsStub());
3638
}));
3739

38-
beforeEach(ngMock.inject(function createPrivateStubs(Private) {
40+
beforeEach(ngMock.inject(function createPrivateStubs() {
3941
searchSourceStub = createSearchSourceStub([
4042
{ _id: 'hit1' },
4143
]);
42-
fetchAnchor = Private(fetchAnchorProvider);
44+
fetchAnchor = fetchAnchorProvider(createIndexPatternsStub(), searchSourceStub);
4345
}));
4446

4547
afterEach(() => {

src/legacy/core_plugins/kibana/public/discover/angular/context/api/__tests__/predecessors.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import expect from '@kbn/expect';
2121
import ngMock from 'ng_mock';
2222
import moment from 'moment';
2323
import * as _ from 'lodash';
24+
import { pluginInstance } from 'plugins/kibana/discover/index';
2425

2526
import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs';
2627

@@ -33,7 +34,8 @@ const ANCHOR_TIMESTAMP_1000 = (new Date(MS_PER_DAY * 1000)).toJSON();
3334
const ANCHOR_TIMESTAMP_3000 = (new Date(MS_PER_DAY * 3000)).toJSON();
3435

3536
describe('context app', function () {
36-
beforeEach(ngMock.module('kibana'));
37+
beforeEach(() => pluginInstance.initializeInnerAngular());
38+
beforeEach(ngMock.module('app/discover'));
3739

3840
describe('function fetchPredecessors', function () {
3941
let fetchPredecessors;
@@ -43,7 +45,7 @@ describe('context app', function () {
4345
$provide.value('indexPatterns', createIndexPatternsStub());
4446
}));
4547

46-
beforeEach(ngMock.inject(function createPrivateStubs(Private) {
48+
beforeEach(ngMock.inject(function createPrivateStubs() {
4749
searchSourceStub = createContextSearchSourceStub([], '@timestamp', MS_PER_DAY * 8);
4850
fetchPredecessors = (indexPatternId, timeField, sortDir, timeValIso, timeValNr, tieBreakerField, tieBreakerValue, size) => {
4951
const anchor = {
@@ -53,7 +55,7 @@ describe('context app', function () {
5355
sort: [timeValNr, tieBreakerValue]
5456
};
5557

56-
return Private(fetchContextProvider).fetchSurroundingDocs(
58+
return fetchContextProvider(createIndexPatternsStub()).fetchSurroundingDocs(
5759
'predecessors',
5860
indexPatternId,
5961
anchor,

0 commit comments

Comments
 (0)