Skip to content

Commit

Permalink
Merge branch 'master' into apm
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Dec 2, 2019
2 parents e64c525 + 45e7a11 commit 4f34863
Show file tree
Hide file tree
Showing 190 changed files with 3,366 additions and 2,202 deletions.
2 changes: 2 additions & 0 deletions packages/eslint-config-kibana/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ module.exports = {
}],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/triple-slash-reference': ['error', {
Expand Down Expand Up @@ -167,6 +168,7 @@ module.exports = {
'object-shorthand': 'error',
'one-var': [ 'error', 'never' ],
'prefer-const': 'error',
'prefer-rest-params': 'error',
'quotes': ['error', 'double', { 'avoidEscape': true }],
'quote-props': ['error', 'consistent-as-needed'],
'radix': 'error',
Expand Down
1 change: 1 addition & 0 deletions src/cli/cluster/cluster_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export default class ClusterManager {
fromRoot('x-pack/legacy/plugins/reporting/.chromium'),
fromRoot('x-pack/legacy/plugins/siem/cypress'),
fromRoot('x-pack/legacy/plugins/apm/cypress'),
fromRoot('x-pack/legacy/plugins/apm/scripts'),
fromRoot('x-pack/legacy/plugins/canvas/canvas_plugin_src') // prevents server from restarting twice for Canvas plugin changes
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ import {
applyFiltersPopover,
changeTimeFilter,
extractTimeFilter,
IndexPatternsStart,
} from '../../../../../../plugins/data/public';
import { IndexPatternsStart } from '../../index_patterns';

export const GLOBAL_APPLY_FILTER_ACTION = 'GLOBAL_APPLY_FILTER_ACTION';

interface ActionContext {
Expand Down Expand Up @@ -74,7 +75,7 @@ export function createFilterAction(
if (selectedFilters.length > 1) {
const indexPatterns = await Promise.all(
filters.map(filter => {
return indexPatternsService.indexPatterns.get(filter.meta.index);
return indexPatternsService.indexPatterns.get(filter.meta.index!);
})
);

Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ export {
/** @public static code */
export * from '../common';
export { FilterStateManager } from './filter/filter_manager';
export { getFromSavedObject, getRoutes } from './index_patterns';
export { getFromSavedObject, getRoutes, flattenHitWrapper } from './index_patterns';
19 changes: 18 additions & 1 deletion src/legacy/core_plugins/data/public/index_patterns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,21 @@
* under the License.
*/

export * from './index_patterns_service';
import { IFieldType, IIndexPattern, indexPatterns } from '../../../../../plugins/data/public';

const getFromSavedObject = indexPatterns.getFromSavedObject;
const getRoutes = indexPatterns.getRoutes;
const flattenHitWrapper = indexPatterns.flattenHitWrapper;

export { getFromSavedObject, getRoutes, flattenHitWrapper };
export { IFieldType as FieldType };
export { IIndexPattern as StaticIndexPattern };
export {
Field,
FieldListInterface,
IndexPattern,
IndexPatterns,
IndexPatternsStart,
IndexPatternsSetup,
IndexPatternsService,
} from '../../../../../plugins/data/public';
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { isEmpty } from 'lodash';
import { IUiSettingsClient, SavedObjectsClientContract } from 'src/core/public';
import { getFromSavedObject } from '../../../index_patterns';
import { getFromSavedObject } from '../../../';

export async function fetchIndexPatterns(
savedObjectsClient: SavedObjectsClientContract,
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/data/public/shim/legacy_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { once } from 'lodash';

// @ts-ignore
import { uiModules } from 'ui/modules';
import { IndexPatterns } from '../index_patterns/index_patterns';
import { IndexPatterns } from '../';

/** @internal */
export const initLegacyModule = once((indexPatterns: IndexPatterns): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { mount } from 'enzyme';
import { IndexPattern } from 'ui/index_patterns';
// @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test';
import { flattenHitWrapper } from '../../../../data/public/index_patterns/index_patterns/flatten_hit';
import { flattenHitWrapper } from '../../../../data/public/';
import { DocViewTable } from './table';

// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ export default function (kibana) {

uiExports: {
hacks: [
'plugins/kibana/discover',
'plugins/kibana/dev_tools',
],
savedObjectTypes: [
'plugins/kibana/visualize/saved_visualizations/saved_visualization_register',
'plugins/kibana/discover/saved_searches/saved_search_register',
'plugins/kibana/dashboard/saved_dashboard/saved_dashboard_register',
],
app: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ import {

// @ts-ignore
import { initDashboardApp } from './legacy_app';
import { DataStart } from '../../../data/public';
import { DataStart, IndexPatterns } from '../../../data/public';
import { IEmbeddableStart } from '../../../../../plugins/embeddable/public';
import { NavigationStart } from '../../../navigation/public';
import { DataPublicPluginStart as NpDataStart } from '../../../../../plugins/data/public';
import { SharePluginStart } from '../../../../../plugins/share/public';

export interface RenderDeps {
core: LegacyCoreStart;
indexPatterns: DataStart['indexPatterns']['indexPatterns'];
indexPatterns: IndexPatterns;
dataStart: DataStart;
npDataStart: NpDataStart;
navigation: NavigationStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
unhashUrl,
} from './legacy_imports';
import { FilterStateManager, IndexPattern } from '../../../data/public';
import { Query, SavedQuery } from '../../../../../plugins/data/public';
import { Query, SavedQuery, IndexPatterns } from '../../../../../plugins/data/public';

import './dashboard_empty_screen_directive';

Expand Down Expand Up @@ -78,9 +78,7 @@ export interface DashboardAppControllerDependencies extends RenderDeps {
$routeParams: any;
getAppState: any;
globalState: State;
indexPatterns: {
getDefault: () => Promise<IndexPattern>;
};
indexPatterns: IndexPatterns;
dashboardConfig: any;
kbnUrl: KbnUrl;
AppStateClass: TAppStateClass<DashboardAppState>;
Expand Down Expand Up @@ -171,7 +169,7 @@ export class DashboardAppController {
} else {
indexPatterns.getDefault().then(defaultIndexPattern => {
$scope.$evalAsync(() => {
$scope.indexPatterns = [defaultIndexPattern];
$scope.indexPatterns = [defaultIndexPattern as IndexPattern];
});
});
}
Expand Down
42 changes: 22 additions & 20 deletions src/legacy/core_plugins/kibana/public/dashboard/dashboard_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@
import { uiModules } from 'ui/modules';
import { capabilities } from 'ui/capabilities';

uiModules.get('kibana')
.provider('dashboardConfig', () => {
let hideWriteControls = !capabilities.get().dashboard.showWriteControls;
export function dashboardConfigProvider() {
let hideWriteControls = !capabilities.get().dashboard.showWriteControls;

return {
/**
* Part of the exposed plugin API - do not remove without careful consideration.
* @type {boolean}
*/
turnHideWriteControlsOn() {
hideWriteControls = true;
},
$get() {
return {
getHideWriteControls() {
return hideWriteControls;
}
};
}
};
}

return {
/**
* Part of the exposed plugin API - do not remove without careful consideration.
* @type {boolean}
*/
turnHideWriteControlsOn() {
hideWriteControls = true;
},
$get() {
return {
getHideWriteControls() {
return hideWriteControls;
}
};
}
};
});
uiModules.get('kibana')
.provider('dashboardConfig', dashboardConfigProvider);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import _ from 'lodash';
import sinon from 'sinon';
import ngMock from 'ng_mock';
import expect from '@kbn/expect';
import '../../components/field_chooser/discover_field';
import { pluginInstance } from 'plugins/kibana/discover/index';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

// Load the kibana app dependencies.
Expand All @@ -32,8 +32,9 @@ describe('discoverField', function () {
let $scope;
let indexPattern;
let $elem;

beforeEach(ngMock.module('kibana'));
beforeEach(() => pluginInstance.initializeServices(true));
beforeEach(() => pluginInstance.initializeInnerAngular());
beforeEach(ngMock.module('app/discover'));
beforeEach(ngMock.inject(function (Private, $rootScope, $compile) {
$elem = angular.element(`
<discover-field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


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

describe('fieldCalculator', function () {
beforeEach(ngMock.module('kibana'));
beforeEach(() => pluginInstance.initializeInnerAngular());
beforeEach(ngMock.module('app/discover'));
beforeEach(ngMock.inject(function (Private) {
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import _ from 'lodash';
import sinon from 'sinon';
import expect from '@kbn/expect';
import $ from 'jquery';
import '../../components/field_chooser/field_chooser';
import { pluginInstance } from 'plugins/kibana/discover/index';
import FixturesHitsProvider from 'fixtures/hits';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import { SimpleSavedObject } from '../../../../../../../core/public';
Expand Down Expand Up @@ -70,8 +70,10 @@ describe('discover field chooser directives', function () {
on-remove-field="removeField"
></disc-field-chooser>
`);
beforeEach(() => pluginInstance.initializeServices(true));
beforeEach(() => pluginInstance.initializeInnerAngular());

beforeEach(ngMock.module('kibana', ($provide) => {
beforeEach(ngMock.module('app/discover', ($provide) => {
$provide.decorator('config', ($delegate) => {
// disable shortDots for these tests
$delegate.get = _.wrap($delegate.get, function (origGet, name) {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/discover/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@import 'embeddable/index';

// Doc Viewer
@import 'doc_viewer/index';
@import 'components/doc_viewer/index';

// Context styles
@import 'angular/context/index';
59 changes: 34 additions & 25 deletions src/legacy/core_plugins/kibana/public/discover/angular/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { getServices, subscribeWithScope } from './../kibana_services';
import { getAngularModule, getServices, subscribeWithScope } from './../kibana_services';

import './context_app';
import contextAppRouteTemplate from './context.html';
import { getRootBreadcrumbs } from '../breadcrumbs';
const { FilterBarQueryFilterProvider, uiRoutes, chrome } = getServices();
import { getRootBreadcrumbs } from '../helpers/breadcrumbs';
import { FilterStateManager } from '../../../../data/public/filter/filter_manager';
const { chrome } = getServices();

const k7Breadcrumbs = $route => {
const { indexPattern } = $route.current.locals;
Expand All @@ -44,26 +45,33 @@ const k7Breadcrumbs = $route => {
];
};

uiRoutes
// deprecated route, kept for compatibility
// should be removed in the future
.when('/context/:indexPatternId/:type/:id*', {
redirectTo: '/context/:indexPatternId/:id',
})
.when('/context/:indexPatternId/:id*', {
controller: ContextAppRouteController,
k7Breadcrumbs,
controllerAs: 'contextAppRoute',
resolve: {
indexPattern: function ($route, indexPatterns) {
return indexPatterns.get($route.current.params.indexPatternId);
getAngularModule().config($routeProvider => {
$routeProvider
// deprecated route, kept for compatibility
// should be removed in the future
.when('/discover/context/:indexPatternId/:type/:id*', {
redirectTo: '/discover/context/:indexPatternId/:id',
})
.when('/discover/context/:indexPatternId/:id*', {
controller: ContextAppRouteController,
k7Breadcrumbs,
controllerAs: 'contextAppRoute',
resolve: {
indexPattern: ($route, Promise) => {
const indexPattern = getServices().indexPatterns.get(
$route.current.params.indexPatternId
);
return Promise.props({ ip: indexPattern });
},
},
},
template: contextAppRouteTemplate,
});
template: contextAppRouteTemplate,
});
});

function ContextAppRouteController($routeParams, $scope, AppState, config, indexPattern, Private) {
const queryFilter = Private(FilterBarQueryFilterProvider);
function ContextAppRouteController($routeParams, $scope, AppState, config, $route, getAppState, globalState) {
const filterManager = getServices().filterManager;
const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager);
const indexPattern = $route.current.locals.indexPattern.ip;

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

const updateSubsciption = subscribeWithScope($scope, queryFilter.getUpdates$(), {
const updateSubsciption = subscribeWithScope($scope, filterManager.getUpdates$(), {
next: () => {
this.filters = _.cloneDeep(queryFilter.getFilters());
this.filters = _.cloneDeep(filterManager.getFilters());
},
});

$scope.$on('$destroy', function () {
$scope.$on('$destroy', () => {
filterStateManager.destroy();
updateSubsciption.unsubscribe();
});
this.anchorId = $routeParams.id;
this.indexPattern = indexPattern;
this.discoverUrl = chrome.navLinks.get('kibana:discover').url;
this.filters = _.cloneDeep(queryFilter.getFilters());
this.filters = _.cloneDeep(filterManager.getFilters());
}

function createDefaultAppState(config, indexPattern) {
Expand Down
Loading

0 comments on commit 4f34863

Please sign in to comment.