Skip to content

Commit

Permalink
Move kuery_autocomplete ⇒ NP
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Feb 3, 2020
1 parent 38dc1cb commit cf997c3
Show file tree
Hide file tree
Showing 25 changed files with 95 additions and 117 deletions.
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"xpack.idxMgmt": "legacy/plugins/index_management",
"xpack.indexLifecycleMgmt": "legacy/plugins/index_lifecycle_management",
"xpack.infra": "legacy/plugins/infra",
"xpack.kueryAutocomplete": "legacy/plugins/kuery_autocomplete",
"xpack.data": "plugins/data",
"xpack.lens": "legacy/plugins/lens",
"xpack.licenseMgmt": "legacy/plugins/license_management",
"xpack.licensing": "plugins/licensing",
Expand Down
2 changes: 0 additions & 2 deletions x-pack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { licenseManagement } from './legacy/plugins/license_management';
import { indexManagement } from './legacy/plugins/index_management';
import { indexLifecycleManagement } from './legacy/plugins/index_lifecycle_management';
import { spaces } from './legacy/plugins/spaces';
import { kueryAutocompleteInitializer } from './legacy/plugins/kuery_autocomplete';
import { canvas } from './legacy/plugins/canvas';
import { infra } from './legacy/plugins/infra';
import { taskManager } from './legacy/plugins/task_manager';
Expand Down Expand Up @@ -65,7 +64,6 @@ module.exports = function(kibana) {
licenseManagement(kibana),
indexManagement(kibana),
indexLifecycleManagement(kibana),
kueryAutocompleteInitializer(kibana),
infra(kibana),
taskManager(kibana),
rollup(kibana),
Expand Down
22 changes: 0 additions & 22 deletions x-pack/legacy/plugins/kuery_autocomplete/index.ts

This file was deleted.

27 changes: 0 additions & 27 deletions x-pack/legacy/plugins/kuery_autocomplete/public/legacy.ts

This file was deleted.

41 changes: 0 additions & 41 deletions x-pack/legacy/plugins/kuery_autocomplete/public/plugin.ts

This file was deleted.

13 changes: 13 additions & 0 deletions x-pack/plugins/data/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"id": "data_xpack",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": [
"xpack"
],
"requiredPlugins": [
"data"
],
"server": false,
"ui": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { PluginInitializerContext } from 'src/core/public';
import { KueryAutocompletePlugin as Plugin } from './plugin';

export function plugin(initializerContext: PluginInitializerContext) {
return new Plugin(initializerContext);
}
export {
setupKqlQuerySuggestionProvider,
KUERY_LANGUAGE_NAME,
} from './providers/kql_query_suggestion';
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

import { setupGetConjunctionSuggestions } from './conjunction';
import { autocomplete, esKuery } from '../../../../../../src/plugins/data/public';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { autocomplete, esKuery } from '../../../../../../../src/plugins/data/public';
import { coreMock } from '../../../../../../../src/core/public/mocks';

const mockKueryNode = (kueryNode: Partial<esKuery.KueryNode>) =>
(kueryNode as unknown) as esKuery.KueryNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from 'react';
import { $Keys } from 'utility-types';
import { FormattedMessage } from '@kbn/i18n/react';
import { KqlQuerySuggestionProvider } from './types';
import { autocomplete } from '../../../../../../src/plugins/data/public';
import { autocomplete } from '../../../../../../../src/plugins/data/public';

