From 957ab4a1e9bdef2b43dfd9819f3f507fec78f81c Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Tue, 3 Mar 2020 15:40:02 +0100 Subject: [PATCH 1/4] saved search leftovers from visualizations --- .../kibana/public/discover/build_services.ts | 3 +-- .../np_ready/embeddable/search_embeddable.ts | 2 +- .../discover/np_ready/embeddable/types.ts | 2 +- .../public/components/sidebar/sidebar.tsx | 2 +- .../components/sidebar/sidebar_title.tsx | 2 +- .../visualizations/public/legacy_imports.ts | 1 - .../visualizations/public/legacy_mocks.ts | 21 ------------------- .../public/legacy/build_pipeline.test.ts | 3 ++- .../public/np_ready/public/types.ts | 2 +- src/plugins/discover/public/index.ts | 1 + .../discover/public/saved_searches/types.ts} | 4 ++-- .../public/app/lib/kibana/kibana_context.tsx | 2 +- .../legacy/plugins/transform/public/shim.ts | 2 +- 13 files changed, 13 insertions(+), 34 deletions(-) delete mode 100644 src/legacy/core_plugins/visualizations/public/legacy_mocks.ts rename src/{legacy/core_plugins/kibana/public/discover/np_ready/types.d.ts => plugins/discover/public/saved_searches/types.ts} (89%) diff --git a/src/legacy/core_plugins/kibana/public/discover/build_services.ts b/src/legacy/core_plugins/kibana/public/discover/build_services.ts index 6b0d2368cc1a2..c58307adaf38c 100644 --- a/src/legacy/core_plugins/kibana/public/discover/build_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/build_services.ts @@ -33,11 +33,10 @@ import { import { DiscoverStartPlugins } from './plugin'; import { SharePluginStart } from '../../../../../plugins/share/public'; -import { SavedSearch } from './np_ready/types'; import { DocViewsRegistry } from './np_ready/doc_views/doc_views_registry'; import { ChartsPluginStart } from '../../../../../plugins/charts/public'; import { VisualizationsStart } from '../../../visualizations/public'; -import { createSavedSearchesLoader } from '../../../../../plugins/discover/public'; +import { createSavedSearchesLoader, SavedSearch } from '../../../../../plugins/discover/public'; export interface DiscoverServices { addBasePath: (path: string) => string; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/search_embeddable.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/search_embeddable.ts index 738a74d93449d..0aaf3e7f156c1 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/search_embeddable.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/search_embeddable.ts @@ -37,7 +37,6 @@ import { Embeddable, } from '../../../../../embeddable_api/public/np_ready/public'; import * as columnActions from '../angular/doc_table/actions/columns'; -import { SavedSearch } from '../types'; import searchTemplate from './search_template.html'; import { ISearchEmbeddable, SearchInput, SearchOutput } from './types'; import { SortOrder } from '../angular/doc_table/components/table_header/helpers'; @@ -51,6 +50,7 @@ import { ISearchSource, } from '../../kibana_services'; import { SEARCH_EMBEDDABLE_TYPE } from './constants'; +import { SavedSearch } from '../../../../../../../plugins/discover/public'; interface SearchScope extends ng.IScope { columns?: string[]; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/types.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/types.ts index e7aa390cda858..b20e9b2faf7c4 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/types.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/types.ts @@ -18,9 +18,9 @@ */ import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from 'src/plugins/embeddable/public'; -import { SavedSearch } from '../types'; import { SortOrder } from '../angular/doc_table/components/table_header/helpers'; import { Filter, IIndexPattern, TimeRange, Query } from '../../../../../../../plugins/data/public'; +import { SavedSearch } from '../../../../../../../plugins/discover/public'; export interface SearchInput extends EmbeddableInput { timeRange: TimeRange; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx index 425245fe91fed..a70ffd3cd88e1 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar.tsx @@ -29,8 +29,8 @@ import { DefaultEditorControls } from './controls'; import { setStateParamValue, useEditorReducer, useEditorFormState, discardChanges } from './state'; import { DefaultEditorAggCommonProps } from '../agg_common_props'; import { SidebarTitle } from './sidebar_title'; -import { SavedSearch } from '../../../../kibana/public/discover/np_ready/types'; import { PersistedState } from '../../../../../../plugins/visualizations/public'; +import { SavedSearch } from '../../../../../../plugins/discover/public'; interface DefaultEditorSideBarProps { isCollapsed: boolean; diff --git a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar_title.tsx b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar_title.tsx index 3fd82f1c4a2b6..876404851aed4 100644 --- a/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar_title.tsx +++ b/src/legacy/core_plugins/vis_default_editor/public/components/sidebar/sidebar_title.tsx @@ -35,7 +35,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { Vis } from 'src/legacy/core_plugins/visualizations/public'; -import { SavedSearch } from '../../../../kibana/public/discover/np_ready/types'; +import { SavedSearch } from '../../../../../../plugins/discover/public'; interface LinkedSearchProps { savedSearch: SavedSearch; diff --git a/src/legacy/core_plugins/visualizations/public/legacy_imports.ts b/src/legacy/core_plugins/visualizations/public/legacy_imports.ts index 0a3b1938436c0..1dca8ccb3925e 100644 --- a/src/legacy/core_plugins/visualizations/public/legacy_imports.ts +++ b/src/legacy/core_plugins/visualizations/public/legacy_imports.ts @@ -24,4 +24,3 @@ export { setBounds, } from '../../data/public'; export { createAggConfigs } from 'ui/agg_types'; -export { createSavedSearchesLoader } from '../../../../plugins/discover/public'; diff --git a/src/legacy/core_plugins/visualizations/public/legacy_mocks.ts b/src/legacy/core_plugins/visualizations/public/legacy_mocks.ts deleted file mode 100644 index 6cd57bb88bc26..0000000000000 --- a/src/legacy/core_plugins/visualizations/public/legacy_mocks.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export { searchSourceMock } from '../../../../plugins/data/public/search/search_source/mocks'; diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts index 1adf6fd23f5a5..05b60c4954789 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts @@ -28,7 +28,8 @@ import { } from './build_pipeline'; import { Vis } from '..'; import { IAggConfig } from '../../../legacy_imports'; -import { searchSourceMock } from '../../../legacy_mocks'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { searchSourceMock } from '../../../../../../../plugins/data/public/search/search_source/mocks'; jest.mock('ui/new_platform'); diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/types.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/types.ts index d2ca4ffb92eb2..d8e3ccdeb065e 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/types.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/types.ts @@ -20,7 +20,7 @@ import { SavedObject } from '../../../../../../plugins/saved_objects/public'; import { Vis, VisState, VisParams, VisualizationController } from './vis'; import { ISearchSource } from '../../../../../../plugins/data/public/'; -import { SavedSearch } from '../../../../kibana/public/discover/np_ready/types'; +import { SavedSearch } from '../../../../../../plugins/discover/public'; export { Vis, VisState, VisParams, VisualizationController }; diff --git a/src/plugins/discover/public/index.ts b/src/plugins/discover/public/index.ts index 2ccfe39748024..c5050147c3d5a 100644 --- a/src/plugins/discover/public/index.ts +++ b/src/plugins/discover/public/index.ts @@ -18,3 +18,4 @@ */ export { createSavedSearchesLoader } from './saved_searches/saved_searches'; +export { SavedSearchLoader, SavedSearch } from './saved_searches/types'; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/types.d.ts b/src/plugins/discover/public/saved_searches/types.ts similarity index 89% rename from src/legacy/core_plugins/kibana/public/discover/np_ready/types.d.ts rename to src/plugins/discover/public/saved_searches/types.ts index d36a6b02e1f7a..d601d087afcee 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/types.d.ts +++ b/src/plugins/discover/public/saved_searches/types.ts @@ -17,9 +17,9 @@ * under the License. */ -import { ISearchSource } from '../kibana_services'; -import { SortOrder } from './angular/doc_table/components/table_header/helpers'; +import { ISearchSource } from '../../../data/public'; +export type SortOrder = [string, string]; export interface SavedSearch { readonly id: string; title: string; diff --git a/x-pack/legacy/plugins/transform/public/app/lib/kibana/kibana_context.tsx b/x-pack/legacy/plugins/transform/public/app/lib/kibana/kibana_context.tsx index 3acec1ea0e809..7677c491a7a59 100644 --- a/x-pack/legacy/plugins/transform/public/app/lib/kibana/kibana_context.tsx +++ b/x-pack/legacy/plugins/transform/public/app/lib/kibana/kibana_context.tsx @@ -8,11 +8,11 @@ import React, { createContext, useContext, FC } from 'react'; import { IUiSettingsClient } from 'kibana/public'; -import { SavedSearch } from '../../../../../../../../src/legacy/core_plugins/kibana/public/discover/np_ready/types'; import { IndexPattern, IndexPatternsContract, } from '../../../../../../../../src/plugins/data/public'; +import { SavedSearch } from '../../../../../../../../src/plugins/discover/public/'; interface UninitializedKibanaContextValue { initialized: false; diff --git a/x-pack/legacy/plugins/transform/public/shim.ts b/x-pack/legacy/plugins/transform/public/shim.ts index 95f54605377a8..05f7626e25e9d 100644 --- a/x-pack/legacy/plugins/transform/public/shim.ts +++ b/x-pack/legacy/plugins/transform/public/shim.ts @@ -11,9 +11,9 @@ import { docTitle } from 'ui/doc_title/doc_title'; // @ts-ignore: allow traversal to fail on x-pack build import { createUiStatsReporter } from '../../../../../src/legacy/core_plugins/ui_metric/public'; -import { SavedSearchLoader } from '../../../../../src/legacy/core_plugins/kibana/public/discover/np_ready/types'; import { TRANSFORM_DOC_PATHS } from './app/constants'; +import { SavedSearchLoader } from '../../../../../src/plugins/discover/public'; export type NpCore = typeof npStart.core; export type NpPlugins = typeof npStart.plugins; From f8c77235ee41d286d1f7d354ef184464f2491d65 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Tue, 3 Mar 2020 17:20:01 +0100 Subject: [PATCH 2/4] wip --- .../core_plugins/visualizations/index.ts | 2 +- .../visualizations/public/legacy_imports.ts | 26 ------------------- .../public/np_ready/kibana.json | 2 +- .../public/np_ready/public/legacy.ts | 8 +++++- .../public/legacy/build_pipeline.test.ts | 2 +- .../np_ready/public/legacy/build_pipeline.ts | 2 +- .../public/np_ready/public/mocks.ts | 5 ++++ .../public/np_ready/public/plugin.ts | 8 +++++- .../public/np_ready/public/services.ts | 5 ++++ .../public/np_ready/public/vis.ts | 2 +- .../public/np_ready/public/vis_impl.js | 7 +++-- 11 files changed, 32 insertions(+), 37 deletions(-) delete mode 100644 src/legacy/core_plugins/visualizations/public/legacy_imports.ts diff --git a/src/legacy/core_plugins/visualizations/index.ts b/src/legacy/core_plugins/visualizations/index.ts index 3c22f22f63682..a2779cfe4346d 100644 --- a/src/legacy/core_plugins/visualizations/index.ts +++ b/src/legacy/core_plugins/visualizations/index.ts @@ -24,7 +24,7 @@ export const visualizations: LegacyPluginInitializer = kibana => new kibana.Plugin({ id: 'visualizations', publicDir: resolve(__dirname, 'public'), - require: ['vis_default_editor'], + require: [], uiExports: { styleSheetPaths: resolve(__dirname, 'public/index.scss'), }, diff --git a/src/legacy/core_plugins/visualizations/public/legacy_imports.ts b/src/legacy/core_plugins/visualizations/public/legacy_imports.ts deleted file mode 100644 index 1dca8ccb3925e..0000000000000 --- a/src/legacy/core_plugins/visualizations/public/legacy_imports.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -export { - IAggConfig, - IAggConfigs, - isDateHistogramBucketAggConfig, - setBounds, -} from '../../data/public'; -export { createAggConfigs } from 'ui/agg_types'; diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/kibana.json b/src/legacy/core_plugins/visualizations/public/np_ready/kibana.json index d4f9bd327d6ac..f8637a71b2d35 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/kibana.json +++ b/src/legacy/core_plugins/visualizations/public/np_ready/kibana.json @@ -3,5 +3,5 @@ "version": "kibana", "server": false, "ui": true, - "requiredPlugins": ["data", "search", "expressions", "uiActions"] + "requiredPlugins": ["data", "expressions", "uiActions", "embeddable", "usageCollection"] } diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy.ts index 57c686b6e9cb0..fdbd1d5a61ce7 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy.ts @@ -19,6 +19,7 @@ /* eslint-disable @kbn/eslint/no-restricted-paths */ import { npSetup, npStart } from 'ui/new_platform'; +import { start as legacyDataStart } from '../../../../data/public/legacy'; /* eslint-enable @kbn/eslint/no-restricted-paths */ import { PluginInitializerContext } from '../../../../../../core/public'; @@ -28,4 +29,9 @@ import { plugin } from '.'; const pluginInstance = plugin({} as PluginInitializerContext); export const setup = pluginInstance.setup(npSetup.core, npSetup.plugins); -export const start = pluginInstance.start(npStart.core, npStart.plugins); +export const start = pluginInstance.start(npStart.core, { + ...npStart.plugins, + __LEGACY: { + aggs: legacyDataStart.search.aggs, + }, +}); diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts index 05b60c4954789..09037d445baf5 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.test.ts @@ -27,9 +27,9 @@ import { Schemas, } from './build_pipeline'; import { Vis } from '..'; -import { IAggConfig } from '../../../legacy_imports'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { searchSourceMock } from '../../../../../../../plugins/data/public/search/search_source/mocks'; +import { IAggConfig } from '../../../../../data/public'; jest.mock('ui/new_platform'); diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts index 155213b4103b0..265ac8f8a84f7 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy/build_pipeline.ts @@ -21,8 +21,8 @@ import { cloneDeep, get } from 'lodash'; import moment from 'moment'; import { SerializedFieldFormat } from '../../../../../../../plugins/expressions/public'; import { fieldFormats, ISearchSource } from '../../../../../../../plugins/data/public'; -import { IAggConfig, setBounds, isDateHistogramBucketAggConfig } from '../../../legacy_imports'; import { Vis, VisParams } from '../types'; +import { IAggConfig, isDateHistogramBucketAggConfig, setBounds } from '../../../../../data/public'; interface SchemaConfigParams { precision?: number; diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts index b3dd22f62f81f..0b52ea20b89d9 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts @@ -67,6 +67,11 @@ const createInstance = async () => { data: dataPluginMock.createStartContract(), expressions: expressionsPluginMock.createStartContract(), uiActions: uiActionsPluginMock.createStartContract(), + __LEGACY: { + aggs: { + createAggConfigs: jest.fn(), + } as any, + }, }); return { diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/plugin.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/plugin.ts index e1d87d414d398..10797a1a04df4 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/plugin.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/plugin.ts @@ -38,6 +38,7 @@ import { setUiActions, setSavedVisualizationsLoader, setTimeFilter, + setAggs, } from './services'; import { VISUALIZE_EMBEDDABLE_TYPE, VisualizeEmbeddableFactory } from './embeddable'; import { ExpressionsSetup, ExpressionsStart } from '../../../../../../plugins/expressions/public'; @@ -53,6 +54,7 @@ import { createSavedVisLoader, SavedVisualizationsLoader } from './saved_visuali import { VisImpl, VisImplConstructor } from './vis_impl'; import { showNewVisModal } from './wizard'; import { UiActionsStart } from '../../../../../../plugins/ui_actions/public'; +import { DataStart as LegacyDataStart } from '../../../../data/public'; /** * Interface for this plugin's returned setup/start contracts. @@ -81,6 +83,9 @@ export interface VisualizationsStartDeps { data: DataPublicPluginStart; expressions: ExpressionsStart; uiActions: UiActionsStart; + __LEGACY: { + aggs: LegacyDataStart['search']['aggs']; + }; } /** @@ -123,7 +128,7 @@ export class VisualizationsPlugin public start( core: CoreStart, - { data, expressions, uiActions }: VisualizationsStartDeps + { data, expressions, uiActions, __LEGACY: { aggs } }: VisualizationsStartDeps ): VisualizationsStart { const types = this.types.start(); setI18n(core.i18n); @@ -136,6 +141,7 @@ export class VisualizationsPlugin setExpressions(expressions); setUiActions(uiActions); setTimeFilter(data.query.timefilter.timefilter); + setAggs(aggs); const savedVisualizationsLoader = createSavedVisLoader({ savedObjectsClient: core.savedObjects.client, indexPatterns: data.indexPatterns, diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/services.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/services.ts index a977a4b452bf7..05fb106bf9940 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/services.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/services.ts @@ -35,6 +35,7 @@ import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection import { ExpressionsStart } from '../../../../../../plugins/expressions/public'; import { UiActionsStart } from '../../../../../../plugins/ui_actions/public'; import { SavedVisualizationsLoader } from './saved_visualizations'; +import { DataStart as LegacyDataStart } from '../../../../data/public'; export const [getUISettings, setUISettings] = createGetterSetter('UISettings'); @@ -71,3 +72,7 @@ export const [getUiActions, setUiActions] = createGetterSetter(' export const [getSavedVisualizationsLoader, setSavedVisualizationsLoader] = createGetterSetter< SavedVisualizationsLoader >('SavedVisualisationsLoader'); + +export const [getAggs, setAggs] = createGetterSetter( + 'AggConfigs' +); diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts index 990f27dca7556..f658f6ef52df8 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts @@ -18,8 +18,8 @@ */ import { VisType } from './vis_types'; -import { IAggConfigs } from '../../legacy_imports'; import { Status } from './legacy/update_status'; +import { IAggConfigs } from '../../../../data/public'; export interface Vis { type: VisType; diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis_impl.js b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis_impl.js index 15a826cc6ddbe..d5e6412b6bdab 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis_impl.js +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis_impl.js @@ -30,9 +30,8 @@ import { EventEmitter } from 'events'; import _ from 'lodash'; import { PersistedState } from '../../../../../../../src/plugins/visualizations/public'; -import { createAggConfigs } from '../../legacy_imports'; import { updateVisualizationConfig } from './legacy/vis_update'; -import { getTypes } from './services'; +import { getTypes, getAggs } from './services'; class VisImpl extends EventEmitter { constructor(indexPattern, visState) { @@ -83,7 +82,7 @@ class VisImpl extends EventEmitter { updateVisualizationConfig(state.params, this.params); if (state.aggs || !this.aggs) { - this.aggs = createAggConfigs( + this.aggs = getAggs().createAggConfigs( this.indexPattern, state.aggs ? state.aggs.aggs || state.aggs : [], this.type.schemas.all @@ -125,7 +124,7 @@ class VisImpl extends EventEmitter { copyCurrentState(includeDisabled = false) { const state = this.getCurrentState(includeDisabled); - state.aggs = createAggConfigs( + state.aggs = getAggs().createAggConfigs( this.indexPattern, state.aggs.aggs || state.aggs, this.type.schemas.all From 3a7cf0bb065649774b28057d950407a599f4216d Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Tue, 3 Mar 2020 17:32:40 +0100 Subject: [PATCH 3/4] wip --- .../public/legacy_imports.ts | 2 -- .../public/metrics_type.ts | 2 +- .../vis_type_vega/public/legacy_imports.ts | 2 -- .../vis_type_vega/public/vega_type.ts | 3 +-- .../visualizations/public/index.ts | 9 ------- .../public/np_ready/public/index.ts | 1 + .../misc/default_feedback_message.test.ts | 26 +++++++++++++++++++ .../public/misc/default_feedback_message.ts} | 2 +- .../translations/translations/ja-JP.json | 2 +- .../translations/translations/zh-CN.json | 2 +- 10 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 src/legacy/core_plugins/visualizations/public/np_ready/public/misc/default_feedback_message.test.ts rename src/legacy/{ui/public/vis/default_feedback_message.js => core_plugins/visualizations/public/np_ready/public/misc/default_feedback_message.ts} (91%) diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_timeseries/public/legacy_imports.ts index a2952b2c83afd..7cf0a12e8567c 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_timeseries/public/legacy_imports.ts @@ -17,7 +17,5 @@ * under the License. */ -// @ts-ignore -export { defaultFeedbackMessage } from 'ui/vis/default_feedback_message'; // @ts-ignore export { timezoneProvider } from 'ui/vis/lib/timezone'; diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/metrics_type.ts b/src/legacy/core_plugins/vis_type_timeseries/public/metrics_type.ts index 01750ee0c448d..135cc1e181432 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/metrics_type.ts +++ b/src/legacy/core_plugins/vis_type_timeseries/public/metrics_type.ts @@ -18,7 +18,6 @@ */ import { i18n } from '@kbn/i18n'; -import { defaultFeedbackMessage } from './legacy_imports'; // @ts-ignore import { metricsRequestHandler } from './request_handler'; @@ -26,6 +25,7 @@ import { metricsRequestHandler } from './request_handler'; import { EditorController } from './editor_controller'; // @ts-ignore import { PANEL_TYPES } from '../../../../plugins/vis_type_timeseries/common/panel_types'; +import { defaultFeedbackMessage } from '../../visualizations/public'; export const metricsVisDefinition = { name: 'metrics', diff --git a/src/legacy/core_plugins/vis_type_vega/public/legacy_imports.ts b/src/legacy/core_plugins/vis_type_vega/public/legacy_imports.ts index 9e1067ed9099a..b868321d6310f 100644 --- a/src/legacy/core_plugins/vis_type_vega/public/legacy_imports.ts +++ b/src/legacy/core_plugins/vis_type_vega/public/legacy_imports.ts @@ -17,8 +17,6 @@ * under the License. */ -// @ts-ignore -export { defaultFeedbackMessage } from 'ui/vis/default_feedback_message'; // @ts-ignore export { KibanaMapLayer } from 'ui/vis/map/kibana_map_layer'; // @ts-ignore diff --git a/src/legacy/core_plugins/vis_type_vega/public/vega_type.ts b/src/legacy/core_plugins/vis_type_vega/public/vega_type.ts index 1d4655b4d525f..a84948f725e0a 100644 --- a/src/legacy/core_plugins/vis_type_vega/public/vega_type.ts +++ b/src/legacy/core_plugins/vis_type_vega/public/vega_type.ts @@ -19,8 +19,7 @@ import { i18n } from '@kbn/i18n'; // @ts-ignore -import { defaultFeedbackMessage } from './legacy_imports'; -import { Status } from '../../visualizations/public'; +import { Status, defaultFeedbackMessage } from '../../visualizations/public'; import { DefaultEditorSize } from '../../vis_default_editor/public'; import { VegaVisualizationDependencies } from './plugin'; import { VegaVisEditor } from './components'; diff --git a/src/legacy/core_plugins/visualizations/public/index.ts b/src/legacy/core_plugins/visualizations/public/index.ts index 4557cf9ab22f1..f5590c745b3f9 100644 --- a/src/legacy/core_plugins/visualizations/public/index.ts +++ b/src/legacy/core_plugins/visualizations/public/index.ts @@ -17,15 +17,6 @@ * under the License. */ -/** - * Static legacy code which hasn't been moved to this plugin yet, but - * should be eventually. - * - * @public - */ -// @ts-ignore Used only by tsvb, vega, input control vis -export { defaultFeedbackMessage } from 'ui/vis/default_feedback_message'; - /** * Static np-ready code, re-exported here so consumers can import from * `src/legacy/core_plugins/visualizations/public` diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/index.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/index.ts index 34ffb698e5f8c..7688a7769cf79 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/index.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/index.ts @@ -59,3 +59,4 @@ export { buildPipeline, buildVislibDimensions, SchemaConfig } from './legacy/bui export { updateOldState } from './legacy/vis_update_state'; export { calculateObjectHash } from './legacy/calculate_object_hash'; export { createSavedVisLoader } from './saved_visualizations/saved_visualizations'; +export { defaultFeedbackMessage } from './misc/default_feedback_message'; diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/misc/default_feedback_message.test.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/misc/default_feedback_message.test.ts new file mode 100644 index 0000000000000..5c1afa4634b71 --- /dev/null +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/misc/default_feedback_message.test.ts @@ -0,0 +1,26 @@ +/* + * 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 { defaultFeedbackMessage } from './default_feedback_message'; + +test('default feedback message with link', () => { + expect(defaultFeedbackMessage).toMatchInlineSnapshot( + `"Have feedback? Please create an issue in GitHub."` + ); +}); diff --git a/src/legacy/ui/public/vis/default_feedback_message.js b/src/legacy/core_plugins/visualizations/public/np_ready/public/misc/default_feedback_message.ts similarity index 91% rename from src/legacy/ui/public/vis/default_feedback_message.js rename to src/legacy/core_plugins/visualizations/public/np_ready/public/misc/default_feedback_message.ts index 8b8491d397aad..2871437614231 100644 --- a/src/legacy/ui/public/vis/default_feedback_message.js +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/misc/default_feedback_message.ts @@ -19,7 +19,7 @@ import { i18n } from '@kbn/i18n'; -export const defaultFeedbackMessage = i18n.translate('common.ui.vis.defaultFeedbackMessage', { +export const defaultFeedbackMessage = i18n.translate('visualizations.defaultFeedbackMessage', { defaultMessage: 'Have feedback? Please create an issue in {link}.', values: { link: diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 75db834a969d0..6290b7ce0d0b3 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -256,7 +256,6 @@ "common.ui.stateManagement.unableToStoreHistoryInSessionErrorMessage": "セッションがいっぱいで安全に削除できるアイテムが見つからないため、Kibana は履歴アイテムを保存できません。\n\nこれは大抵新規タブに移動することで解決されますが、より大きな問題が原因である可能性もあります。このメッセージが定期的に表示される場合は、{gitHubIssuesUrl} で問題を報告してください。", "common.ui.url.replacementFailedErrorMessage": "置換に失敗、未解決の表現式: {expr}", "common.ui.url.savedObjectIsMissingNotificationMessage": "保存されたオブジェクトがありません", - "common.ui.vis.defaultFeedbackMessage": "フィードバックがありますか?{link} で問題を報告してください。", "common.ui.vis.kibanaMap.leaflet.fitDataBoundsAriaLabel": "データバウンドを合わせる", "common.ui.vis.kibanaMap.zoomWarning": "ズームレベルが最大に達しました。完全にズームインするには、Elasticsearch と Kibana の {defaultDistribution} にアップグレードしてください。{ems} でより多くのズームレベルが利用できます。または、独自のマップサーバーを構成できます。詳細は { wms } または { configSettings} をご覧ください。", "data.search.aggs.aggGroups.bucketsText": "バケット", @@ -2852,6 +2851,7 @@ "timelion.vis.intervalLabel": "間隔", "uiActions.actionPanel.title": "オプション", "uiActions.errors.incompatibleAction": "操作に互換性がありません", + "visualizations.defaultFeedbackMessage": "フィードバックがありますか?{link} で問題を報告してください。", "visualizations.newVisWizard.betaDescription": "このビジュアライゼーションはベータ段階で、変更される可能性があります。デザインとコードはオフィシャル GA 機能よりも完成度が低く、現状のまま保証なしで提供されています。ベータ機能にはオフィシャル GA 機能の SLA が適用されません", "visualizations.newVisWizard.betaTitle": "ベータ", "visualizations.newVisWizard.chooseSourceTitle": "ソースの選択", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index d67d2054a2da6..4d964101cf199 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -256,7 +256,6 @@ "common.ui.stateManagement.unableToStoreHistoryInSessionErrorMessage": "Kibana 无法将历史记录项存储在您的会话中,因为其已满,并且似乎没有任何可安全删除的项。\n\n通常可通过移至新的标签页来解决此问题,但这会导致更大的问题。如果您有规律地看到此消息,请在 {gitHubIssuesUrl} 提交问题。", "common.ui.url.replacementFailedErrorMessage": "替换失败,未解析的表达式:{expr}", "common.ui.url.savedObjectIsMissingNotificationMessage": "已保存对象缺失", - "common.ui.vis.defaultFeedbackMessage": "想反馈?请在“{link}中创建问题。", "common.ui.vis.kibanaMap.leaflet.fitDataBoundsAriaLabel": "适应数据边界", "common.ui.vis.kibanaMap.zoomWarning": "已达到缩放级别最大数目。要一直放大,请升级到 Elasticsearch 和 Kibana 的 {defaultDistribution}。您可以通过 {ems} 免费使用其他缩放级别。或者,您可以配置自己的地图服务器。请前往 { wms } 或 { configSettings} 以获取详细信息。", "data.search.aggs.aggGroups.bucketsText": "存储桶", @@ -2853,6 +2852,7 @@ "timelion.vis.intervalLabel": "时间间隔", "uiActions.actionPanel.title": "选项", "uiActions.errors.incompatibleAction": "操作不兼容", + "visualizations.defaultFeedbackMessage": "想反馈?请在“{link}中创建问题。", "visualizations.newVisWizard.betaDescription": "此可视化为公测版,可能会进行更改。设计和代码相对于正式发行版功能还不够成熟,将按原样提供,且不提供任何保证。公测版功能不受正式发行版功能支持 SLA 的约束", "visualizations.newVisWizard.betaTitle": "公测版", "visualizations.newVisWizard.chooseSourceTitle": "选择源", From 7436e353277af205217e9b34929d107b6f8b1fa5 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Tue, 3 Mar 2020 19:05:36 +0100 Subject: [PATCH 4/4] check ci if delete --- .../visualizations/public/np_ready/public/mocks.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts index 0b52ea20b89d9..8d7407b6191d6 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts @@ -17,12 +17,6 @@ * under the License. */ -jest.mock('ui/vis/vis_filters'); -jest.mock('ui/vis/default_feedback_message'); -jest.mock('ui/vis/vis_factory'); -jest.mock('ui/registry/vis_types'); -jest.mock('./types/vis_type_alias_registry'); - import { PluginInitializerContext } from '../../../../../../core/public'; import { VisualizationsSetup, VisualizationsStart } from './'; import { VisualizationsPlugin } from './plugin';