Separate class\type definitions from plugin instance setup (#38894)
* Separate class\type defenitions from plugin instance setup in shim plugin definition This helps avoiding circular dependency issues that were obsereved in filter-manager branch (due to code starting to use the data plugin). * typescript fun
This commit is contained in:
parent
5baf958adf
commit
4a39c7a33e
|
@ -22,8 +22,6 @@
|
||||||
// and handled by the platform itself in the setup method
|
// and handled by the platform itself in the setup method
|
||||||
// of the ExpressionExectorService
|
// of the ExpressionExectorService
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { getInterpreter } from 'plugins/interpreter/interpreter';
|
|
||||||
// @ts-ignore
|
|
||||||
import { renderersRegistry } from 'plugins/interpreter/registries';
|
import { renderersRegistry } from 'plugins/interpreter/registries';
|
||||||
import { ExpressionsService, ExpressionsSetup } from './expressions';
|
import { ExpressionsService, ExpressionsSetup } from './expressions';
|
||||||
import { SearchService, SearchSetup } from './search';
|
import { SearchService, SearchSetup } from './search';
|
||||||
|
@ -31,7 +29,7 @@ import { QueryService, QuerySetup } from './query';
|
||||||
import { FilterService, FilterSetup } from './filter';
|
import { FilterService, FilterSetup } from './filter';
|
||||||
import { IndexPatternsService, IndexPatternsSetup } from './index_patterns';
|
import { IndexPatternsService, IndexPatternsSetup } from './index_patterns';
|
||||||
|
|
||||||
class DataPlugin {
|
export class DataPlugin {
|
||||||
// Exposed services, sorted alphabetically
|
// Exposed services, sorted alphabetically
|
||||||
private readonly expressions: ExpressionsService;
|
private readonly expressions: ExpressionsService;
|
||||||
private readonly filter: FilterService;
|
private readonly filter: FilterService;
|
||||||
|
@ -48,6 +46,9 @@ class DataPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public setup(): DataSetup {
|
public setup(): DataSetup {
|
||||||
|
// TODO: this is imported here to avoid circular imports.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const { getInterpreter } = require('plugins/interpreter/interpreter');
|
||||||
return {
|
return {
|
||||||
expressions: this.expressions.setup({
|
expressions: this.expressions.setup({
|
||||||
interpreter: {
|
interpreter: {
|
||||||
|
@ -71,13 +72,6 @@ class DataPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* We export data here so that users importing from 'plugins/data'
|
|
||||||
* will automatically receive the response value of the `setup` contract, mimicking
|
|
||||||
* the data that will eventually be injected by the new platform.
|
|
||||||
*/
|
|
||||||
export const data = new DataPlugin().setup();
|
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export interface DataSetup {
|
export interface DataSetup {
|
||||||
expressions: ExpressionsSetup;
|
expressions: ExpressionsSetup;
|
||||||
|
|
27
src/legacy/core_plugins/data/public/setup.ts
Normal file
27
src/legacy/core_plugins/data/public/setup.ts
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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 { DataPlugin } from './index';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We export data here so that users importing from 'plugins/data'
|
||||||
|
* will automatically receive the response value of the `setup` contract, mimicking
|
||||||
|
* the data that will eventually be injected by the new platform.
|
||||||
|
*/
|
||||||
|
export const data = new DataPlugin().setup();
|
|
@ -38,7 +38,7 @@ import {
|
||||||
} from './query';
|
} from './query';
|
||||||
import { timefilter } from 'ui/timefilter';
|
import { timefilter } from 'ui/timefilter';
|
||||||
|
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
data.filter.loadLegacyDirectives();
|
data.filter.loadLegacyDirectives();
|
||||||
|
|
||||||
const module = uiModules.get('apps/context', [
|
const module = uiModules.get('apps/context', [
|
||||||
|
|
|
@ -39,7 +39,7 @@ import { DashboardListing, EMPTY_FILTER } from './listing/dashboard_listing';
|
||||||
import { uiModules } from 'ui/modules';
|
import { uiModules } from 'ui/modules';
|
||||||
import 'ui/capabilities/route_setup';
|
import 'ui/capabilities/route_setup';
|
||||||
|
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
data.search.loadLegacyDirectives();
|
data.search.loadLegacyDirectives();
|
||||||
data.filter.loadLegacyDirectives();
|
data.filter.loadLegacyDirectives();
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../breadcrumbs';
|
||||||
import { buildVislibDimensions } from 'ui/visualize/loader/pipeline_helpers/build_pipeline';
|
import { buildVislibDimensions } from 'ui/visualize/loader/pipeline_helpers/build_pipeline';
|
||||||
import 'ui/capabilities/route_setup';
|
import 'ui/capabilities/route_setup';
|
||||||
|
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
data.search.loadLegacyDirectives();
|
data.search.loadLegacyDirectives();
|
||||||
|
|
||||||
const fetchStatuses = {
|
const fetchStatuses = {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import { VisualizeConstants } from './visualize_constants';
|
||||||
import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
|
import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
|
||||||
import { getLandingBreadcrumbs, getWizardStep1Breadcrumbs } from './breadcrumbs';
|
import { getLandingBreadcrumbs, getWizardStep1Breadcrumbs } from './breadcrumbs';
|
||||||
|
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
data.search.loadLegacyDirectives();
|
data.search.loadLegacyDirectives();
|
||||||
data.filter.loadLegacyDirectives();
|
data.filter.loadLegacyDirectives();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import uuid from 'uuid';
|
||||||
import { IconSelect } from './icon_select';
|
import { IconSelect } from './icon_select';
|
||||||
import { YesNo } from './yes_no';
|
import { YesNo } from './yes_no';
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
import { getDefaultQueryLanguage } from './lib/get_default_query_language';
|
import { getDefaultQueryLanguage } from './lib/get_default_query_language';
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ import {
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
|
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
const localStorage = new Storage(window.localStorage);
|
const localStorage = new Storage(window.localStorage);
|
||||||
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
||||||
|
|
|
@ -45,7 +45,7 @@ import {
|
||||||
const lessC = less(window, { env: 'production' });
|
const lessC = less(window, { env: 'production' });
|
||||||
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
|
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
const localStorage = new Storage(window.localStorage);
|
const localStorage = new Storage(window.localStorage);
|
||||||
|
|
|
@ -40,7 +40,7 @@ import {
|
||||||
import { FormattedMessage } from '@kbn/i18n/react';
|
import { FormattedMessage } from '@kbn/i18n/react';
|
||||||
|
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
const localStorage = new Storage(window.localStorage);
|
const localStorage = new Storage(window.localStorage);
|
||||||
|
|
|
@ -44,7 +44,7 @@ import {
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import { FormattedMessage } from '@kbn/i18n/react';
|
import { FormattedMessage } from '@kbn/i18n/react';
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
const localStorage = new Storage(window.localStorage);
|
const localStorage = new Storage(window.localStorage);
|
||||||
|
|
|
@ -43,7 +43,7 @@ import {
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
|
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
const localStorage = new Storage(window.localStorage);
|
const localStorage = new Storage(window.localStorage);
|
||||||
|
|
|
@ -43,7 +43,7 @@ import {
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import { FormattedMessage } from '@kbn/i18n/react';
|
import { FormattedMessage } from '@kbn/i18n/react';
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
const localStorage = new Storage(window.localStorage);
|
const localStorage = new Storage(window.localStorage);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {
|
||||||
EuiSpacer,
|
EuiSpacer,
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import { FormattedMessage } from '@kbn/i18n/react';
|
import { FormattedMessage } from '@kbn/i18n/react';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { getDefaultQueryLanguage } from './lib/get_default_query_language';
|
import { getDefaultQueryLanguage } from './lib/get_default_query_language';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { createSelectHandler } from '../lib/create_select_handler';
|
||||||
import { GroupBySelect } from './group_by_select';
|
import { GroupBySelect } from './group_by_select';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { htmlIdGenerator, EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui';
|
import { htmlIdGenerator, EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui';
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { collectionActions } from '../lib/collection_actions';
|
||||||
import { AddDeleteButtons } from '../add_delete_buttons';
|
import { AddDeleteButtons } from '../add_delete_buttons';
|
||||||
import { ColorPicker } from '../color_picker';
|
import { ColorPicker } from '../color_picker';
|
||||||
import uuid from 'uuid';
|
import uuid from 'uuid';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { EuiFieldText, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
|
import { EuiFieldText, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
|
||||||
|
|
|
@ -40,7 +40,7 @@ import {
|
||||||
EuiTitle,
|
EuiTitle,
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
|
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import { getDefaultQueryLanguage } from '../../lib/get_default_query_language';
|
import { getDefaultQueryLanguage } from '../../lib/get_default_query_language';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { createSelectHandler } from '../../lib/create_select_handler';
|
||||||
import { YesNo } from '../../yes_no';
|
import { YesNo } from '../../yes_no';
|
||||||
import { createTextHandler } from '../../lib/create_text_handler';
|
import { createTextHandler } from '../../lib/create_text_handler';
|
||||||
import { IndexPattern } from '../../index_pattern';
|
import { IndexPattern } from '../../index_pattern';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import { i18n } from '@kbn/i18n';
|
||||||
|
|
||||||
import chrome from 'ui/chrome';
|
import chrome from 'ui/chrome';
|
||||||
import { buildEsQuery } from '@kbn/es-query';
|
import { buildEsQuery } from '@kbn/es-query';
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
|
|
||||||
const { getQueryLog } = data.query.helpers;
|
const { getQueryLog } = data.query.helpers;
|
||||||
const config = chrome.getUiSettingsClient();
|
const config = chrome.getUiSettingsClient();
|
||||||
|
|
|
@ -28,7 +28,9 @@ import {
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { AggConfig } from 'ui/vis';
|
import { AggConfig } from 'ui/vis';
|
||||||
import { Query, data } from 'plugins/data';
|
// @ts-ignore
|
||||||
|
import { data } from 'plugins/data/setup';
|
||||||
|
import { Query } from 'plugins/data';
|
||||||
|
|
||||||
const { QueryBarInput } = data.query.ui;
|
const { QueryBarInput } = data.query.ui;
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ function FilterRow({
|
||||||
query={value}
|
query={value}
|
||||||
indexPatterns={[agg.getIndexPattern()]}
|
indexPatterns={[agg.getIndexPattern()]}
|
||||||
appName="filtersAgg"
|
appName="filtersAgg"
|
||||||
onChange={query => onChangeValue(id, query, customLabel)}
|
onChange={(query: Query) => onChangeValue(id, query, customLabel)}
|
||||||
disableAutoFocus={!autoFocus}
|
disableAutoFocus={!autoFocus}
|
||||||
data-test-subj={dataTestSubj}
|
data-test-subj={dataTestSubj}
|
||||||
bubbleSubmitEvent={true}
|
bubbleSubmitEvent={true}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { i18n } from '@kbn/i18n';
|
||||||
import { indexPatternService } from '../../../kibana_services';
|
import { indexPatternService } from '../../../kibana_services';
|
||||||
import { Storage } from 'ui/storage';
|
import { Storage } from 'ui/storage';
|
||||||
|
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
const { QueryBar } = data.query.ui;
|
const { QueryBar } = data.query.ui;
|
||||||
|
|
||||||
const settings = chrome.getUiSettingsClient();
|
const settings = chrome.getUiSettingsClient();
|
||||||
|
|
|
@ -33,7 +33,7 @@ import mapTemplate from './angular/map.html';
|
||||||
import { MapListing } from './shared/components/map_listing';
|
import { MapListing } from './shared/components/map_listing';
|
||||||
import { recentlyAccessed } from 'ui/persisted_log';
|
import { recentlyAccessed } from 'ui/persisted_log';
|
||||||
|
|
||||||
import { data } from 'plugins/data';
|
import { data } from 'plugins/data/setup';
|
||||||
data.query.loadLegacyDirectives();
|
data.query.loadLegacyDirectives();
|
||||||
|
|
||||||
const app = uiModules.get('app/maps', ['ngRoute', 'react']);
|
const app = uiModules.get('app/maps', ['ngRoute', 'react']);
|
||||||
|
|
Loading…
Reference in a new issue