Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into revert-chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Nov 12, 2019
2 parents 3c0272e + 19f7e99 commit 2c97999
Show file tree
Hide file tree
Showing 298 changed files with 8,951 additions and 11,387 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"dependencies": {
"@babel/core": "^7.5.5",
"@babel/register": "^7.5.5",
"@elastic/charts": "^13.5.12",
"@elastic/charts": "^14.0.0",
"@elastic/datemath": "5.0.2",
"@elastic/ems-client": "1.0.5",
"@elastic/eui": "14.8.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-config-kibana/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ module.exports = {
from: 'x-pack',
toRelative: 'x-pack',
},
{
from: 'react-router',
to: 'react-router-dom',
},
],
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';

import {
Link,
} from 'react-router';
import { Link } from 'react-router'; // eslint-disable-line

import classNames from 'classnames';

Expand Down
5 changes: 1 addition & 4 deletions packages/kbn-ui-framework/doc_site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ import 'regenerator-runtime/runtime';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import {
Router,
hashHistory,
} from 'react-router';
import { Router, hashHistory } from 'react-router'; // eslint-disable-line

// Store.
import configureStore from './store/configure_store';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ import {
compose,
} from 'redux';
import thunk from 'redux-thunk';
import { browserHistory } from 'react-router';
import {
routerMiddleware,
routerReducer,
} from 'react-router-redux';
import { browserHistory } from 'react-router'; // eslint-disable-line
import { routerMiddleware, routerReducer } from 'react-router-redux';

import codeViewerReducer from './reducers/code_viewer_reducer';
import sandboxReducer from './reducers/sandbox_reducer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

import React from 'react';

import {
Link,
} from 'react-router';
import { Link } from 'react-router'; // eslint-disable-line