const bothArgumentsText = (
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import indexPatternResponse from './__fixtures__/index_pattern_response.json';

import { setupGetFieldSuggestions } from './field';
import { isFilterable, autocomplete, esKuery } from '../../../../../../src/plugins/data/public';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { isFilterable, autocomplete, esKuery } from '../../../../../../../src/plugins/data/public';
import { coreMock } from '../../../../../../../src/core/public/mocks';

const mockKueryNode = (kueryNode: Partial<esKuery.KueryNode>) =>
(kueryNode as unknown) as esKuery.KueryNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { flatten } from 'lodash';
import { FormattedMessage } from '@kbn/i18n/react';
import { escapeKuery } from './lib/escape_kuery';
import { sortPrefixFirst } from './sort_prefix_first';
import { IFieldType, isFilterable, autocomplete } from '../../../../../../src/plugins/data/public';
import {
IFieldType,
isFilterable,
autocomplete,
} from '../../../../../../../src/plugins/data/public';
import { KqlQuerySuggestionProvider } from './types';

const getDescription = (field: IFieldType) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import { setupGetFieldSuggestions } from './field';
import { setupGetValueSuggestions } from './value';
import { setupGetOperatorSuggestions } from './operator';
import { setupGetConjunctionSuggestions } from './conjunction';
import { esKuery, autocomplete } from '../../../../../../src/plugins/data/public';
import { esKuery, autocomplete } from '../../../../../../../src/plugins/data/public';

const cursorSymbol = '@kuery-cursor@';

const dedup = (suggestions: autocomplete.QuerySuggestion[]): autocomplete.QuerySuggestion[] =>
uniq(suggestions, ({ type, text, start, end }) => [type, text, start, end].join('|'));

export const KUERY_LANGUAGE_NAME = 'kuery';

export const setupKqlQuerySuggestionProvider = (
core: CoreSetup
): autocomplete.QuerySuggestionsGetFn => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import indexPatternResponse from './__fixtures__/index_pattern_response.json';

import { setupGetOperatorSuggestions } from './operator';
import { autocomplete, esKuery } from '../../../../../../src/plugins/data/public';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { autocomplete, esKuery } from '../../../../../../../src/plugins/data/public';
import { coreMock } from '../../../../../../../src/core/public/mocks';

const mockKueryNode = (kueryNode: Partial<esKuery.KueryNode>) =>
(kueryNode as unknown) as esKuery.KueryNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { $Keys } from 'utility-types';
import { flatten } from 'lodash';

import { KqlQuerySuggestionProvider } from './types';
import { autocomplete } from '../../../../../../src/plugins/data/public';
import { autocomplete } from '../../../../../../../src/plugins/data/public';

const equalsText = (
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { CoreSetup } from 'kibana/public';
import { esKuery, autocomplete } from '../../../../../../src/plugins/data/public';
import { esKuery, autocomplete } from '../../../../../../../src/plugins/data/public';

export type KqlQuerySuggestionProvider<T = autocomplete.BasicQuerySuggestion> = (
core: CoreSetup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/
import { setupGetValueSuggestions } from './value';
import indexPatternResponse from './__fixtures__/index_pattern_response.json';
import { coreMock } from '../../../../../../src/core/public/mocks';
import { autocomplete, esKuery } from '../../../../../../src/plugins/data/public';
import { setAutocompleteService } from '../services';
import { coreMock } from '../../../../../../../src/core/public/mocks';
import { autocomplete, esKuery } from '../../../../../../../src/plugins/data/public';
import { setAutocompleteService } from '../../../services';

const mockKueryNode = (kueryNode: Partial<esKuery.KueryNode>) =>
(kueryNode as unknown) as esKuery.KueryNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import { flatten } from 'lodash';
import { escapeQuotes } from './lib/escape_kuery';
import { KqlQuerySuggestionProvider } from './types';
import { getAutocompleteService } from '../services';
import { autocomplete } from '../../../../../../src/plugins/data/public';
import { getAutocompleteService } from '../../../services';
import { autocomplete } from '../../../../../../../src/plugins/data/public';

const wrapAsSuggestions = (start: number, end: number, query: string, values: string[]) =>
values
Expand Down
20 changes: 20 additions & 0 deletions x-pack/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { PluginInitializer } from 'kibana/public';
import {
DataPublicPlugin as Plugin,
DataPublicSetup,
DataPublicStart,
DataPublicSetupDependencies,
DataPublicStartDependencies,
} from './plugin';

export const plugin: PluginInitializer<
DataPublicSetup,
DataPublicStart,
DataPublicSetupDependencies,
DataPublicStartDependencies
> = () => new Plugin();
33 changes: 33 additions & 0 deletions x-pack/plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
import { DataPublicPluginStart, DataPublicPluginSetup } from '../../../../src/plugins/data/public';
import { setAutocompleteService } from './services';
import { setupKqlQuerySuggestionProvider, KUERY_LANGUAGE_NAME } from './autocomplete';

export interface DataPublicSetupDependencies {
data: DataPublicPluginSetup;
}
export interface DataPublicStartDependencies {
data: DataPublicPluginStart;
}

export type DataPublicSetup = ReturnType<DataPublicPlugin['setup']>;
export type DataPublicStart = ReturnType<DataPublicPlugin['start']>;

export class DataPublicPlugin implements Plugin {
public setup(core: CoreSetup, plugins: DataPublicSetupDependencies) {
plugins.data.autocomplete.addQuerySuggestionProvider(
KUERY_LANGUAGE_NAME,
setupKqlQuerySuggestionProvider(core)
);
}

public start(core: CoreStart, plugins: DataPublicStartDependencies) {
setAutocompleteService(plugins.data.autocomplete);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { createGetterSetter } from '../../../../../src/plugins/kibana_utils/public';
import { DataPublicPluginStart } from '../../../../../src/plugins/data/public';
import { createGetterSetter } from '../../../../src/plugins/kibana_utils/public';
import { DataPublicPluginStart } from '../../../../src/plugins/data/public';

export const [getAutocompleteService, setAutocompleteService] = createGetterSetter<
DataPublicPluginStart['autocomplete']
Expand Down

0 comments on commit cf997c3

Please sign in to comment.