Skip to content

Commit

Permalink
Merge branch 'master' into telemetry/update-banner
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Nov 12, 2019
2 parents f68c610 + 19f7e99 commit e123cc5
Show file tree
Hide file tree
Showing 109 changed files with 72,919 additions and 47,485 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ describe('esArchiver: createCreateIndexStream()', () => {
sinon.assert.calledWith(client.indices.create, {
method: 'PUT',
index: 'index',
include_type_name: false,
body: {
settings: undefined,
mappings: undefined,
Expand Down
4 changes: 0 additions & 4 deletions src/es_archiver/lib/indices/create_index_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ export function createCreateIndexStream({ client, stats, skipExisting, log }) {

async function handleIndex(record) {
const { index, settings, mappings, aliases } = record.value;

// Determine if the mapping belongs to a pre-7.0 instance, for BWC tests, mainly
const isPre7Mapping = !!mappings && Object.keys(mappings).length > 0 && !mappings.properties;
const isKibana = index.startsWith('.kibana');

async function attemptToCreate(attemptNumber = 1) {
Expand All @@ -55,7 +52,6 @@ export function createCreateIndexStream({ client, stats, skipExisting, log }) {
await client.indices.create({
method: 'PUT',
index,
include_type_name: isPre7Mapping,
body: {
settings,
mappings,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.create": {
"url_params": {
"include_type_name": "__flag__",
"wait_for_active_shards": "",
"timeout": "",
"master_timeout": ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.get": {
"url_params": {
"include_type_name": "__flag__",
"local": "__flag__",
"ignore_unavailable": "__flag__",
"allow_no_indices": "__flag__",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.get_field_mapping": {
"url_params": {
"include_type_name": "__flag__",
"include_defaults": "__flag__",
"ignore_unavailable": "__flag__",
"allow_no_indices": "__flag__",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.get_template": {
"url_params": {
"include_type_name": "__flag__",
"flat_settings": "__flag__",
"master_timeout": "",
"local": "__flag__"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.put_template": {
"url_params": {
"include_type_name": "__flag__",
"order": "",
"create": "__flag__",
"timeout": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.rollover": {
"url_params": {
"include_type_name": "__flag__",
"timeout": "",
"dry_run": "__flag__",
"master_timeout": "",
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 e123cc5

Please sign in to comment.