export const NotFoundView = () => (
<div className="guideContentPage">
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-router": "^3.2.0",
"react-router-dom": "4.2.2",
"react-router-redux": "^4.0.8",
"redux": "3.7.2",
"redux-thunk": "2.2.0",
Expand Down
5 changes: 4 additions & 1 deletion src/core/server/http/http_server.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface RequestFixtureOptions {
path?: string;
method?: RouteMethod;
socket?: Socket;
routeTags?: string[];
}

function createKibanaRequestMock({
Expand All @@ -49,6 +50,7 @@ function createKibanaRequestMock({
query = {},
method = 'get',
socket = new Socket(),
routeTags,
}: RequestFixtureOptions = {}) {
const queryString = querystring.stringify(query);
return KibanaRequest.from(
Expand All @@ -61,10 +63,11 @@ function createKibanaRequestMock({
method,
url: {
path,
pathname: path,
query: queryString,
search: queryString ? `?${queryString}` : queryString,
},
route: { settings: {} },
route: { settings: { tags: routeTags } },
raw: {
req: { socket },
},
Expand Down
1 change: 1 addition & 0 deletions src/core/server/saved_objects/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface SavedObjectsLegacyService<Request = any> {
addScopedSavedObjectsClientWrapperFactory: SavedObjectsClientProvider<
Request
>['addClientWrapperFactory'];
setScopedSavedObjectsClientFactory: SavedObjectsClientProvider<Request>['setClientFactory'];
getScopedSavedObjectsClient: SavedObjectsClientProvider<Request>['getClient'];
SavedObjectsClient: typeof SavedObjectsClient;
types: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class SavedObjectsClientProvider<Request = unknown> {
this._wrapperFactories.add(priority, { id, factory });
}

setClientFactory(customClientFactory: SavedObjectsClientFactory) {
setClientFactory(customClientFactory: SavedObjectsClientFactory<Request>) {
if (this._clientFactory !== this._originalClientFactory) {
throw new Error(`custom client factory is already set, unable to replace the current one`);
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,8 @@ export interface SavedObjectsLegacyService<Request = any> {
// (undocumented)
schema: SavedObjectsSchema;
// (undocumented)
setScopedSavedObjectsClientFactory: SavedObjectsClientProvider<Request>['setClientFactory'];
// (undocumented)
types: string[];
}

Expand Down
51 changes: 2 additions & 49 deletions src/legacy/core_plugins/data/public/shim/legacy_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { wrapInI18nContext } from 'ui/i18n';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { npStart } from 'ui/new_platform';
import { FilterBar, ApplyFiltersPopover } from '../filter';
import { FilterBar } from '../filter';
import { IndexPatterns } from '../index_patterns/index_patterns';

/** @internal */
Expand Down Expand Up @@ -70,54 +70,7 @@ export const initLegacyModule = once((indexPatterns: IndexPatterns): void => {
['className', { watchDepth: 'reference' }],
['pluginDataStart', { watchDepth: 'reference' }],
]);
})
.directive('applyFiltersPopover', () => {
return {
restrict: 'E',
template: '',
compile: (elem: any) => {
const child = document.createElement('apply-filters-popover-helper');

// Copy attributes to the child directive
for (const attr of elem[0].attributes) {
child.setAttribute(attr.name, attr.value);
}

// Add a key attribute that will force a full rerender every time that
// a filter changes.
child.setAttribute('key', 'key');

// Append helper directive
elem.append(child);

const linkFn = ($scope: any, _: any, $attr: any) => {
// Watch only for filter changes to update key.
$scope.$watch(
() => {
return $scope.$eval($attr.filters) || [];
},
(newVal: any) => {
$scope.key = Date.now();
},
true
);
};

return linkFn;
},
};
})
.directive('applyFiltersPopoverHelper', (reactDirective: any) =>
reactDirective(wrapInI18nContext(ApplyFiltersPopover), [
['filters', { watchDepth: 'collection' }],
['onCancel', { watchDepth: 'reference' }],
['onSubmit', { watchDepth: 'reference' }],
['indexPatterns', { watchDepth: 'collection' }],

// Key is needed to trigger a full rerender of the component
'key',
])
);
});

uiModules.get('kibana/index_patterns').value('indexPatterns', indexPatterns);
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { fromExpression } from '@kbn/interpreter/target/common';
import { fromExpression, toExpression } from '@kbn/interpreter/target/common';
import { DataAdapter, RequestAdapter, Adapters } from '../../../../../../plugins/inspector/public';
import { getInterpreter } from './services';
import { ExpressionAST, IExpressionLoaderParams, IInterpreterResult } from './types';
Expand All @@ -38,17 +38,18 @@ export class ExpressionDataHandler {
private inspectorAdapters: Adapters;
private promise: Promise<IInterpreterResult>;

public isPending: boolean = true;
constructor(expression: string | ExpressionAST, params: IExpressionLoaderParams) {
if (typeof expression === 'string') {
this.expression = expression;
this.ast = fromExpression(expression) as ExpressionAST;
} else {
this.ast = expression;
this.expression = '';
this.expression = toExpression(this.ast);
}

this.abortController = new AbortController();
this.inspectorAdapters = this.getActiveInspectorAdapters();
this.inspectorAdapters = params.inspectorAdapters || this.getActiveInspectorAdapters();

const getInitialContext = () => ({
type: 'kibana_context',
Expand All @@ -58,11 +59,21 @@ export class ExpressionDataHandler {
const defaultContext = { type: 'null' };

const interpreter = getInterpreter();
this.promise = interpreter.interpretAst(this.ast, params.context || defaultContext, {
getInitialContext,
inspectorAdapters: this.inspectorAdapters,
abortSignal: this.abortController.signal,
});
this.promise = interpreter
.interpretAst(this.ast, params.context || defaultContext, {
getInitialContext,
inspectorAdapters: this.inspectorAdapters,
abortSignal: this.abortController.signal,
})
.then(
(v: IInterpreterResult) => {
this.isPending = false;
return v;
},
() => {
this.isPending = false;
}
);
}

cancel = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('execute helper function', () => {
});

describe('ExpressionLoader', () => {
const expressionString = '';
const expressionString = 'demodata';

describe('constructor', () => {
it('accepts expression string', () => {
Expand Down Expand Up @@ -134,6 +134,8 @@ describe('ExpressionLoader', () => {
(ExpressionDataHandler as jest.Mock).mockImplementationOnce(() => ({
getData: () => true,
cancel: cancelMock,
isPending: () => true,
inspect: () => {},
}));

const expressionLoader = new ExpressionLoader(element, expressionString, {});
Expand All @@ -160,10 +162,15 @@ describe('ExpressionLoader', () => {
(ExpressionDataHandler as jest.Mock).mockImplementationOnce(() => ({
getData,
cancel: cancelMock,
isPending: () => true,
inspect: () => {},
}));

(ExpressionDataHandler as jest.Mock).mockImplementationOnce(() => ({
getData,
cancel: cancelMock,
isPending: () => true,
inspect: () => {},
}));

const expressionLoader = new ExpressionLoader(element, expressionString, {});
Expand Down Expand Up @@ -193,6 +200,8 @@ describe('ExpressionLoader', () => {
(ExpressionDataHandler as jest.Mock).mockImplementationOnce(() => ({
getData,
cancel: cancelMock,
isPending: () => true,
inspect: () => {},
}));

const expressionLoader = new ExpressionLoader(element, expressionString, {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ export class ExpressionLoader {
private loadingSubject: Subject<void>;
private data: Data;
private params: IExpressionLoaderParams = {};
private ignoreNextResponse = false;

constructor(
element: HTMLElement,
expression: string | ExpressionAST,
params: IExpressionLoaderParams
expression?: string | ExpressionAST,
params?: IExpressionLoaderParams
) {
this.dataSubject = new Subject();
this.data$ = this.dataSubject.asObservable().pipe(share());
Expand All @@ -65,7 +66,9 @@ export class ExpressionLoader {

this.setParams(params);

this.loadData(expression, this.params);
if (expression) {
this.loadData(expression, this.params);
}
}

destroy() {
Expand Down Expand Up @@ -117,9 +120,10 @@ export class ExpressionLoader {
update(expression?: string | ExpressionAST, params?: IExpressionLoaderParams): void {
this.setParams(params);

this.loadingSubject.next();
if (expression) {
this.loadData(expression, this.params);
} else {
} else if (this.data) {
this.render(this.data);
}
}
Expand All @@ -128,18 +132,22 @@ export class ExpressionLoader {
expression: string | ExpressionAST,
params: IExpressionLoaderParams
): Promise<void> => {
this.loadingSubject.next();
if (this.dataHandler) {
if (this.dataHandler && this.dataHandler.isPending) {
this.ignoreNextResponse = true;
this.dataHandler.cancel();
}
this.setParams(params);
this.dataHandler = new ExpressionDataHandler(expression, params);
if (!params.inspectorAdapters) params.inspectorAdapters = this.dataHandler.inspect();
const data = await this.dataHandler.getData();
if (this.ignoreNextResponse) {
this.ignoreNextResponse = false;
return;
}
this.dataSubject.next(data);
};

private render(data: Data): void {
this.loadingSubject.next();
this.renderHandler.render(data, this.params.extraHandlers);
}

Expand All @@ -148,23 +156,16 @@ export class ExpressionLoader {
return;
}

if (params.searchContext && this.params.searchContext) {
if (params.searchContext) {
this.params.searchContext = _.defaults(
{},
params.searchContext,
this.params.searchContext
this.params.searchContext || {}
) as any;
}
if (params.extraHandlers && this.params) {
this.params.extraHandlers = params.extraHandlers;
}

if (!Object.keys(this.params).length) {
this.params = {
...params,
searchContext: { type: 'kibana_context', ...(params.searchContext || {}) },
};
}
}
}

Expand Down
Loading

0 comments on commit 2c97999

Please sign in to comment.