From 160fe52741e7652431b724f642a244ae9a10e3e6 Mon Sep 17 00:00:00 2001
From: maryia-lapata
Date: Wed, 23 Oct 2019 18:19:07 +0300
Subject: [PATCH 01/12] Centralize dependencies for Visualize plugin
---
.../visualize/embeddable/get_index_pattern.ts | 9 +--
.../visualize_embeddable_factory.tsx | 6 +-
.../public/visualize/help_menu/help_menu.js | 7 +-
.../visualize/help_menu/help_menu_util.js | 2 +-
.../kibana/public/visualize/index.js | 7 +-
.../public/visualize/kibana_services.ts | 71 +++++++++++++++++++
.../visualize/listing/visualize_listing.js | 27 ++++---
.../listing/visualize_listing_table.js | 9 ++-
.../kibana/public/visualize/types.d.ts | 2 +-
.../public/visualize/wizard/new_vis_modal.tsx | 10 +--
.../wizard/type_selection/new_vis_help.tsx | 5 +-
11 files changed, 123 insertions(+), 32 deletions(-)
create mode 100644 src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/get_index_pattern.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/get_index_pattern.ts
index 699fa68b4528b..97db9e1efea8c 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/get_index_pattern.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/get_index_pattern.ts
@@ -17,10 +17,13 @@
* under the License.
*/
-import chrome from 'ui/chrome';
import { StaticIndexPattern, getFromSavedObject } from 'ui/index_patterns';
import { VisSavedObject } from 'ui/visualize/loader/types';
+import { getServices } from '../kibana_services';
+
+const { uiSettings, savedObjectsClient } = getServices();
+
export async function getIndexPattern(
savedVis: VisSavedObject
): Promise {
@@ -28,9 +31,7 @@ export async function getIndexPattern(
return savedVis.vis.indexPattern;
}
- const config = chrome.getUiSettingsClient();
- const savedObjectsClient = chrome.getSavedObjectsClient();
- const defaultIndex = config.get('defaultIndex');
+ const defaultIndex = uiSettings.get('defaultIndex');
if (savedVis.vis.params.index_pattern) {
const indexPatternObjects = await savedObjectsClient.find({
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
index 8448b65e0994e..5c4768cd63dad 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
@@ -61,6 +61,10 @@ import { VisualizeEmbeddable, VisualizeInput, VisualizeOutput } from './visualiz
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import { TypesStart } from '../../../../visualizations/public/np_ready/public/types';
+import { getServices } from '../kibana_services';
+
+const { addBasePath } = getServices();
+
interface VisualizationAttributes extends SavedObjectAttributes {
visState: string;
}
@@ -142,7 +146,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
try {
const visId = savedObjectId;
- const editUrl = chrome.addBasePath(`/app/kibana${savedVisualizations.urlFor(visId)}`);
+ const editUrl = addBasePath(`/app/kibana${savedVisualizations.urlFor(visId)}`);
const loader = await getVisualizeLoader();
const savedObject = await savedVisualizations.get(visId);
const isLabsEnabled = config.get('visualize:enableLabs');
diff --git a/src/legacy/core_plugins/kibana/public/visualize/help_menu/help_menu.js b/src/legacy/core_plugins/kibana/public/visualize/help_menu/help_menu.js
index d95f7ea85c5db..40a1b79ea3520 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/help_menu/help_menu.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/help_menu/help_menu.js
@@ -20,7 +20,10 @@
import React, { Fragment, PureComponent } from 'react';
import { EuiButton, EuiHorizontalRule, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';
+
+import { getServices } from '../kibana_services';
+
+const { docLinks } = getServices();
export class HelpMenu extends PureComponent {
render() {
@@ -31,7 +34,7 @@ export class HelpMenu extends PureComponent {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/help_menu/help_menu_util.js b/src/legacy/core_plugins/kibana/public/visualize/help_menu/help_menu_util.js
index aeabff2d97007..58a92193de63e 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/help_menu/help_menu_util.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/help_menu/help_menu_util.js
@@ -22,7 +22,7 @@ import { render, unmountComponentAtNode } from 'react-dom';
import { HelpMenu } from './help_menu';
export function addHelpMenuToAppChrome(chrome) {
- chrome.helpExtension.set(domElement => {
+ chrome.setHelpExtension(domElement => {
render(, domElement);
return () => {
unmountComponentAtNode(domElement);
diff --git a/src/legacy/core_plugins/kibana/public/visualize/index.js b/src/legacy/core_plugins/kibana/public/visualize/index.js
index b3c16fb94d7fb..e53a3479f0ffa 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/index.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/index.js
@@ -21,17 +21,18 @@ import './editor/editor';
import { i18n } from '@kbn/i18n';
import './saved_visualizations/_saved_vis';
import './saved_visualizations/saved_visualizations';
-import uiRoutes from 'ui/routes';
-import 'ui/capabilities/route_setup';
import visualizeListingTemplate from './listing/visualize_listing.html';
import { VisualizeListingController } from './listing/visualize_listing';
import { VisualizeConstants } from './visualize_constants';
-import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
import { getLandingBreadcrumbs, getWizardStep1Breadcrumbs } from './breadcrumbs';
+import { getServices, FeatureCatalogueCategory } from './kibana_services';
+
// load directives
import '../../../data/public';
+const { uiRoutes, FeatureCatalogueRegistryProvider } = getServices();
+
uiRoutes
.defaults(/visualize/, {
requireDefaultIndex: true,
diff --git a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
new file mode 100644
index 0000000000000..dd0234d6ed490
--- /dev/null
+++ b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
@@ -0,0 +1,71 @@
+/*
+ * 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 'ui/directives/kbn_href';
+
+import { npStart } from 'ui/new_platform';
+import chromeLegacy from 'ui/chrome';
+import angular from 'angular';
+
+import uiRoutes from 'ui/routes';
+import { wrapInI18nContext } from 'ui/i18n';
+
+// @ts-ignore
+import { uiModules } from 'ui/modules';
+import { FeatureCatalogueRegistryProvider } from 'ui/registry/feature_catalogue';
+
+// Filters
+import { timefilter } from 'ui/timefilter';
+
+// Saved objects
+import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
+import { SavedObjectsClientProvider } from 'ui/saved_objects';
+// @ts-ignore
+import { SavedObjectProvider } from 'ui/saved_objects/saved_object';
+
+const services = {
+ // new platform
+ capabilities: npStart.core.application.capabilities,
+ chrome: npStart.core.chrome,
+ docLinks: npStart.core.docLinks,
+ toastNotifications: npStart.core.notifications.toasts,
+ uiSettings: npStart.core.uiSettings,
+ savedObjectsClient: npStart.core.savedObjects.client,
+ addBasePath: npStart.core.http.basePath.prepend,
+
+ // legacy
+ angular,
+ uiRoutes,
+ uiModules,
+ FeatureCatalogueRegistryProvider,
+ SavedObjectRegistryProvider,
+ SavedObjectsClientProvider,
+ SavedObjectProvider,
+ timefilter,
+ wrapInI18nContext,
+};
+export function getServices() {
+ return services;
+}
+
+// export types
+export { VisSavedObject } from 'ui/visualize/loader/types';
+
+// const
+export { FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
index bb05ce34413db..aeee3c91cbfa7 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
@@ -17,21 +17,26 @@
* under the License.
*/
-import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
-import 'ui/directives/kbn_href';
-import { uiModules } from 'ui/modules';
-import { timefilter } from 'ui/timefilter';
-import chrome from 'ui/chrome';
-import { wrapInI18nContext } from 'ui/i18n';
-import { toastNotifications } from 'ui/notify';
import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util';
-import { SavedObjectsClientProvider } from 'ui/saved_objects';
import { VisualizeListingTable } from './visualize_listing_table';
import { NewVisModal } from '../wizard/new_vis_modal';
import { VisualizeConstants } from '../visualize_constants';
import { start as visualizations } from '../../../../visualizations/public/np_ready/public/legacy';
import { i18n } from '@kbn/i18n';
+import { getServices } from '../kibana_services';
+
+const {
+ uiModules,
+ SavedObjectRegistryProvider,
+ timefilter,
+ chrome,
+ toastNotifications,
+ wrapInI18nContext,
+ SavedObjectsClientProvider,
+ addBasePath
+} = getServices();
+
const app = uiModules.get('app/visualize', ['ngRoute', 'react']);
app.directive('visualizeListingTable', reactDirective =>
reactDirective(wrapInI18nContext(VisualizeListingTable))
@@ -55,11 +60,11 @@ export function VisualizeListingController($injector, createNewVis) {
this.editItem = ({ editUrl }) => {
// for visualizations the edit and view URLs are the same
- window.location = chrome.addBasePath(editUrl);
+ window.location = addBasePath(editUrl);
};
this.getViewUrl = ({ editUrl }) => {
- return chrome.addBasePath(editUrl);
+ return addBasePath(editUrl);
};
this.closeNewVisModal = () => {
@@ -112,7 +117,7 @@ export function VisualizeListingController($injector, createNewVis) {
});
};
- chrome.breadcrumbs.set([
+ chrome.setBreadcrumbs([
{
text: i18n.translate('kbn.visualize.visualizeListingBreadcrumbsTitle', {
defaultMessage: 'Visualize',
diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing_table.js b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing_table.js
index c909b6003516f..67fc70899410b 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing_table.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing_table.js
@@ -21,7 +21,6 @@ import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
-import { capabilities } from 'ui/capabilities';
import { TableListView } from './../../table_list_view';
import {
@@ -32,6 +31,10 @@ import {
EuiEmptyPrompt,
} from '@elastic/eui';
+import { getServices } from '../kibana_services';
+
+const { capabilities } = getServices();
+
class VisualizeListingTableUi extends Component {
constructor(props) {
@@ -46,8 +49,8 @@ class VisualizeListingTableUi extends Component {
// for data exploration purposes
createItem={this.props.createItem}
findItems={this.props.findItems}
- deleteItems={capabilities.get().visualize.delete ? this.props.deleteItems : null}
- editItem={capabilities.get().visualize.save ? this.props.editItem : null}
+ deleteItems={capabilities.visualize.delete ? this.props.deleteItems : null}
+ editItem={capabilities.visualize.save ? this.props.editItem : null}
tableColumns={this.getTableColumns()}
listingLimit={this.props.listingLimit}
selectable={item => item.canDelete}
diff --git a/src/legacy/core_plugins/kibana/public/visualize/types.d.ts b/src/legacy/core_plugins/kibana/public/visualize/types.d.ts
index b321e5563eb60..c83f7f5a5da8b 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/types.d.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/types.d.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import { VisSavedObject } from 'ui/visualize/loader/types';
+import { VisSavedObject } from './kibana_services';
export interface SavedVisualizations {
urlFor: (id: string) => string;
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx
index 31ddafb4ec719..7231d7e947408 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx
@@ -22,14 +22,16 @@ import React from 'react';
import { EuiModal, EuiOverlayMask } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import chrome from 'ui/chrome';
-import { VisType } from 'ui/vis';
import { VisualizeConstants } from '../visualize_constants';
import { createUiStatsReporter, METRIC_TYPE } from '../../../../ui_metric/public';
import { SearchSelection } from './search_selection';
import { TypeSelection } from './type_selection';
import { TypesStart, VisTypeAlias } from '../../../../visualizations/public/np_ready/public/types';
+import { getServices, VisType } from '../kibana_services';
+
+const { addBasePath, uiSettings } = getServices();
+
interface TypeSelectionProps {
isOpen: boolean;
onClose: () => void;
@@ -54,7 +56,7 @@ class NewVisModal extends React.Component{t.promotion!.description}
Date: Fri, 25 Oct 2019 10:24:30 +0300
Subject: [PATCH 02/12] Centralizing dependencies in editor and embeddable
---
.../kibana/public/visualize/editor/editor.js | 66 +++++++++++--------
.../visualize/editor/visualization_editor.js | 6 +-
.../visualize/embeddable/get_index_pattern.ts | 12 ++--
.../embeddable/visualize_embeddable.ts | 19 +++---
.../visualize_embeddable_factory.tsx | 11 +---
.../kibana/public/visualize/index.js | 2 +-
.../public/visualize/kibana_services.ts | 53 +++++++++++----
.../visualize/listing/visualize_listing.js | 8 +--
8 files changed, 107 insertions(+), 70 deletions(-)
diff --git a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
index dac0880e6fec4..d140d8b29ad92 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
@@ -26,39 +26,47 @@ import 'ui/vis/editors/default/sidebar';
import 'ui/visualize';
import 'ui/collapsible_sidebar';
-import { capabilities } from 'ui/capabilities';
-import chrome from 'ui/chrome';
import React from 'react';
-import angular from 'angular';
import { FormattedMessage } from '@kbn/i18n/react';
-import { toastNotifications } from 'ui/notify';
-import { docTitle } from 'ui/doc_title';
-import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
-import { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
import { migrateAppState } from './lib';
-import uiRoutes from 'ui/routes';
-import { uiModules } from 'ui/modules';
import editorTemplate from './editor.html';
import { DashboardConstants } from '../../dashboard/dashboard_constants';
import { VisualizeConstants } from '../visualize_constants';
-import { KibanaParsedUrl } from 'ui/url/kibana_parsed_url';
-import { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
-import { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
-import { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
-import { timefilter } from 'ui/timefilter';
-import { getVisualizeLoader } from '../../../../../ui/public/visualize/loader';
-import { showShareContextMenu, ShareContextMenuExtensionsRegistryProvider } from 'ui/share';
-import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing';
-import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
-import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
import { getEditBreadcrumbs, getCreateBreadcrumbs } from '../breadcrumbs';
-import { npStart } from 'ui/new_platform';
import { extractTimeFilter, changeTimeFilter } from '../../../../data/public';
import { start as data } from '../../../../data/public/legacy';
import { start as visualizations } from '../../../../visualizations/public/np_ready/public/legacy';
import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util';
+import {
+ getServices,
+ absoluteToParsedUrl,
+ getUnhashableStatesProvider,
+ getVisualizeLoader,
+ KibanaParsedUrl,
+ migrateLegacyQuery,
+ SavedObjectSaveModal,
+ showShareContextMenu,
+ showSaveModal,
+ stateMonitorFactory,
+ subscribeWithScope,
+} from '../kibana_services';
+
+const {
+ angular,
+ capabilities,
+ chrome,
+ docTitle,
+ FilterBarQueryFilterProvider,
+ getBasePath,
+ ShareContextMenuExtensionsRegistryProvider,
+ toastNotifications,
+ timefilter,
+ uiModules,
+ uiRoutes,
+} = getServices();
+
const { savedQueryService } = data.search.services;
uiRoutes
@@ -100,7 +108,7 @@ uiRoutes
savedVis: function (savedVisualizations, redirectWhenMissing, $route) {
return savedVisualizations.get($route.current.params.id)
.then((savedVis) => {
- npStart.core.chrome.recentlyAccessed.add(
+ chrome.recentlyAccessed.add(
savedVis.getFullPath(),
savedVis.title,
savedVis.id);
@@ -167,7 +175,7 @@ function VisEditor(
dirty: !savedVis.id
};
- $scope.topNavMenu = [...(capabilities.get().visualize.save ? [{
+ $scope.topNavMenu = [...(capabilities.visualize.save ? [{
id: 'save',
label: i18n.translate('kbn.topNavMenu.saveVisualizationButtonLabel', { defaultMessage: 'save' }),
description: i18n.translate('kbn.visualize.topNavMenu.saveVisualizationButtonAriaLabel', {
@@ -236,7 +244,7 @@ function VisEditor(
showShareContextMenu({
anchorElement,
allowEmbed: true,
- allowShortUrl: capabilities.get().visualize.createShortUrl,
+ allowShortUrl: capabilities.visualize.createShortUrl,
getUnhashableStates,
objectId: savedVis.id,
objectType: 'visualization',
@@ -353,9 +361,9 @@ function VisEditor(
}
});
- $scope.showSaveQuery = capabilities.get().visualize.saveQuery;
+ $scope.showSaveQuery = capabilities.visualize.saveQuery;
- $scope.$watch(() => capabilities.get().visualize.saveQuery, (newCapability) => {
+ $scope.$watch(() => capabilities.visualize.saveQuery, (newCapability) => {
$scope.showSaveQuery = newCapability;
});
@@ -582,7 +590,7 @@ function VisEditor(
if ($scope.isAddToDashMode()) {
const savedVisualizationParsedUrl = new KibanaParsedUrl({
- basePath: chrome.getBasePath(),
+ basePath: getBasePath(),
appId: kbnBaseUrl.slice('/app/'.length),
appPath: kbnUrl.eval(`${VisualizeConstants.EDIT_PATH}/{{id}}`, { id: savedVis.id }),
});
@@ -593,13 +601,13 @@ function VisEditor(
// url, not the unsaved one.
chrome.trackSubUrlForApp('kibana:visualize', savedVisualizationParsedUrl);
- const lastDashboardAbsoluteUrl = npStart.core.chrome.navLinks.get('kibana:dashboard').url;
- const dashboardParsedUrl = absoluteToParsedUrl(lastDashboardAbsoluteUrl, chrome.getBasePath());
+ const lastDashboardAbsoluteUrl = chrome.navLinks.get('kibana:dashboard').url;
+ const dashboardParsedUrl = absoluteToParsedUrl(lastDashboardAbsoluteUrl, getBasePath());
dashboardParsedUrl.addQueryParameter(DashboardConstants.NEW_VISUALIZATION_ID_PARAM, savedVis.id);
kbnUrl.change(dashboardParsedUrl.appPath);
} else if (savedVis.id === $route.current.params.id) {
docTitle.change(savedVis.lastSavedTitle);
- chrome.breadcrumbs.set($injector.invoke(getEditBreadcrumbs));
+ chrome.setBreadcrumbs($injector.invoke(getEditBreadcrumbs));
} else {
kbnUrl.change(`${VisualizeConstants.EDIT_PATH}/{{id}}`, { id: savedVis.id });
}
diff --git a/src/legacy/core_plugins/kibana/public/visualize/editor/visualization_editor.js b/src/legacy/core_plugins/kibana/public/visualize/editor/visualization_editor.js
index a2ed44df2f5b0..63dcd395ef918 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/editor/visualization_editor.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/editor/visualization_editor.js
@@ -18,9 +18,11 @@
*/
import { debounce } from 'lodash';
-import { uiModules } from 'ui/modules';
import 'angular-sanitize';
-import { VisEditorTypesRegistryProvider } from 'ui/registry/vis_editor_types';
+
+import { getServices, VisEditorTypesRegistryProvider } from '../kibana_services';
+
+const { uiModules } = getServices();
uiModules
.get('kibana/directive', ['ngSanitize'])
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/get_index_pattern.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/get_index_pattern.ts
index 97db9e1efea8c..b6d5adcd98bd0 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/get_index_pattern.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/get_index_pattern.ts
@@ -17,12 +17,14 @@
* under the License.
*/
-import { StaticIndexPattern, getFromSavedObject } from 'ui/index_patterns';
-import { VisSavedObject } from 'ui/visualize/loader/types';
+import {
+ getServices,
+ getFromSavedObject,
+ StaticIndexPattern,
+ VisSavedObject,
+} from '../kibana_services';
-import { getServices } from '../kibana_services';
-
-const { uiSettings, savedObjectsClient } = getServices();
+const { savedObjectsClient, uiSettings } = getServices();
export async function getIndexPattern(
savedVis: VisSavedObject
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
index b9febc3af54ea..3b5d68de3f8a0 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
@@ -18,15 +18,6 @@
*/
import _ from 'lodash';
-import { StaticIndexPattern } from 'ui/index_patterns';
-import { PersistedState } from 'ui/persisted_state';
-import { VisualizeLoader } from 'ui/visualize/loader';
-import { EmbeddedVisualizeHandler } from 'ui/visualize/loader/embedded_visualize_handler';
-import {
- VisSavedObject,
- VisualizeLoaderParams,
- VisualizeUpdateParams,
-} from 'ui/visualize/loader/types';
import { Subscription } from 'rxjs';
import * as Rx from 'rxjs';
import { Filter } from '@kbn/es-query';
@@ -40,6 +31,16 @@ import {
import { Query, onlyDisabledFiltersChanged } from '../../../../data/public';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
+import {
+ EmbeddedVisualizeHandler,
+ PersistedState,
+ StaticIndexPattern,
+ VisSavedObject,
+ VisualizeLoader,
+ VisualizeLoaderParams,
+ VisualizeUpdateParams,
+} from '../kibana_services';
+
const getKeys = (o: T): Array => Object.keys(o) as Array;
export interface VisualizeEmbeddableConfiguration {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
index 5c4768cd63dad..a8e0fee804a72 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
@@ -37,11 +37,6 @@ import 'uiExports/visualize';
import { i18n } from '@kbn/i18n';
-import { capabilities } from 'ui/capabilities';
-
-import chrome from 'ui/chrome';
-import { getVisualizeLoader } from 'ui/visualize/loader';
-
import { Legacy } from 'kibana';
import { SavedObjectAttributes } from 'kibana/server';
@@ -61,9 +56,9 @@ import { VisualizeEmbeddable, VisualizeInput, VisualizeOutput } from './visualiz
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import { TypesStart } from '../../../../visualizations/public/np_ready/public/types';
-import { getServices } from '../kibana_services';
+import { getServices, getVisualizeLoader } from '../kibana_services';
-const { addBasePath } = getServices();
+const { addBasePath, capabilities, chrome, uiSettings } = getServices();
interface VisualizationAttributes extends SavedObjectAttributes {
visState: string;
@@ -113,7 +108,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
if (!visType) {
return false;
}
- if (chrome.getUiSettingsClient().get('visualize:enableLabs')) {
+ if (uiSettings.get('visualize:enableLabs')) {
return true;
}
return visType.stage !== 'experimental';
diff --git a/src/legacy/core_plugins/kibana/public/visualize/index.js b/src/legacy/core_plugins/kibana/public/visualize/index.js
index e53a3479f0ffa..74dd17a18a9bc 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/index.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/index.js
@@ -31,7 +31,7 @@ import { getServices, FeatureCatalogueCategory } from './kibana_services';
// load directives
import '../../../data/public';
-const { uiRoutes, FeatureCatalogueRegistryProvider } = getServices();
+const { FeatureCatalogueRegistryProvider, uiRoutes } = getServices();
uiRoutes
.defaults(/visualize/, {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
index dd0234d6ed490..2a7591dd7fa48 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
@@ -20,52 +20,81 @@
import 'ui/directives/kbn_href';
import { npStart } from 'ui/new_platform';
-import chromeLegacy from 'ui/chrome';
import angular from 'angular';
import uiRoutes from 'ui/routes';
-import { wrapInI18nContext } from 'ui/i18n';
+// @ts-ignore
+import { docTitle } from 'ui/doc_title';
+import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
+import { wrapInI18nContext } from 'ui/i18n';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { FeatureCatalogueRegistryProvider } from 'ui/registry/feature_catalogue';
-
-// Filters
+import { ShareContextMenuExtensionsRegistryProvider } from 'ui/share';
import { timefilter } from 'ui/timefilter';
// Saved objects
-import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import { SavedObjectsClientProvider } from 'ui/saved_objects';
// @ts-ignore
import { SavedObjectProvider } from 'ui/saved_objects/saved_object';
+import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
const services = {
// new platform
+ addBasePath: npStart.core.http.basePath.prepend,
capabilities: npStart.core.application.capabilities,
chrome: npStart.core.chrome,
docLinks: npStart.core.docLinks,
+ savedObjectsClient: npStart.core.savedObjects.client,
toastNotifications: npStart.core.notifications.toasts,
uiSettings: npStart.core.uiSettings,
- savedObjectsClient: npStart.core.savedObjects.client,
- addBasePath: npStart.core.http.basePath.prepend,
// legacy
angular,
- uiRoutes,
- uiModules,
+ docTitle,
FeatureCatalogueRegistryProvider,
+ FilterBarQueryFilterProvider,
+ SavedObjectProvider,
SavedObjectRegistryProvider,
SavedObjectsClientProvider,
- SavedObjectProvider,
+ ShareContextMenuExtensionsRegistryProvider,
timefilter,
+ uiModules,
+ uiRoutes,
wrapInI18nContext,
};
+
export function getServices() {
return services;
}
+// export legacy static dependencies
+export { getFromSavedObject } from 'ui/index_patterns';
+export { PersistedState } from 'ui/persisted_state';
+// @ts-ignore
+export { VisEditorTypesRegistryProvider } from 'ui/registry/vis_editor_types';
+// @ts-ignore
+export { getUnhashableStatesProvider } from 'ui/state_management/state_hashing';
+export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
+export { showShareContextMenu } from 'ui/share';
+export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
+export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
+export { KibanaParsedUrl } from 'ui/url/kibana_parsed_url';
+export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
+export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
+export { getVisualizeLoader } from 'ui/visualize/loader';
+export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
+
// export types
-export { VisSavedObject } from 'ui/visualize/loader/types';
+export { StaticIndexPattern } from 'ui/index_patterns';
+export { VisualizeLoader } from 'ui/visualize/loader';
+export {
+ VisSavedObject,
+ VisualizeLoaderParams,
+ VisualizeUpdateParams,
+} from 'ui/visualize/loader/types';
+export { EmbeddedVisualizeHandler } from 'ui/visualize/loader/embedded_visualize_handler';
-// const
+// export const
export { FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
index aeee3c91cbfa7..42c4556041197 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
@@ -27,14 +27,14 @@ import { i18n } from '@kbn/i18n';
import { getServices } from '../kibana_services';
const {
- uiModules,
+ addBasePath,
+ chrome,
SavedObjectRegistryProvider,
+ SavedObjectsClientProvider,
timefilter,
- chrome,
toastNotifications,
+ uiModules,
wrapInI18nContext,
- SavedObjectsClientProvider,
- addBasePath
} = getServices();
const app = uiModules.get('app/visualize', ['ngRoute', 'react']);
From 46ba3db2eeb649d41c846f9bba43ddfe45b8d1f4 Mon Sep 17 00:00:00 2001
From: maryia-lapata
Date: Fri, 25 Oct 2019 12:30:04 +0300
Subject: [PATCH 03/12] Remove unused deps, move imports
---
.../kibana/public/visualize/editor/editor.js | 7 ++---
.../visualize/editor/visualization_editor.js | 1 -
.../embeddable/visualize_embeddable.ts | 2 +-
.../visualize_embeddable_factory.tsx | 27 ++-----------------
.../public/visualize/kibana_services.ts | 18 ++++++++++---
.../visualize/listing/visualize_listing.js | 2 +-
.../public/visualize/wizard/new_vis_modal.tsx | 5 ++--
7 files changed, 22 insertions(+), 40 deletions(-)
diff --git a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
index fa59084e345da..5930c96b09273 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
@@ -22,9 +22,6 @@ import { Subscription } from 'rxjs';
import { i18n } from '@kbn/i18n';
import '../saved_visualizations/saved_visualizations';
import './visualization_editor';
-import 'ui/vis/editors/default/sidebar';
-import 'ui/visualize';
-import 'ui/collapsible_sidebar';
import React from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
@@ -35,12 +32,12 @@ import { VisualizeConstants } from '../visualize_constants';
import { getEditBreadcrumbs, getCreateBreadcrumbs } from '../breadcrumbs';
import { extractTimeFilter, changeTimeFilter } from '../../../../data/public';
import { start as data } from '../../../../data/public/legacy';
-import { start as visualizations } from '../../../../visualizations/public/np_ready/public/legacy';
import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util';
import {
getServices,
+ angular,
absoluteToParsedUrl,
getUnhashableStatesProvider,
getVisualizeLoader,
@@ -54,7 +51,6 @@ import {
} from '../kibana_services';
const {
- angular,
capabilities,
chrome,
docTitle,
@@ -65,6 +61,7 @@ const {
timefilter,
uiModules,
uiRoutes,
+ visualizations,
} = getServices();
const { savedQueryService } = data.search.services;
diff --git a/src/legacy/core_plugins/kibana/public/visualize/editor/visualization_editor.js b/src/legacy/core_plugins/kibana/public/visualize/editor/visualization_editor.js
index 63dcd395ef918..9c96d8ca506a8 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/editor/visualization_editor.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/editor/visualization_editor.js
@@ -18,7 +18,6 @@
*/
import { debounce } from 'lodash';
-import 'angular-sanitize';
import { getServices, VisEditorTypesRegistryProvider } from '../kibana_services';
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
index 3b5d68de3f8a0..d95264abdd559 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
@@ -18,6 +18,7 @@
*/
import _ from 'lodash';
+import { EmbeddedVisualizeHandler } from 'ui/visualize/loader/embedded_visualize_handler';
import { Subscription } from 'rxjs';
import * as Rx from 'rxjs';
import { Filter } from '@kbn/es-query';
@@ -32,7 +33,6 @@ import { Query, onlyDisabledFiltersChanged } from '../../../../data/public';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {
- EmbeddedVisualizeHandler,
PersistedState,
StaticIndexPattern,
VisSavedObject,
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
index a8e0fee804a72..a0a1182ea3c55 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
@@ -17,37 +17,17 @@
* under the License.
*/
-import 'ui/registry/field_formats';
-import 'uiExports/contextMenuActions';
-import 'uiExports/devTools';
-import 'uiExports/docViews';
-import 'uiExports/embeddableFactories';
-import 'uiExports/embeddableActions';
-import 'uiExports/fieldFormatEditors';
-import 'uiExports/fieldFormats';
-import 'uiExports/home';
-import 'uiExports/indexManagement';
-import 'uiExports/inspectorViews';
-import 'uiExports/savedObjectTypes';
-import 'uiExports/search';
-import 'uiExports/shareContextMenuExtensions';
-import 'uiExports/visEditorTypes';
-import 'uiExports/visTypes';
-import 'uiExports/visualize';
-
import { i18n } from '@kbn/i18n';
import { Legacy } from 'kibana';
import { SavedObjectAttributes } from 'kibana/server';
-import { npSetup } from 'ui/new_platform';
import {
EmbeddableFactory,
ErrorEmbeddable,
Container,
EmbeddableOutput,
} from '../../../../../../plugins/embeddable/public';
-import { start as visualizations } from '../../../../visualizations/public/np_ready/public/legacy';
import { showNewVisModal } from '../wizard';
import { SavedVisualizations } from '../types';
import { DisabledLabEmbeddable } from './disabled_lab_embeddable';
@@ -58,7 +38,7 @@ import { TypesStart } from '../../../../visualizations/public/np_ready/public/ty
import { getServices, getVisualizeLoader } from '../kibana_services';
-const { addBasePath, capabilities, chrome, uiSettings } = getServices();
+const { addBasePath, capabilities, chrome, embeddable, uiSettings, visualizations } = getServices();
interface VisualizationAttributes extends SavedObjectAttributes {
visState: string;
@@ -182,8 +162,5 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
}
VisualizeEmbeddableFactory.createVisualizeEmbeddableFactory().then(embeddableFactory => {
- npSetup.plugins.embeddable.registerEmbeddableFactory(
- VISUALIZE_EMBEDDABLE_TYPE,
- embeddableFactory
- );
+ embeddable.registerEmbeddableFactory(VISUALIZE_EMBEDDABLE_TYPE, embeddableFactory);
});
diff --git a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
index 2a7591dd7fa48..2b8fcb02dcb5b 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
@@ -17,10 +17,11 @@
* under the License.
*/
-import 'ui/directives/kbn_href';
+import 'angular-sanitize'; // used in visualization_editor.js
+import 'ui/collapsible_sidebar'; // used in default editor
import { npStart } from 'ui/new_platform';
-import angular from 'angular';
+import angular from 'angular'; // just used in editor.js
import uiRoutes from 'ui/routes';
@@ -40,18 +41,23 @@ import { SavedObjectsClientProvider } from 'ui/saved_objects';
import { SavedObjectProvider } from 'ui/saved_objects/saved_object';
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
+import { createUiStatsReporter, METRIC_TYPE } from '../../../ui_metric/public';
+import { start as visualizations } from '../../../visualizations/public/np_ready/public/legacy';
+
const services = {
// new platform
addBasePath: npStart.core.http.basePath.prepend,
capabilities: npStart.core.application.capabilities,
chrome: npStart.core.chrome,
docLinks: npStart.core.docLinks,
+ embeddable: npStart.plugins.embeddable,
savedObjectsClient: npStart.core.savedObjects.client,
toastNotifications: npStart.core.notifications.toasts,
uiSettings: npStart.core.uiSettings,
+ visualizations,
+
// legacy
- angular,
docTitle,
FeatureCatalogueRegistryProvider,
FilterBarQueryFilterProvider,
@@ -63,6 +69,8 @@ const services = {
uiModules,
uiRoutes,
wrapInI18nContext,
+
+ createUiStatsReporter,
};
export function getServices() {
@@ -70,6 +78,7 @@ export function getServices() {
}
// export legacy static dependencies
+export { angular };
export { getFromSavedObject } from 'ui/index_patterns';
export { PersistedState } from 'ui/persisted_state';
// @ts-ignore
@@ -87,14 +96,15 @@ export { getVisualizeLoader } from 'ui/visualize/loader';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
// export types
+export { METRIC_TYPE };
export { StaticIndexPattern } from 'ui/index_patterns';
+export { VisType } from 'ui/vis';
export { VisualizeLoader } from 'ui/visualize/loader';
export {
VisSavedObject,
VisualizeLoaderParams,
VisualizeUpdateParams,
} from 'ui/visualize/loader/types';
-export { EmbeddedVisualizeHandler } from 'ui/visualize/loader/embedded_visualize_handler';
// export const
export { FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
index 42c4556041197..7a0ff15f13511 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
@@ -21,7 +21,6 @@ import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util';
import { VisualizeListingTable } from './visualize_listing_table';
import { NewVisModal } from '../wizard/new_vis_modal';
import { VisualizeConstants } from '../visualize_constants';
-import { start as visualizations } from '../../../../visualizations/public/np_ready/public/legacy';
import { i18n } from '@kbn/i18n';
import { getServices } from '../kibana_services';
@@ -35,6 +34,7 @@ const {
toastNotifications,
uiModules,
wrapInI18nContext,
+ visualizations,
} = getServices();
const app = uiModules.get('app/visualize', ['ngRoute', 'react']);
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx
index 7231d7e947408..2b36c9af705c2 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx
@@ -23,14 +23,13 @@ import { EuiModal, EuiOverlayMask } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { VisualizeConstants } from '../visualize_constants';
-import { createUiStatsReporter, METRIC_TYPE } from '../../../../ui_metric/public';
import { SearchSelection } from './search_selection';
import { TypeSelection } from './type_selection';
import { TypesStart, VisTypeAlias } from '../../../../visualizations/public/np_ready/public/types';
-import { getServices, VisType } from '../kibana_services';
+import { getServices, METRIC_TYPE, VisType } from '../kibana_services';
-const { addBasePath, uiSettings } = getServices();
+const { addBasePath, createUiStatsReporter, uiSettings } = getServices();
interface TypeSelectionProps {
isOpen: boolean;
From 36ec4e1e8929ac73e400801bd8b7ebf2f7e492d5 Mon Sep 17 00:00:00 2001
From: maryia-lapata
Date: Fri, 25 Oct 2019 12:50:03 +0300
Subject: [PATCH 04/12] Fix dangerouslyGetActiveInjector
---
.../embeddable/visualize_embeddable_factory.tsx | 14 +++++++++++---
.../kibana/public/visualize/kibana_services.ts | 5 +++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
index a0a1182ea3c55..c69bd25966451 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
@@ -38,7 +38,15 @@ import { TypesStart } from '../../../../visualizations/public/np_ready/public/ty
import { getServices, getVisualizeLoader } from '../kibana_services';
-const { addBasePath, capabilities, chrome, embeddable, uiSettings, visualizations } = getServices();
+const {
+ addBasePath,
+ capabilities,
+ chrome,
+ embeddable,
+ getInjector,
+ uiSettings,
+ visualizations,
+} = getServices();
interface VisualizationAttributes extends SavedObjectAttributes {
visState: string;
@@ -100,7 +108,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
}
public isEditable() {
- return capabilities.get().visualize.save as boolean;
+ return capabilities.visualize.save as boolean;
}
public getDisplayName() {
@@ -114,7 +122,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
input: Partial & { id: string },
parent?: Container
): Promise {
- const $injector = await chrome.dangerouslyGetActiveInjector();
+ const $injector = await getInjector();
const config = $injector.get('config');
const savedVisualizations = $injector.get('savedVisualizations');
diff --git a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
index 2b8fcb02dcb5b..8ffd1d19e447a 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
@@ -19,9 +19,11 @@
import 'angular-sanitize'; // used in visualization_editor.js
import 'ui/collapsible_sidebar'; // used in default editor
+import 'ui/vis/editors/default/sidebar';
import { npStart } from 'ui/new_platform';
import angular from 'angular'; // just used in editor.js
+import chromeLegacy from 'ui/chrome';
import uiRoutes from 'ui/routes';
@@ -61,6 +63,9 @@ const services = {
docTitle,
FeatureCatalogueRegistryProvider,
FilterBarQueryFilterProvider,
+ getInjector: () => {
+ return chromeLegacy.dangerouslyGetActiveInjector();
+ },
SavedObjectProvider,
SavedObjectRegistryProvider,
SavedObjectsClientProvider,
From abfdc2aa48fc31067d5345ab030101115bc58955 Mon Sep 17 00:00:00 2001
From: maryia-lapata
Date: Fri, 25 Oct 2019 12:58:06 +0300
Subject: [PATCH 05/12] Move loading directive to kibana_services.ts
---
src/legacy/core_plugins/kibana/public/visualize/index.js | 3 ---
.../core_plugins/kibana/public/visualize/kibana_services.ts | 2 ++
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/legacy/core_plugins/kibana/public/visualize/index.js b/src/legacy/core_plugins/kibana/public/visualize/index.js
index 74dd17a18a9bc..592a355a71b0d 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/index.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/index.js
@@ -28,9 +28,6 @@ import { getLandingBreadcrumbs, getWizardStep1Breadcrumbs } from './breadcrumbs'
import { getServices, FeatureCatalogueCategory } from './kibana_services';
-// load directives
-import '../../../data/public';
-
const { FeatureCatalogueRegistryProvider, uiRoutes } = getServices();
uiRoutes
diff --git a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
index 8ffd1d19e447a..69333e0768229 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
@@ -20,6 +20,8 @@
import 'angular-sanitize'; // used in visualization_editor.js
import 'ui/collapsible_sidebar'; // used in default editor
import 'ui/vis/editors/default/sidebar';
+// load directives
+import '../../../data/public';
import { npStart } from 'ui/new_platform';
import angular from 'angular'; // just used in editor.js
From 1dc18c7a84fa0b7a2f1708e72d99c81dc09a0280 Mon Sep 17 00:00:00 2001
From: maryia-lapata
Date: Fri, 25 Oct 2019 14:35:39 +0300
Subject: [PATCH 06/12] Fix exceptions
---
.../visualize/embeddable/visualize_embeddable_factory.tsx | 1 -
.../core_plugins/kibana/public/visualize/kibana_services.ts | 1 +
.../kibana/public/visualize/listing/visualize_listing.js | 2 +-
.../kibana/public/visualize/wizard/new_vis_modal.tsx | 2 +-
4 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
index c69bd25966451..b3ccd55110373 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
@@ -41,7 +41,6 @@ import { getServices, getVisualizeLoader } from '../kibana_services';
const {
addBasePath,
capabilities,
- chrome,
embeddable,
getInjector,
uiSettings,
diff --git a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
index 69333e0768229..a39cbc231bd4f 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
@@ -55,6 +55,7 @@ const services = {
chrome: npStart.core.chrome,
docLinks: npStart.core.docLinks,
embeddable: npStart.plugins.embeddable,
+ getBasePath: npStart.core.http.basePath.get,
savedObjectsClient: npStart.core.savedObjects.client,
toastNotifications: npStart.core.notifications.toasts,
uiSettings: npStart.core.uiSettings,
diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
index 7a0ff15f13511..81f8c0fe5a2b9 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
@@ -60,7 +60,7 @@ export function VisualizeListingController($injector, createNewVis) {
this.editItem = ({ editUrl }) => {
// for visualizations the edit and view URLs are the same
- window.location = addBasePath(editUrl);
+ window.location.href = addBasePath(editUrl);
};
this.getViewUrl = ({ editUrl }) => {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx
index 2b36c9af705c2..420f0e5198056 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.tsx
@@ -124,7 +124,7 @@ class NewVisModal extends React.Component
Date: Fri, 25 Oct 2019 15:05:22 +0300
Subject: [PATCH 07/12] Get rid of injectI18n; fix chrome method invocation
---
.../kibana/public/visualize/editor/editor.js | 3 +-
.../public/visualize/kibana_services.ts | 1 +
.../listing/no_visualizations_prompt.js | 12 +-
.../visualize/listing/visualize_listing.js | 3 +-
.../listing/visualize_listing_table.js | 129 +++++++-----------
5 files changed, 61 insertions(+), 87 deletions(-)
diff --git a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
index 5930c96b09273..b0909d16974b6 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
@@ -53,6 +53,7 @@ import {
const {
capabilities,
chrome,
+ chromeLegacy,
docTitle,
FilterBarQueryFilterProvider,
getBasePath,
@@ -596,7 +597,7 @@ function VisEditor(
// Since we aren't reloading the page, only inserting a new browser history item, we need to manually update
// the last url for this app, so directly clicking on the Visualize tab will also bring the user to the saved
// url, not the unsaved one.
- chrome.trackSubUrlForApp('kibana:visualize', savedVisualizationParsedUrl);
+ chromeLegacy.trackSubUrlForApp('kibana:visualize', savedVisualizationParsedUrl);
const lastDashboardAbsoluteUrl = chrome.navLinks.get('kibana:dashboard').url;
const dashboardParsedUrl = absoluteToParsedUrl(lastDashboardAbsoluteUrl, getBasePath());
diff --git a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
index a39cbc231bd4f..f85b602583335 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
@@ -63,6 +63,7 @@ const services = {
visualizations,
// legacy
+ chromeLegacy,
docTitle,
FeatureCatalogueRegistryProvider,
FilterBarQueryFilterProvider,
diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/no_visualizations_prompt.js b/src/legacy/core_plugins/kibana/public/visualize/listing/no_visualizations_prompt.js
index 54a6048a22daf..34b662838880e 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/listing/no_visualizations_prompt.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/listing/no_visualizations_prompt.js
@@ -18,7 +18,8 @@
*/
import React from 'react';
-import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
+import { i18n } from '@kbn/i18n';
+import { FormattedMessage } from '@kbn/i18n/react';
import {
KuiEmptyTablePrompt,
@@ -27,7 +28,7 @@ import {
KuiButtonIcon,
} from '@kbn/ui-framework/components';
-function NoVisualizationsPromptUi({ onCreateVis, intl }) {
+function NoVisualizationsPrompt({ onCreateVis }) {
return (
}
+ icon={}
>
}
- message={intl.formatMessage({
- id: 'kbn.visualize.listing.noVisualizationsText',
+ message={i18n.translate('kbn.visualize.listing.noVisualizationsText', {
defaultMessage: `Looks like you don't have any visualizations. Let's create some!`,
})}
/>
@@ -52,4 +52,4 @@ function NoVisualizationsPromptUi({ onCreateVis, intl }) {
);
}
-export const NoVisualizationsPrompt = injectI18n(NoVisualizationsPromptUi);
+export { NoVisualizationsPrompt };
diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
index 81f8c0fe5a2b9..f9e3a1a90115a 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing.js
@@ -28,6 +28,7 @@ import { getServices } from '../kibana_services';
const {
addBasePath,
chrome,
+ chromeLegacy,
SavedObjectRegistryProvider,
SavedObjectsClientProvider,
timefilter,
@@ -106,7 +107,7 @@ export function VisualizeListingController($injector, createNewVis) {
})
)
.then(() => {
- chrome.untrackNavLinksForDeletedSavedObjects(selectedItems.map(item => item.id));
+ chromeLegacy.untrackNavLinksForDeletedSavedObjects(selectedItems.map(item => item.id));
})
.catch(error => {
toastNotifications.addError(error, {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing_table.js b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing_table.js
index 67fc70899410b..fbd70a0d8c0f7 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing_table.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/listing/visualize_listing_table.js
@@ -19,30 +19,22 @@
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
-import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
+import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { TableListView } from './../../table_list_view';
-import {
- EuiIcon,
- EuiBetaBadge,
- EuiLink,
- EuiButton,
- EuiEmptyPrompt,
-} from '@elastic/eui';
+import { EuiIcon, EuiBetaBadge, EuiLink, EuiButton, EuiEmptyPrompt } from '@elastic/eui';
import { getServices } from '../kibana_services';
const { capabilities } = getServices();
-class VisualizeListingTableUi extends Component {
-
+class VisualizeListingTable extends Component {
constructor(props) {
super(props);
}
render() {
- const { intl } = this.props;
return (
item.canDelete}
initialFilter={''}
noItemsFragment={this.getNoItemsMessage()}
- entityName={
- intl.formatMessage({
- id: 'kbn.visualize.listing.table.entityName',
- defaultMessage: 'visualization',
- })
- }
- entityNamePlural={
- intl.formatMessage({
- id: 'kbn.visualize.listing.table.entityNamePlural',
- defaultMessage: 'visualizations',
- })
- }
- tableListTitle={
- intl.formatMessage({
- id: 'kbn.visualize.listing.table.listTitle',
- defaultMessage: 'Visualizations',
- })
- }
+ entityName={i18n.translate('kbn.visualize.listing.table.entityName', {
+ defaultMessage: 'visualization',
+ })}
+ entityNamePlural={i18n.translate('kbn.visualize.listing.table.entityNamePlural', {
+ defaultMessage: 'visualizations',
+ })}
+ tableListTitle={i18n.translate('kbn.visualize.listing.table.listTitle', {
+ defaultMessage: 'Visualizations',
+ })}
/>
);
}
getTableColumns() {
- const { intl } = this.props;
const tableColumns = [
{
field: 'title',
- name: intl.formatMessage({
- id: 'kbn.visualize.listing.table.titleColumnName',
+ name: i18n.translate('kbn.visualize.listing.table.titleColumnName', {
defaultMessage: 'Title',
}),
sortable: true,
@@ -95,35 +76,29 @@ class VisualizeListingTableUi extends Component {
>
{field}
- )
+ ),
},
{
field: 'typeTitle',
- name: intl.formatMessage({
- id: 'kbn.visualize.listing.table.typeColumnName',
+ name: i18n.translate('kbn.visualize.listing.table.typeColumnName', {
defaultMessage: 'Type',
}),
sortable: true,
- render: (field, record) => (
+ render: (field, record) => (
{this.renderItemTypeIcon(record)}
{record.typeTitle}
{this.getBadge(record)}
- )
+ ),
},
{
field: 'description',
- name: intl.formatMessage({
- id: 'kbn.dashboard.listing.table.descriptionColumnName',
+ name: i18n.translate('kbn.dashboard.listing.table.descriptionColumnName', {
defaultMessage: 'Description',
}),
sortable: true,
- render: (field, record) => (
-
- {record.description}
-
- )
+ render: (field, record) => {record.description},
},
];
@@ -187,19 +162,13 @@ class VisualizeListingTableUi extends Component {
/>
);
-
}
renderItemTypeIcon(item) {
let icon;
if (item.image) {
icon = (
-
+
);
} else {
icon = (
@@ -217,38 +186,40 @@ class VisualizeListingTableUi extends Component {
getBadge(item) {
if (item.stage === 'beta') {
- return ();
+ return (
+
+ );
} else if (item.stage === 'experimental') {
- return ();
+ return (
+
+ );
}
}
}
-VisualizeListingTableUi.propTypes = {
+VisualizeListingTable.propTypes = {
deleteItems: PropTypes.func.isRequired,
findItems: PropTypes.func.isRequired,
createItem: PropTypes.func.isRequired,
@@ -257,4 +228,4 @@ VisualizeListingTableUi.propTypes = {
listingLimit: PropTypes.number.isRequired,
};
-export const VisualizeListingTable = injectI18n(VisualizeListingTableUi);
+export { VisualizeListingTable };
From 72fd4acfd20349febc5c154a12ae045085d4f467 Mon Sep 17 00:00:00 2001
From: maryia-lapata
Date: Fri, 25 Oct 2019 17:23:56 +0300
Subject: [PATCH 08/12] Update unit tests
---
.../wizard/new_vis_modal.test.mocks.ts | 26 -------------------
.../visualize/wizard/new_vis_modal.test.tsx | 26 ++++++++++++++++---
.../type_selection/new_vis_help.test.tsx | 14 ++++++++--
3 files changed, 34 insertions(+), 32 deletions(-)
delete mode 100644 src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.mocks.ts
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.mocks.ts b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.mocks.ts
deleted file mode 100644
index 04c99a1547ba9..0000000000000
--- a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.mocks.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 const settingsGet = jest.fn();
-
-jest.doMock('ui/chrome', () => ({
- getUiSettingsClient: () => ({
- get: settingsGet,
- }),
-}));
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx
index 6b2f51c3dcf2b..a69c4e4b5d3d1 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx
@@ -20,14 +20,32 @@
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
-import { settingsGet } from './new_vis_modal.test.mocks';
-
import { NewVisModal } from './new_vis_modal';
-
-import { VisType } from 'ui/vis';
import { TypesStart } from '../../../../visualizations/public/np_ready/public/types';
+jest.mock('../kibana_services', () => {
+ const mock = {
+ addBasePath: jest.fn(path => `root${path}`),
+ uiSettings: { get: jest.fn() },
+ createUiStatsReporter: () => jest.fn(),
+ };
+
+ return {
+ getServices: () => mock,
+ VisType: {},
+ METRIC_TYPE: 'metricType',
+ };
+});
+
+import { getServices } from '../kibana_services';
+
+beforeEach(() => {
+ jest.clearAllMocks();
+});
+
describe('NewVisModal', () => {
+ const settingsGet = getServices().uiSettings.get;
+
const defaultVisTypeParams = {
hidden: false,
visualization: class Controller {
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/new_vis_help.test.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/new_vis_help.test.tsx
index 7fd1df85cee06..5980430d0f259 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/new_vis_help.test.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/new_vis_help.test.tsx
@@ -22,7 +22,17 @@ import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { NewVisHelp } from './new_vis_help';
import chrome from 'ui/chrome';
-jest.doMock('ui/chrome');
+jest.mock('../../kibana_services', () => {
+ return {
+ getServices: () => ({
+ addBasePath: jest.fn(url => `testbasepath${url}`),
+ }),
+ };
+});
+
+beforeEach(() => {
+ jest.clearAllMocks();
+});
describe('NewVisHelp', () => {
it('should render as expected', () => {
@@ -36,7 +46,7 @@ describe('NewVisHelp', () => {
aliasUrl: '/my/fancy/new/thing',
description: 'Some desc',
highlighted: false,
- icon: 'wahtever',
+ icon: 'whatever',
name: 'whatever',
promotion: {
buttonText: 'Do it now!',
From 65ef3d063aab523b9795430596471217f739b58e Mon Sep 17 00:00:00 2001
From: maryia-lapata
Date: Mon, 28 Oct 2019 16:29:32 +0300
Subject: [PATCH 09/12] Fix TS
---
.../kibana/public/visualize/wizard/new_vis_modal.test.tsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx
index a69c4e4b5d3d1..99d9590e750fd 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/new_vis_modal.test.tsx
@@ -21,6 +21,7 @@ import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { NewVisModal } from './new_vis_modal';
+import { VisType } from '../kibana_services';
import { TypesStart } from '../../../../visualizations/public/np_ready/public/types';
jest.mock('../kibana_services', () => {
@@ -44,7 +45,7 @@ beforeEach(() => {
});
describe('NewVisModal', () => {
- const settingsGet = getServices().uiSettings.get;
+ const settingsGet = getServices().uiSettings.get as jest.Mock;
const defaultVisTypeParams = {
hidden: false,
From d66b1adc46bb15a925f3c4b16d21a01044b67b1f Mon Sep 17 00:00:00 2001
From: maryia-lapata
Date: Tue, 29 Oct 2019 09:25:40 +0300
Subject: [PATCH 10/12] Move data and Embeddable import
---
.../kibana/public/visualize/editor/editor.js | 2 +-
.../embeddable/disabled_lab_embeddable.tsx | 3 ++-
.../visualize/embeddable/visualize_embeddable.ts | 10 ++++------
.../embeddable/visualize_embeddable_factory.tsx | 15 ++++++++-------
.../kibana/public/visualize/kibana_services.ts | 10 ++++++++++
.../wizard/search_selection/search_selection.tsx | 4 ++--
.../wizard/type_selection/new_vis_help.test.tsx | 5 +----
.../wizard/type_selection/type_selection.tsx | 2 +-
8 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
index b0909d16974b6..a617e184c3dc7 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
+++ b/src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
@@ -31,7 +31,6 @@ import { DashboardConstants } from '../../dashboard/dashboard_constants';
import { VisualizeConstants } from '../visualize_constants';
import { getEditBreadcrumbs, getCreateBreadcrumbs } from '../breadcrumbs';
import { extractTimeFilter, changeTimeFilter } from '../../../../data/public';
-import { start as data } from '../../../../data/public/legacy';
import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util';
@@ -54,6 +53,7 @@ const {
capabilities,
chrome,
chromeLegacy,
+ data,
docTitle,
FilterBarQueryFilterProvider,
getBasePath,
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/disabled_lab_embeddable.tsx b/src/legacy/core_plugins/kibana/public/visualize/embeddable/disabled_lab_embeddable.tsx
index 92bd0fa345fa0..065feae045597 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/disabled_lab_embeddable.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/disabled_lab_embeddable.tsx
@@ -19,7 +19,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { Embeddable, EmbeddableOutput } from '../../../../../../plugins/embeddable/public';
+
+import { Embeddable, EmbeddableOutput } from '../kibana_services';
import { DisabledLabVisualization } from './disabled_lab_visualization';
import { VisualizeInput } from './visualize_embeddable';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
index d95264abdd559..caf37fd907e60 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
@@ -23,16 +23,14 @@ import { Subscription } from 'rxjs';
import * as Rx from 'rxjs';
import { Filter } from '@kbn/es-query';
import { TimeRange } from '../../../../../../plugins/data/public';
-import {
- EmbeddableInput,
- EmbeddableOutput,
- Embeddable,
- Container,
-} from '../../../../../../plugins/embeddable/public';
import { Query, onlyDisabledFiltersChanged } from '../../../../data/public';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {
+ Container,
+ Embeddable,
+ EmbeddableInput,
+ EmbeddableOutput,
PersistedState,
StaticIndexPattern,
VisSavedObject,
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
index b3ccd55110373..ff55b02082040 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable_factory.tsx
@@ -22,12 +22,6 @@ import { i18n } from '@kbn/i18n';
import { Legacy } from 'kibana';
import { SavedObjectAttributes } from 'kibana/server';
-import {
- EmbeddableFactory,
- ErrorEmbeddable,
- Container,
- EmbeddableOutput,
-} from '../../../../../../plugins/embeddable/public';
import { showNewVisModal } from '../wizard';
import { SavedVisualizations } from '../types';
import { DisabledLabEmbeddable } from './disabled_lab_embeddable';
@@ -36,7 +30,14 @@ import { VisualizeEmbeddable, VisualizeInput, VisualizeOutput } from './visualiz
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import { TypesStart } from '../../../../visualizations/public/np_ready/public/types';
-import { getServices, getVisualizeLoader } from '../kibana_services';
+import {
+ getServices,
+ Container,
+ EmbeddableFactory,
+ EmbeddableOutput,
+ ErrorEmbeddable,
+ getVisualizeLoader,
+} from '../kibana_services';
const {
addBasePath,
diff --git a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
index f85b602583335..29d18c28392f0 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts
@@ -47,6 +47,7 @@ import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_regis
import { createUiStatsReporter, METRIC_TYPE } from '../../../ui_metric/public';
import { start as visualizations } from '../../../visualizations/public/np_ready/public/legacy';
+import { start as data } from '../../../data/public/legacy';
const services = {
// new platform
@@ -60,6 +61,7 @@ const services = {
toastNotifications: npStart.core.notifications.toasts,
uiSettings: npStart.core.uiSettings,
+ data,
visualizations,
// legacy
@@ -103,6 +105,14 @@ export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
export { getVisualizeLoader } from 'ui/visualize/loader';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
+export {
+ Container,
+ Embeddable,
+ EmbeddableFactory,
+ EmbeddableInput,
+ EmbeddableOutput,
+ ErrorEmbeddable,
+} from '../../../../../plugins/embeddable/public';
// export types
export { METRIC_TYPE };
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx
index 34c95b43991e8..88dbbb8de7df9 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx
@@ -22,10 +22,10 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
-import { VisType } from 'ui/vis';
-
import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';
+import { VisType } from '../../kibana_services';
+
interface SearchSelectionProps {
onSearchSelected: (searchId: string, searchType: string) => void;
visType: VisType;
diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/new_vis_help.test.tsx b/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/new_vis_help.test.tsx
index 5980430d0f259..382f475669f5d 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/new_vis_help.test.tsx
+++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/type_selection/new_vis_help.test.tsx
@@ -20,12 +20,11 @@
import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { NewVisHelp } from './new_vis_help';
-import chrome from 'ui/chrome';
jest.mock('../../kibana_services', () => {
return {
getServices: () => ({
- addBasePath: jest.fn(url => `testbasepath${url}`),
+ addBasePath: jest.fn((url: string) => `testbasepath${url}`),
}),
};
});
@@ -36,8 +35,6 @@ beforeEach(() => {
describe('NewVisHelp', () => {
it('should render as expected', () => {
- (chrome.addBasePath as unknown) = (url: string) => `testbasepath${url}`;
-
expect(
shallowWithIntl(
Date: Tue, 29 Oct 2019 10:49:42 +0300
Subject: [PATCH 11/12] Import VISUALIZE_EMBEDDABLE_TYPE directly
---
.../canvas_plugin_src/expression_types/embeddable_types.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/expression_types/embeddable_types.ts b/x-pack/legacy/plugins/canvas/canvas_plugin_src/expression_types/embeddable_types.ts
index 6efe6bc96dbba..546e8967a7439 100644
--- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/expression_types/embeddable_types.ts
+++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/expression_types/embeddable_types.ts
@@ -6,7 +6,7 @@
// @ts-ignore
import { MAP_SAVED_OBJECT_TYPE } from '../../../maps/common/constants';
-import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../../../../src/legacy/core_plugins/kibana/public/visualize/embeddable';
+import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../../../../src/legacy/core_plugins/kibana/public/visualize/embeddable/constants';
import { SEARCH_EMBEDDABLE_TYPE } from '../../../../../../src/legacy/core_plugins/kibana/public/discover/embeddable/constants';
export const EmbeddableTypes = {
From 8dd28f785f4b0f7cfc686671466b789258f36b84 Mon Sep 17 00:00:00 2001
From: maryia-lapata
Date: Tue, 29 Oct 2019 16:02:52 +0300
Subject: [PATCH 12/12] Fix deps
---
.../public/visualize/embeddable/visualize_embeddable.ts | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
index 246e16b50efa6..ef9c9a00f980b 100644
--- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
+++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts
@@ -22,8 +22,8 @@ import { EmbeddedVisualizeHandler } from 'ui/visualize/loader/embedded_visualize
import { Subscription } from 'rxjs';
import * as Rx from 'rxjs';
import { Filter } from '@kbn/es-query';
-import { TimeRange } from '../../../../../../plugins/data/public';
-import { Query, onlyDisabledFiltersChanged } from '../../../../data/public';
+import { TimeRange, onlyDisabledFiltersChanged } from '../../../../../../plugins/data/public';
+import { Query } from '../../../../data/public';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {