Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"paths": {
"common.ui": "src/legacy/ui",
"data": "src/legacy/core_plugins/data",
"expressions": "src/legacy/core_plugins/expressions",
"kibana_react": "src/legacy/core_plugins/kibana_react",
"server": "src/legacy/server",
"console": "src/legacy/core_plugins/console",
Expand Down
4 changes: 1 addition & 3 deletions src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

// /// Define plugin function
import { DataPlugin as Plugin, DataSetup, DataStart } from './plugin';
import { DataPlugin as Plugin, DataSetup } from './plugin';

export function plugin() {
return new Plugin();
Expand All @@ -28,9 +28,7 @@ export function plugin() {

/** @public types */
export type DataSetup = DataSetup;
export type DataStart = DataStart;

export { ExpressionRenderer, ExpressionRendererProps } from './expressions';
export { FilterBar, ApplyFiltersPopover } from './filter';
export {
Field,
Expand Down
7 changes: 1 addition & 6 deletions src/legacy/core_plugins/data/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
*/

import { npSetup, npStart } from 'ui/new_platform';
// @ts-ignore
import { getInterpreter } from 'plugins/interpreter/interpreter';
import { LegacyDependenciesPlugin } from './shim/legacy_dependencies_plugin';
import { plugin } from '.';

Expand All @@ -45,9 +43,6 @@ const legacyPlugin = new LegacyDependenciesPlugin();

export const setup = dataPlugin.setup(npSetup.core, {
__LEGACY: legacyPlugin.setup(),
inspector: npSetup.plugins.inspector,
});

export const start = dataPlugin.start(npStart.core, {
inspector: npStart.plugins.inspector,
});
export const start = dataPlugin.start(npStart.core);
24 changes: 3 additions & 21 deletions src/legacy/core_plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@
*/

import { CoreSetup, CoreStart, Plugin } from '../../../../core/public';
import { ExpressionsService, ExpressionsSetup, ExpressionsStart } from './expressions';
import { SearchService, SearchSetup } from './search';
import { QueryService, QuerySetup } from './query';
import { FilterService, FilterSetup } from './filter';
import { IndexPatternsService, IndexPatternsSetup } from './index_patterns';
import { LegacyDependenciesPluginSetup } from './shim/legacy_dependencies_plugin';
import {
Start as InspectorStart,
Setup as InspectorSetup,
} from '../../../../plugins/inspector/public';

/**
* Interface for any dependencies on other plugins' `setup` contracts.
Expand All @@ -36,11 +31,6 @@ import {
*/
export interface DataPluginSetupDependencies {
__LEGACY: LegacyDependenciesPluginSetup;
inspector: InspectorSetup;
}

export interface DataPluginStartDependencies {
inspector: InspectorStart;
}

/**
Expand All @@ -49,17 +39,12 @@ export interface DataPluginStartDependencies {
* @public
*/
export interface DataSetup {
expressions: ExpressionsSetup;
indexPatterns: IndexPatternsSetup;
filter: FilterSetup;
query: QuerySetup;
search: SearchSetup;
}

export interface DataStart {
expressions: ExpressionsStart;
}

/**
* Data Plugin - public
*
Expand All @@ -71,9 +56,8 @@ export interface DataStart {
* in the setup/start interfaces. The remaining items exported here are either types,
* or static code.
*/
export class DataPlugin implements Plugin<DataSetup, DataStart, DataPluginSetupDependencies> {
export class DataPlugin implements Plugin<DataSetup, {}, DataPluginSetupDependencies> {
// Exposed services, sorted alphabetically
private readonly expressions: ExpressionsService = new ExpressionsService();
private readonly filter: FilterService = new FilterService();
private readonly indexPatterns: IndexPatternsService = new IndexPatternsService();
private readonly query: QueryService = new QueryService();
Expand All @@ -89,8 +73,8 @@ export class DataPlugin implements Plugin<DataSetup, DataStart, DataPluginSetupD
uiSettings,
savedObjectsClient,
});

this.setupApi = {
expressions: this.expressions.setup(),
indexPatterns: indexPatternsService,
filter: this.filter.setup({
uiSettings,
Expand All @@ -103,15 +87,13 @@ export class DataPlugin implements Plugin<DataSetup, DataStart, DataPluginSetupD
return this.setupApi;
}

public start(core: CoreStart, plugins: DataPluginStartDependencies) {
public start(core: CoreStart) {
return {
...this.setupApi!,
expressions: this.expressions.start({ inspector: plugins.inspector }),
};
}

public stop() {
this.expressions.stop();
this.indexPatterns.stop();
this.filter.stop();
this.query.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export { fromUser } from './lib/from_user';
export { toUser } from './lib/to_user';
export { getQueryLog } from './lib/get_query_log';

export { Query } from '../../../../../../plugins/data/common/query/types';
export { Query } from '../../../../../../plugins/data/public';
41 changes: 41 additions & 0 deletions src/legacy/core_plugins/expressions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { resolve } from 'path';
import { Legacy } from '../../../../kibana';

// eslint-disable-next-line import/no-default-export
export default function DataExpressionsPlugin(kibana: any) {
const config: Legacy.PluginSpecOptions = {
id: 'expressions',
require: ['elasticsearch'],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requires data as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, ignore this comment. it shouldn't require data, all the functions that do require data should be registered from data plugin (or another plugin listing data as dependency)

publicDir: resolve(__dirname, 'public'),
config: (Joi: any) => {
return Joi.object({
enabled: Joi.boolean().default(true),
}).default();
},
init: (server: Legacy.Server) => ({}),
uiExports: {
injectDefaultVars: () => ({}),
},
};

return new kibana.Plugin(config);
}
4 changes: 4 additions & 0 deletions src/legacy/core_plugins/expressions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "expressions",
"version": "kibana"
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export class ExpressionsService {
});

return {
registerType: npSetup.plugins.data.expressions.registerType,
registerFunction: npSetup.plugins.data.expressions.registerFunction,
registerRenderer: npSetup.plugins.data.expressions.registerRenderer,
registerType: npSetup.plugins.expressions.registerType,
registerFunction: npSetup.plugins.expressions.registerFunction,
registerRenderer: npSetup.plugins.expressions.registerRenderer,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import { TimeRange } from 'src/plugins/data/public';
import { Filter } from '@kbn/es-query';
import { Adapters } from '../../../../../ui/public/inspector';
import { Query } from '../../query';
import { ExpressionAST } from '../../../../../../plugins/data/common/expressions/types';
import { Adapters } from '../../../../../../plugins/inspector/public';
import { Query } from '../../../../../../plugins/data/public';
import { ExpressionAST } from '../../../../../../plugins/expressions/common';

export { ExpressionAST, TimeRange, Adapters, Filter, Query };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { execute, ExpressionDataHandler } from './execute';
import { fromExpression } from '@kbn/interpreter/common';
import { ExpressionAST } from '../../../../../../plugins/data/common/expressions/types';
import { ExpressionAST } from './_types';

jest.mock('../services', () => ({
getInterpreter: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { loader, ExpressionLoader } from './loader';
import { fromExpression } from '@kbn/interpreter/common';
import { IInterpreterRenderHandlers } from './_types';
import { Observable } from 'rxjs';
import { ExpressionAST } from '../../../../../../plugins/data/common/expressions/types';
import { ExpressionAST } from '../../../../../../plugins/expressions/common';

const element: HTMLElement = null as any;

Expand Down
37 changes: 37 additions & 0 deletions src/legacy/core_plugins/expressions/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// /// Define plugin function
import {
DataExpressionsPlugin as Plugin,
DataExpressionsSetup,
DataExpressionsStart,
} from './plugin';

export function plugin() {
return new Plugin();
}

// /// Export types & static code

/** @public types */
export type DataExpressionsSetup = DataExpressionsSetup;
export type DataExpressionsStart = DataExpressionsStart;

export { ExpressionRenderer, ExpressionRendererProps } from './expressions';
29 changes: 29 additions & 0 deletions src/legacy/core_plugins/expressions/public/legacy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { npSetup, npStart } from 'ui/new_platform';
import { plugin } from '.';

const expressionsPlugin = plugin();

export const setup = expressionsPlugin.setup(npSetup.core);

export const start = expressionsPlugin.start(npStart.core, {
inspector: npStart.plugins.inspector,
});
35 changes: 35 additions & 0 deletions src/legacy/core_plugins/expressions/public/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { DataExpressionsSetup } from '.';

function createExpressionsSetupMock() {
const mock: MockedKeys<Partial<DataExpressionsSetup>> = {};

return mock;
}

function createExpressionsStartMock() {
return {};
}

export const dataPluginMock = {
createSetup: createExpressionsSetupMock,
createStart: createExpressionsStartMock,
};
Loading