From 85ee57eff929cd8d22980435ef28545cf07739cb Mon Sep 17 00:00:00 2001 From: Maryia Lapata Date: Wed, 29 Jan 2020 09:08:42 +0300 Subject: [PATCH] [NP Cleanup] Remove ui/public/inspector (#55677) * Use src/plugins/inspector instead of ui/inspector * Remove unused ui/inspector * Use `inspector` plugin directly to register view * Fix path * Use inspector from NP * Revert view registration to a separate file --- .../kibana/public/discover/kibana_services.ts | 3 -- .../discover/np_ready/angular/discover.js | 2 +- .../np_ready/embeddable/search_embeddable.ts | 3 +- src/legacy/ui/public/agg_types/agg_type.ts | 2 +- src/legacy/ui/public/inspector/README.md | 6 --- .../ui/public/inspector/adapters/index.ts | 27 ------------ src/legacy/ui/public/inspector/index.ts | 22 ---------- src/legacy/ui/public/inspector/inspector.tsx | 42 ------------------- src/legacy/ui/public/inspector/types.ts | 33 --------------- .../public/inspector/ui/inspector_panel.tsx | 27 ------------ .../inspector/ui/inspector_view_chooser.tsx | 27 ------------ .../ui/public/inspector/view_registry.ts | 34 --------------- .../embeddable/embeddable.test.tsx | 2 +- .../maps/public/angular/map_controller.js | 5 +-- .../{register_views.js => register_views.ts} | 7 ++-- .../plugins/maps/public/kibana_services.js | 6 +++ x-pack/legacy/plugins/maps/public/plugin.ts | 6 ++- .../reducers/non_serializable_instances.js | 2 +- 18 files changed, 21 insertions(+), 235 deletions(-) delete mode 100644 src/legacy/ui/public/inspector/README.md delete mode 100644 src/legacy/ui/public/inspector/adapters/index.ts delete mode 100644 src/legacy/ui/public/inspector/index.ts delete mode 100644 src/legacy/ui/public/inspector/inspector.tsx delete mode 100644 src/legacy/ui/public/inspector/types.ts delete mode 100644 src/legacy/ui/public/inspector/ui/inspector_panel.tsx delete mode 100644 src/legacy/ui/public/inspector/ui/inspector_view_chooser.tsx delete mode 100644 src/legacy/ui/public/inspector/view_registry.ts rename x-pack/legacy/plugins/maps/public/inspector/views/{register_views.js => register_views.ts} (72%) diff --git a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts index 27aa920c98aad..58406c74e9f38 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -62,8 +62,6 @@ export { getRequestInspectorStats, getResponseInspectorStats } from '../../../da export { intervalOptions } from 'ui/agg_types/buckets/_interval_options'; // @ts-ignore export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; -// @ts-ignore -export { RequestAdapter } from 'ui/inspector/adapters'; export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory'; @@ -92,7 +90,6 @@ export { SortDirection, } from '../../../../../plugins/data/public'; export { ElasticSearchHit } from './np_ready/doc_views/doc_views_types'; -export { Adapters } from 'ui/inspector/types'; export { registerTimefilterWithGlobalStateFactory } from 'ui/timefilter/setup_router'; export { FieldName } from 'ui/directives/field_name/field_name'; export { getFormat } from 'ui/visualize/loader/pipeline_helpers/utilities'; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js index dd782f97b075d..3f3333b7caec2 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js @@ -25,6 +25,7 @@ import dateMath from '@elastic/datemath'; import { i18n } from '@kbn/i18n'; import '../components/field_chooser/field_chooser'; +import { RequestAdapter } from '../../../../../../../plugins/inspector/public'; // doc table import './doc_table'; import { getSort } from './doc_table/lib/get_sort'; @@ -46,7 +47,6 @@ import { hasSearchStategyForIndexPattern, intervalOptions, migrateLegacyQuery, - RequestAdapter, showSaveModal, unhashUrl, stateMonitorFactory, 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 c840f1fbd87ed..f47cf52c756ac 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 @@ -21,6 +21,7 @@ import * as Rx from 'rxjs'; import { Subscription } from 'rxjs'; import { i18n } from '@kbn/i18n'; import { TExecuteTriggerActions } from 'src/plugins/ui_actions/public'; +import { RequestAdapter, Adapters } from '../../../../../../../plugins/inspector/public'; import { esFilters, TimeRange, @@ -43,13 +44,11 @@ import { ISearchEmbeddable, SearchInput, SearchOutput } from './types'; import { SortOrder } from '../angular/doc_table/components/table_header/helpers'; import { getSortForSearchSource } from '../angular/doc_table/lib/get_sort_for_search_source'; import { - Adapters, angular, getRequestInspectorStats, getResponseInspectorStats, getServices, IndexPattern, - RequestAdapter, ISearchSource, } from '../../kibana_services'; import { SEARCH_EMBEDDABLE_TYPE } from './constants'; diff --git a/src/legacy/ui/public/agg_types/agg_type.ts b/src/legacy/ui/public/agg_types/agg_type.ts index f9b48c373e02f..a590a253d8a6c 100644 --- a/src/legacy/ui/public/agg_types/agg_type.ts +++ b/src/legacy/ui/public/agg_types/agg_type.ts @@ -24,7 +24,7 @@ import { initParams } from './agg_params'; import { AggConfig } from '../vis'; import { AggConfigs } from './agg_configs'; -import { Adapters } from '../inspector'; +import { Adapters } from '../../../../plugins/inspector/public'; import { BaseParamType } from './param_types/base'; import { AggParamType } from '../agg_types/param_types/agg'; import { KBN_FIELD_TYPES, fieldFormats, ISearchSource } from '../../../../plugins/data/public'; diff --git a/src/legacy/ui/public/inspector/README.md b/src/legacy/ui/public/inspector/README.md deleted file mode 100644 index c8133d0d9238d..0000000000000 --- a/src/legacy/ui/public/inspector/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Inspector - -- Inspector has been moved to `inspector` New Platform plugin. -- You can find its documentation in `src/plugins/inspector/README.md`. -- This folder will be deleted soon, it is deprecated, do not use anything from here. -- This folder is ready to be deleted, as soon as nothing imports from here anymore. diff --git a/src/legacy/ui/public/inspector/adapters/index.ts b/src/legacy/ui/public/inspector/adapters/index.ts deleted file mode 100644 index 55df5a33a178b..0000000000000 --- a/src/legacy/ui/public/inspector/adapters/index.ts +++ /dev/null @@ -1,27 +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 */ - -/** - * Do not use this, use NP `inspector` plugin instead. - * - * @deprecated - */ -export * from '../../../../../plugins/inspector/public/adapters/index'; diff --git a/src/legacy/ui/public/inspector/index.ts b/src/legacy/ui/public/inspector/index.ts deleted file mode 100644 index db82508f36ada..0000000000000 --- a/src/legacy/ui/public/inspector/index.ts +++ /dev/null @@ -1,22 +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 { Inspector } from './inspector'; -export { viewRegistry } from './view_registry'; -export { Adapters } from './types'; diff --git a/src/legacy/ui/public/inspector/inspector.tsx b/src/legacy/ui/public/inspector/inspector.tsx deleted file mode 100644 index d65245c11cfe1..0000000000000 --- a/src/legacy/ui/public/inspector/inspector.tsx +++ /dev/null @@ -1,42 +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. - */ - -import { npStart } from '../new_platform'; -export { InspectorSession } from '../../../../plugins/inspector/public'; - -/** - * @deprecated - * - * Do not use this, use New Platform `inspector` plugin instead. - */ -export const Inspector = { - /** - * @deprecated - * - * Do not use this, use New Platform `inspector` plugin instead. - */ - isAvailable: npStart.plugins.inspector.isAvailable, - - /** - * @deprecated - * - * Do not use this, use New Platform `inspector` plugin instead. - */ - open: npStart.plugins.inspector.open, -}; diff --git a/src/legacy/ui/public/inspector/types.ts b/src/legacy/ui/public/inspector/types.ts deleted file mode 100644 index 98f2cf487eb43..0000000000000 --- a/src/legacy/ui/public/inspector/types.ts +++ /dev/null @@ -1,33 +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. - */ - -/** - * Do not import these types from here, instead import them from `inspector` plugin. - * - * ```ts - * import { InspectorViewDescription } from 'src/plugins/inspector/public'; - * ``` - * - * @deprecated - */ -export { - Adapters, - InspectorViewProps, - InspectorViewDescription, -} from '../../../../plugins/inspector/public'; diff --git a/src/legacy/ui/public/inspector/ui/inspector_panel.tsx b/src/legacy/ui/public/inspector/ui/inspector_panel.tsx deleted file mode 100644 index 92ed169bf15e8..0000000000000 --- a/src/legacy/ui/public/inspector/ui/inspector_panel.tsx +++ /dev/null @@ -1,27 +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 */ - -/** - * Do not use this, use NP `inspector` plugin instead. - * - * @deprecated - */ -export * from '../../../../../plugins/inspector/public/ui/inspector_panel'; diff --git a/src/legacy/ui/public/inspector/ui/inspector_view_chooser.tsx b/src/legacy/ui/public/inspector/ui/inspector_view_chooser.tsx deleted file mode 100644 index 017e5c91095f6..0000000000000 --- a/src/legacy/ui/public/inspector/ui/inspector_view_chooser.tsx +++ /dev/null @@ -1,27 +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 */ - -/** - * Do not use this, use NP `inspector` plugin instead. - * - * @deprecated - */ -export * from '../../../../../plugins/inspector/public/ui/inspector_view_chooser'; diff --git a/src/legacy/ui/public/inspector/view_registry.ts b/src/legacy/ui/public/inspector/view_registry.ts deleted file mode 100644 index 5958be66ca184..0000000000000 --- a/src/legacy/ui/public/inspector/view_registry.ts +++ /dev/null @@ -1,34 +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. - */ - -import { npSetup } from 'ui/new_platform'; -export { InspectorViewDescription } from './types'; - -/** - * Do not use this, instead use `inspector` plugin directly. - * - * ```ts - * import { npSetup } from 'ui/new_platform'; - * - * npSetup.plugins.inspector.registerView(view); - * ``` - * - * @deprecated - */ -export const viewRegistry = npSetup.plugins.inspector.__LEGACY.views; diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.test.tsx b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.test.tsx index bc61c6ae34ce5..1f0620c43f7f7 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.test.tsx +++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.test.tsx @@ -9,7 +9,7 @@ import { ExpressionRendererProps } from 'src/plugins/expressions/public'; import { Query, TimeRange, esFilters } from 'src/plugins/data/public'; import { Document } from '../../persistence'; -jest.mock('../../../../../../../src/legacy/ui/public/inspector', () => ({ +jest.mock('../../../../../../../src/plugins/inspector/public/', () => ({ isAvailable: false, open: false, })); diff --git a/x-pack/legacy/plugins/maps/public/angular/map_controller.js b/x-pack/legacy/plugins/maps/public/angular/map_controller.js index ece775f5a7e25..5f058e2ba7806 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -43,9 +43,8 @@ import { getLayerListRaw, } from '../selectors/map_selectors'; import { getInspectorAdapters } from '../reducers/non_serializable_instances'; -import { Inspector } from 'ui/inspector'; import { docTitle } from 'ui/doc_title'; -import { indexPatternService } from '../kibana_services'; +import { indexPatternService, getInspector } from '../kibana_services'; import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; import { toastNotifications } from 'ui/notify'; @@ -510,7 +509,7 @@ app.controller( testId: 'openInspectorButton', run() { const inspectorAdapters = getInspectorAdapters(store.getState()); - Inspector.open(inspectorAdapters, {}); + getInspector().open(inspectorAdapters, {}); }, }, ...(capabilities.get().maps.save diff --git a/x-pack/legacy/plugins/maps/public/inspector/views/register_views.js b/x-pack/legacy/plugins/maps/public/inspector/views/register_views.ts similarity index 72% rename from x-pack/legacy/plugins/maps/public/inspector/views/register_views.js rename to x-pack/legacy/plugins/maps/public/inspector/views/register_views.ts index 6cca73f899cfd..59c0595668300 100644 --- a/x-pack/legacy/plugins/maps/public/inspector/views/register_views.js +++ b/x-pack/legacy/plugins/maps/public/inspector/views/register_views.ts @@ -4,8 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { MapView } from './map_view'; +import { npSetup } from 'ui/new_platform'; -import { viewRegistry } from 'ui/inspector'; +// @ts-ignore +import { MapView } from './map_view'; -viewRegistry.register(MapView); +npSetup.plugins.inspector.registerView(MapView); diff --git a/x-pack/legacy/plugins/maps/public/kibana_services.js b/x-pack/legacy/plugins/maps/public/kibana_services.js index dadae7a3fdca9..60fda398b4f3e 100644 --- a/x-pack/legacy/plugins/maps/public/kibana_services.js +++ b/x-pack/legacy/plugins/maps/public/kibana_services.js @@ -21,6 +21,12 @@ export const getLicenseId = () => { return licenseId; }; +let inspector; +export const setInspector = newInspector => (inspector = newInspector); +export const getInspector = () => { + return inspector; +}; + export async function fetchSearchSourceAndRecordWithInspector({ searchSource, requestId, diff --git a/x-pack/legacy/plugins/maps/public/plugin.ts b/x-pack/legacy/plugins/maps/public/plugin.ts index 0df7109852486..e5f765a11d219 100644 --- a/x-pack/legacy/plugins/maps/public/plugin.ts +++ b/x-pack/legacy/plugins/maps/public/plugin.ts @@ -10,7 +10,7 @@ import { wrapInI18nContext } from 'ui/i18n'; // @ts-ignore import { MapListing } from './components/map_listing'; // @ts-ignore -import { setLicenseId } from './kibana_services'; +import { setLicenseId, setInspector } from './kibana_services'; /** * These are the interfaces with your public contracts. You should export these @@ -39,5 +39,7 @@ export class MapsPlugin implements Plugin { } } - public start(core: CoreStart, plugins: any) {} + public start(core: CoreStart, plugins: any) { + setInspector(plugins.np.inspector); + } } diff --git a/x-pack/legacy/plugins/maps/public/reducers/non_serializable_instances.js b/x-pack/legacy/plugins/maps/public/reducers/non_serializable_instances.js index 689212b8e5ff0..c7de2beff0cf6 100644 --- a/x-pack/legacy/plugins/maps/public/reducers/non_serializable_instances.js +++ b/x-pack/legacy/plugins/maps/public/reducers/non_serializable_instances.js @@ -5,7 +5,7 @@ */ import chrome from 'ui/chrome'; -import { RequestAdapter } from 'ui/inspector/adapters'; +import { RequestAdapter } from '../../../../../../src/plugins/inspector/public'; import { MapAdapter } from '../inspector/adapters/map_adapter'; const REGISTER_CANCEL_CALLBACK = 'REGISTER_CANCEL_CALLBACK';