From d0f0ea6e302e0b6acd7657b770946189143d187f Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Wed, 29 Jan 2020 17:44:00 +0300 Subject: [PATCH 01/18] Move saved object modal into new platform --- src/core/MIGRATION.md | 1 - src/core/public/index.scss | 1 + src/core/public/index.ts | 9 ++ .../public/saved_objects/_index.scss | 0 src/core/public/saved_objects/index.ts | 8 ++ .../saved_object_finder.test.tsx | 2 +- .../saved_objects/saved_object_finder.tsx | 8 +- .../saved_object_save_modal.scss | 0 .../saved_object_save_modal.test.tsx | 0 .../saved_objects/saved_object_save_modal.tsx | 4 +- .../show_saved_object_save_modal.tsx | 3 +- .../kibana/public/dashboard/legacy_imports.ts | 2 - .../np_ready/dashboard_app_controller.tsx | 12 +-- .../np_ready/top_nav/save_modal.test.js | 2 +- .../dashboard/np_ready/top_nav/save_modal.tsx | 2 +- .../kibana/public/discover/kibana_services.ts | 2 - .../discover/np_ready/angular/discover.js | 3 +- .../kibana/public/visualize/legacy_imports.ts | 3 - .../visualize/np_ready/editor/editor.js | 3 +- .../components/saved_object_save_modal.tsx | 25 ----- .../dashboard_container_factory.tsx | 3 +- .../public/plugin.tsx | 11 +- .../public/types.ts | 8 -- src/plugins/embeddable/public/index.ts | 1 - .../lib/embeddables/embeddable_factory.ts | 3 +- src/plugins/embeddable/public/lib/types.ts | 11 -- src/plugins/kibana_react/public/index.ts | 1 - .../saved_object_save_modal.test.tsx.snap | 100 ------------------ .../public/saved_objects/index.ts | 21 ---- .../public/np_ready/public/plugin.tsx | 12 ++- .../renderers/embeddable/embeddable.tsx | 5 +- .../components/embeddable_flyout/flyout.tsx | 8 +- x-pack/legacy/plugins/graph/public/app.js | 3 +- .../graph/public/components/save_modal.tsx | 5 +- .../plugins/graph/public/legacy_imports.ts | 2 - .../graph/public/services/save_modal.tsx | 4 +- .../graph/public/state_management/mocks.ts | 1 - .../public/state_management/persistence.ts | 1 - .../graph/public/state_management/store.ts | 1 - .../plugins/lens/public/app_plugin/app.tsx | 3 +- .../maps/public/angular/map_controller.js | 3 +- .../components/embeddables/embedded_map.tsx | 13 +-- 42 files changed, 65 insertions(+), 245 deletions(-) rename src/{plugins/kibana_react => core}/public/saved_objects/_index.scss (100%) rename src/{plugins/kibana_react => core}/public/saved_objects/saved_object_finder.test.tsx (99%) rename src/{plugins/kibana_react => core}/public/saved_objects/saved_object_finder.tsx (98%) rename src/{plugins/kibana_react => core}/public/saved_objects/saved_object_save_modal.scss (100%) rename src/{plugins/kibana_react => core}/public/saved_objects/saved_object_save_modal.test.tsx (100%) rename src/{plugins/kibana_react => core}/public/saved_objects/saved_object_save_modal.tsx (97%) rename src/{legacy/ui => core}/public/saved_objects/show_saved_object_save_modal.tsx (96%) delete mode 100644 src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx delete mode 100644 src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap delete mode 100644 src/plugins/kibana_react/public/saved_objects/index.ts diff --git a/src/core/MIGRATION.md b/src/core/MIGRATION.md index f8699364fa9e2..d21be843a175c 100644 --- a/src/core/MIGRATION.md +++ b/src/core/MIGRATION.md @@ -1168,7 +1168,6 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy'; | `import 'ui/query_bar'` | `import { QueryStringInput } from '../data/public'` | Directives are deprecated. | | `import 'ui/search_bar'` | `import { SearchBar } from '../data/public'` | Directive is deprecated. | | `import 'ui/kbn_top_nav'` | `import { TopNavMenu } from '../navigation/public'` | Directive is still available in `ui/kbn_top_nav`. | -| `ui/saved_objects/components/saved_object_finder` | `import { SavedObjectFinder } from '../kibana_react/public'` | | | `core_plugins/interpreter` | `data.expressions` | still in progress | | `ui/courier` | `data.search` | still in progress | | `ui/embeddable` | `embeddables` | still in progress | diff --git a/src/core/public/index.scss b/src/core/public/index.scss index 86f2efdff7702..4c3f8eeb4393c 100644 --- a/src/core/public/index.scss +++ b/src/core/public/index.scss @@ -9,3 +9,4 @@ @import './chrome/index'; @import './overlays/index'; +@import './saved_objects/index'; diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 6d756e36d7379..563f05ec8a208 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -137,6 +137,15 @@ export { SavedObjectsImportUnknownError, SavedObjectsImportError, SavedObjectsImportRetry, + showSaveModal, + SaveResult, + MinimalSaveModalProps, + SavedObjectSaveModal, + OnSaveProps, + SavedObjectMetaData, + SavedObjectFinderProps, + SavedObjectFinder, + SavedObjectFinderUi, } from './saved_objects'; export { diff --git a/src/plugins/kibana_react/public/saved_objects/_index.scss b/src/core/public/saved_objects/_index.scss similarity index 100% rename from src/plugins/kibana_react/public/saved_objects/_index.scss rename to src/core/public/saved_objects/_index.scss diff --git a/src/core/public/saved_objects/index.ts b/src/core/public/saved_objects/index.ts index 5015a9c3db78e..8be1b16a8aa09 100644 --- a/src/core/public/saved_objects/index.ts +++ b/src/core/public/saved_objects/index.ts @@ -31,6 +31,14 @@ export { } from './saved_objects_client'; export { SimpleSavedObject } from './simple_saved_object'; export { SavedObjectsStart, SavedObjectsService } from './saved_objects_service'; +export { showSaveModal, SaveResult, MinimalSaveModalProps } from './show_saved_object_save_modal'; +export { SavedObjectSaveModal, OnSaveProps } from './saved_object_save_modal'; +export { + SavedObjectMetaData, + SavedObjectFinderProps, + SavedObjectFinder, + SavedObjectFinderUi, +} from './saved_object_finder'; export { SavedObject, SavedObjectAttribute, diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx b/src/core/public/saved_objects/saved_object_finder.test.tsx similarity index 99% rename from src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx rename to src/core/public/saved_objects/saved_object_finder.test.tsx index 58b396d57639b..bc57da1995ce3 100644 --- a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx +++ b/src/core/public/saved_objects/saved_object_finder.test.tsx @@ -37,7 +37,7 @@ import React from 'react'; import * as sinon from 'sinon'; import { SavedObjectFinderUi as SavedObjectFinder } from './saved_object_finder'; // eslint-disable-next-line -import { coreMock } from '../../../../core/public/mocks'; +import { coreMock } from '../mocks'; describe('SavedObjectsFinder', () => { const doc = { diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx b/src/core/public/saved_objects/saved_object_finder.tsx similarity index 98% rename from src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx rename to src/core/public/saved_objects/saved_object_finder.tsx index 2a43f29024ba7..c47447d951326 100644 --- a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx +++ b/src/core/public/saved_objects/saved_object_finder.tsx @@ -44,9 +44,9 @@ import { import { Direction } from '@elastic/eui/src/services/sort/sort_direction'; import { i18n } from '@kbn/i18n'; -import { SavedObjectAttributes } from '../../../../core/public'; -import { SimpleSavedObject, CoreStart } from '../../../../core/public'; -import { useKibana } from '../context'; +import { SavedObjectAttributes } from '.'; +import { SimpleSavedObject, CoreStart } from '../'; +import { useKibana } from '../../../plugins/kibana_react/public'; // eslint-disable-line @kbn/eslint/no-restricted-paths // TODO the typings for EuiListGroup are incorrect - maxWidth is missing. This can be removed when the types are adjusted const FixedEuiListGroup = (EuiListGroup as any) as React.FunctionComponent< @@ -108,7 +108,7 @@ interface SavedObjectFinderInitialPageSize extends BaseSavedObjectFinder { export type SavedObjectFinderProps = SavedObjectFinderFixedPage | SavedObjectFinderInitialPageSize; -export type SavedObjectFinderUiProps = { +type SavedObjectFinderUiProps = { savedObjects: CoreStart['savedObjects']; uiSettings: CoreStart['uiSettings']; } & SavedObjectFinderProps; diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.scss b/src/core/public/saved_objects/saved_object_save_modal.scss similarity index 100% rename from src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.scss rename to src/core/public/saved_objects/saved_object_save_modal.scss diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.test.tsx b/src/core/public/saved_objects/saved_object_save_modal.test.tsx similarity index 100% rename from src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.test.tsx rename to src/core/public/saved_objects/saved_object_save_modal.test.tsx diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.tsx b/src/core/public/saved_objects/saved_object_save_modal.tsx similarity index 97% rename from src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.tsx rename to src/core/public/saved_objects/saved_object_save_modal.tsx index cdbc2bb9b5473..3e15ae7fe04d1 100644 --- a/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.tsx +++ b/src/core/public/saved_objects/saved_object_save_modal.tsx @@ -35,11 +35,11 @@ import { EuiSwitchEvent, EuiTextArea, } from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/target/types/react'; import React from 'react'; import { EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../../legacy/core_plugins/visualizations/public/embeddable/constants'; +import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../legacy/core_plugins/visualizations/public/embeddable/constants'; // eslint-disable-line @kbn/eslint/no-restricted-paths export interface OnSaveProps { newTitle: string; diff --git a/src/legacy/ui/public/saved_objects/show_saved_object_save_modal.tsx b/src/core/public/saved_objects/show_saved_object_save_modal.tsx similarity index 96% rename from src/legacy/ui/public/saved_objects/show_saved_object_save_modal.tsx rename to src/core/public/saved_objects/show_saved_object_save_modal.tsx index 3c691c692948a..d9ca99fd44e9b 100644 --- a/src/legacy/ui/public/saved_objects/show_saved_object_save_modal.tsx +++ b/src/core/public/saved_objects/show_saved_object_save_modal.tsx @@ -19,7 +19,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { I18nContext } from 'ui/i18n'; +import { npStart } from 'ui/new_platform'; /** * Represents the result of trying to persist the saved object. @@ -62,5 +62,6 @@ export function showSaveModal(saveModal: React.ReactElement{element}, container); } diff --git a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts index 97d165b6b5c23..a0efb166c3203 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts @@ -30,11 +30,9 @@ export const legacyChrome = chrome; export { SavedObjectSaveOpts } from 'ui/saved_objects/types'; export { npSetup, npStart } from 'ui/new_platform'; export { IPrivate } from 'ui/private'; -export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; // @ts-ignore export { ConfirmationButtonTypes } from 'ui/modals/confirm_modal'; -export { showSaveModal, SaveResult } from 'ui/saved_objects/show_saved_object_save_modal'; export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; export { KbnUrl } from 'ui/url/kbn_url'; // @ts-ignore diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx index e85054cd7fb34..5bd3736c763f7 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx @@ -24,14 +24,18 @@ import angular from 'angular'; import { Subscription } from 'rxjs'; import { map } from 'rxjs/operators'; +import { + SaveResult, + showSaveModal, + SavedObjectFinderProps, + SavedObjectFinderUi, +} from '../../../../../../core/public'; import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen'; import { ConfirmationButtonTypes, migrateLegacyQuery, SavedObjectSaveOpts, - SaveResult, - showSaveModal, subscribeWithScope, } from '../legacy_imports'; import { @@ -73,10 +77,6 @@ import { getDashboardTitle } from './dashboard_strings'; import { DashboardAppScope } from './dashboard_app'; import { convertSavedDashboardPanelToPanelState } from './lib/embeddable_saved_object_converters'; import { RenderDeps } from './application'; -import { - SavedObjectFinderProps, - SavedObjectFinderUi, -} from '../../../../../../plugins/kibana_react/public'; import { removeQueryParam, unhashUrl } from '../../../../../../plugins/kibana_utils/public'; export interface DashboardAppControllerDependencies extends RenderDeps { diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js index 5f708a22fd530..ca1efaf22ac31 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js @@ -20,7 +20,7 @@ import React from 'react'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; -jest.mock('../../legacy_imports', () => ({ +jest.mock('../../../../../../../core/public', () => ({ SavedObjectSaveModal: () => null, })); diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx index bd53fd5a13083..31e7e134d1935 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx @@ -21,7 +21,7 @@ import React, { Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFormRow, EuiTextArea, EuiSwitch } from '@elastic/eui'; -import { SavedObjectSaveModal } from '../../legacy_imports'; +import { SavedObjectSaveModal } from '../../../../../../../core/public'; interface SaveOptions { newTitle: string; 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 58406c74e9f38..8e05af64a4f92 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'; -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'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; // @ts-ignore 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 3f3333b7caec2..2cb4fabd51c1d 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 { showSaveModal, SavedObjectSaveModal } from '../../../../../../../core/public'; import { RequestAdapter } from '../../../../../../../plugins/inspector/public'; // doc table import './doc_table'; @@ -47,13 +48,11 @@ import { hasSearchStategyForIndexPattern, intervalOptions, migrateLegacyQuery, - showSaveModal, unhashUrl, stateMonitorFactory, subscribeWithScope, tabifyAggResponse, Vis, - SavedObjectSaveModal, getAngularModule, ensureDefaultIndexPattern, registerTimefilterWithGlobalStateFactory, diff --git a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts index e5165cac5c11e..d33108be8ca86 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts @@ -44,9 +44,6 @@ export { IPrivate } from 'ui/private'; // @ts-ignore export { PrivateProvider } from 'ui/private/private'; -export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; -export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; - export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; // @ts-ignore diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js index 2a4fdeb4e4016..aafb10154fdd1 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js @@ -31,6 +31,7 @@ import { getEditBreadcrumbs } from '../breadcrumbs'; import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util'; import { FilterStateManager } from '../../../../../data/public'; import { unhashUrl } from '../../../../../../../plugins/kibana_utils/public'; +import { showSaveModal, SavedObjectSaveModal } from '../../../../../../../core/public'; import { initVisEditorDirective } from './visualization_editor'; import { initVisualizationDirective } from './visualization'; @@ -40,8 +41,6 @@ import { absoluteToParsedUrl, KibanaParsedUrl, migrateLegacyQuery, - SavedObjectSaveModal, - showSaveModal, stateMonitorFactory, DashboardConstants, } from '../../legacy_imports'; diff --git a/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx b/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx deleted file mode 100644 index 131f28059cebd..0000000000000 --- a/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx +++ /dev/null @@ -1,25 +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. - */ - -/** - * @deprecated - * - * Do not import this component from here. Import from `src/plugins/kibana_react` instead. - */ -export { SavedObjectSaveModal } from '../../../../../plugins/kibana_react/public'; diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx index c8a2837fd77d0..2c8fba893ecf2 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx @@ -18,8 +18,7 @@ */ import { i18n } from '@kbn/i18n'; -import { SavedObjectAttributes } from '../../../../core/public'; -import { SavedObjectMetaData } from '../types'; +import { SavedObjectAttributes, SavedObjectMetaData } from '../../../../core/public'; import { ContainerOutput, EmbeddableFactory, diff --git a/src/plugins/dashboard_embeddable_container/public/plugin.tsx b/src/plugins/dashboard_embeddable_container/public/plugin.tsx index d18fbba239ec0..eeb150965acaf 100644 --- a/src/plugins/dashboard_embeddable_container/public/plugin.tsx +++ b/src/plugins/dashboard_embeddable_container/public/plugin.tsx @@ -20,15 +20,20 @@ /* eslint-disable max-classes-per-file */ import * as React from 'react'; -import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public'; +import { + PluginInitializerContext, + CoreSetup, + CoreStart, + Plugin, + SavedObjectFinderUi, + SavedObjectFinderProps, +} from '../../../core/public'; import { IUiActionsSetup, IUiActionsStart } from '../../../plugins/ui_actions/public'; import { CONTEXT_MENU_TRIGGER, IEmbeddableSetup, IEmbeddableStart } from './embeddable_plugin'; import { ExpandPanelAction, ReplacePanelAction } from '.'; import { DashboardContainerFactory } from './embeddable/dashboard_container_factory'; import { Start as InspectorStartContract } from '../../../plugins/inspector/public'; import { - SavedObjectFinderUi, - SavedObjectFinderProps, ExitFullScreenButton as ExitFullScreenButtonUi, ExitFullScreenButtonProps, } from '../../../plugins/kibana_react/public'; diff --git a/src/plugins/dashboard_embeddable_container/public/types.ts b/src/plugins/dashboard_embeddable_container/public/types.ts index 9c2d6c0ab388d..895f61b617d2e 100644 --- a/src/plugins/dashboard_embeddable_container/public/types.ts +++ b/src/plugins/dashboard_embeddable_container/public/types.ts @@ -50,14 +50,6 @@ export interface SimpleSavedObject { delete(): void; } -export interface SavedObjectMetaData { - type: string; - name: string; - getIconForSavedObject(savedObject: SimpleSavedObject): IconType; - getTooltipForSavedObject?(savedObject: SimpleSavedObject): string; - showSavedObject?(savedObject: SimpleSavedObject): boolean; -} - interface FieldSubType { multi?: { parent: string }; nested?: { path: string }; diff --git a/src/plugins/embeddable/public/index.ts b/src/plugins/embeddable/public/index.ts index 583b21ddfa433..21bc45c6c0312 100644 --- a/src/plugins/embeddable/public/index.ts +++ b/src/plugins/embeddable/public/index.ts @@ -51,7 +51,6 @@ export { PanelNotFoundError, PanelState, PropertySpec, - SavedObjectMetaData, ViewMode, isErrorEmbeddable, openAddPanelFlyout, diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts index acc2da1514483..cec0d1875d040 100644 --- a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts +++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts @@ -17,8 +17,7 @@ * under the License. */ -import { SavedObjectAttributes } from 'src/core/public'; -import { SavedObjectMetaData } from '../types'; +import { SavedObjectAttributes, SavedObjectMetaData } from 'src/core/public'; import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from './i_embeddable'; import { ErrorEmbeddable } from './error_embeddable'; import { IContainer } from '../containers/i_container'; diff --git a/src/plugins/embeddable/public/lib/types.ts b/src/plugins/embeddable/public/lib/types.ts index 5fc01a62351c0..1bd71163db44c 100644 --- a/src/plugins/embeddable/public/lib/types.ts +++ b/src/plugins/embeddable/public/lib/types.ts @@ -42,16 +42,5 @@ export enum ViewMode { export { Adapters }; -// import { SavedObjectMetaData } from 'ui/saved_objects/components/saved_object_finder'; -// TODO: Figure out how to do this import in New Platform. -export interface SavedObjectMetaData { - type: string; - name: string; - getIconForSavedObject(savedObject: any): any; - getTooltipForSavedObject?(savedObject: any): any; - showSavedObject?(savedObject: any): boolean; - includeFields?: string[]; -} - export type GetEmbeddableFactory = (id: string) => EmbeddableFactory | undefined; export type GetEmbeddableFactories = () => IterableIterator; diff --git a/src/plugins/kibana_react/public/index.ts b/src/plugins/kibana_react/public/index.ts index 81f2e694e8e5b..1108da1f778b7 100644 --- a/src/plugins/kibana_react/public/index.ts +++ b/src/plugins/kibana_react/public/index.ts @@ -18,7 +18,6 @@ */ export * from './code_editor'; -export * from './saved_objects'; export * from './exit_full_screen_button'; export * from './context'; export * from './overlays'; diff --git a/src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap b/src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap deleted file mode 100644 index 18f84f41d5d99..0000000000000 --- a/src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap +++ /dev/null @@ -1,100 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` - -
- - - - - - - - - - } - labelType="label" - > - - - - } - labelType="label" - > - - - - - - - - - - Save - - - -
-
-`; diff --git a/src/plugins/kibana_react/public/saved_objects/index.ts b/src/plugins/kibana_react/public/saved_objects/index.ts deleted file mode 100644 index ade80d2cd2a92..0000000000000 --- a/src/plugins/kibana_react/public/saved_objects/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export * from './saved_object_finder'; -export * from './saved_object_save_modal'; diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx index 8f22e54bac3c1..64400566b437a 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx @@ -18,7 +18,13 @@ */ import React from 'react'; import ReactDOM from 'react-dom'; -import { CoreSetup, CoreStart, Plugin } from 'src/core/public'; +import { + CoreSetup, + CoreStart, + Plugin, + SavedObjectFinderProps, + SavedObjectFinderUi, +} from 'src/core/public'; import { IUiActionsStart } from '../../../../../../../src/plugins/ui_actions/public'; import { createHelloWorldAction } from '../../../../../../../src/plugins/ui_actions/public/tests/test_samples'; @@ -37,10 +43,6 @@ import { ContactCardEmbeddableFactory, } from './embeddable_api'; import { App } from './app'; -import { - SavedObjectFinderProps, - SavedObjectFinderUi, -} from '../../../../../../../src/plugins/kibana_react/public/saved_objects'; import { HelloWorldEmbeddableFactory } from '../../../../../../../examples/embeddable_examples/public'; import { IEmbeddableStart, diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx index 8642ebd901bb4..94de87c27b7ec 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx @@ -17,10 +17,7 @@ import { import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; import { EmbeddableExpression } from '../../expression_types/embeddable'; import { RendererStrings } from '../../../i18n'; -import { - SavedObjectFinderProps, - SavedObjectFinderUi, -} from '../../../../../../../src/plugins/kibana_react/public'; +import { SavedObjectFinderProps, SavedObjectFinderUi } from '../../../../../../../src/core/public'; const { embeddable: strings } = RendererStrings; import { embeddableInputToExpression } from './embeddable_input_to_expression'; diff --git a/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx b/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx index 786403f2748fa..78af478085fd6 100644 --- a/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx @@ -7,13 +7,13 @@ import React from 'react'; import { EuiFlyout, EuiFlyoutHeader, EuiFlyoutBody, EuiTitle } from '@elastic/eui'; +import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; +import { ComponentStrings } from '../../../i18n'; import { + CoreStart, SavedObjectFinderUi, SavedObjectMetaData, -} from '../../../../../../../src/plugins/kibana_react/public/saved_objects'; // eslint-disable-line -import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; -import { ComponentStrings } from '../../../i18n'; -import { CoreStart } from '../../../../../../../src/core/public'; +} from '../../../../../../../src/core/public'; const { AddEmbeddableFlyout: strings } = ComponentStrings; diff --git a/x-pack/legacy/plugins/graph/public/app.js b/x-pack/legacy/plugins/graph/public/app.js index d0dbf34abc055..37ceee2445629 100644 --- a/x-pack/legacy/plugins/graph/public/app.js +++ b/x-pack/legacy/plugins/graph/public/app.js @@ -12,7 +12,7 @@ import { Provider } from 'react-redux'; import { isColorDark, hexToRgb } from '@elastic/eui'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; -import { showSaveModal } from './legacy_imports'; +import { showSaveModal } from '../../../../../src/core/public'; import appTemplate from './angular/templates/index.html'; import listingTemplate from './angular/templates/listing_ng_wrapper.html'; @@ -276,7 +276,6 @@ export function initGraphApp(angularModule, deps) { }, notifications: coreStart.notifications, http: coreStart.http, - showSaveModal, setWorkspaceInitialized: () => { $scope.workspaceInitialized = true; }, diff --git a/x-pack/legacy/plugins/graph/public/components/save_modal.tsx b/x-pack/legacy/plugins/graph/public/components/save_modal.tsx index b60a444453f7d..56383409078a6 100644 --- a/x-pack/legacy/plugins/graph/public/components/save_modal.tsx +++ b/x-pack/legacy/plugins/graph/public/components/save_modal.tsx @@ -7,10 +7,7 @@ import React, { useState } from 'react'; import { EuiFormRow, EuiTextArea, EuiCallOut, EuiSpacer, EuiSwitch } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { - SavedObjectSaveModal, - OnSaveProps, -} from '../../../../../../src/plugins/kibana_react/public'; +import { SavedObjectSaveModal, OnSaveProps } from '../../../../../../src/core/public'; import { GraphSavePolicy } from '../types/config'; diff --git a/x-pack/legacy/plugins/graph/public/legacy_imports.ts b/x-pack/legacy/plugins/graph/public/legacy_imports.ts index 7ea2cf6dd901b..702c6cb2d4542 100644 --- a/x-pack/legacy/plugins/graph/public/legacy_imports.ts +++ b/x-pack/legacy/plugins/graph/public/legacy_imports.ts @@ -15,6 +15,4 @@ export { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_to export { confirmModalFactory } from 'ui/modals/confirm_modal'; // @ts-ignore export { addAppRedirectMessageToUrl } from 'ui/notify'; -export { SaveResult } from 'ui/saved_objects/show_saved_object_save_modal'; export { createSavedObjectClass } from 'ui/saved_objects/saved_object'; -export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; diff --git a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx index d949ac1d4a600..cabb20941ca1d 100644 --- a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx +++ b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx @@ -5,9 +5,9 @@ */ import React from 'react'; +import { showSaveModal, SaveResult } from '../../../../../../src/core/public'; import { GraphWorkspaceSavedObject, GraphSavePolicy } from '../types'; import { SaveModal, OnSaveGraphProps } from '../components/save_modal'; -import { SaveResult } from '../legacy_imports'; export type SaveWorkspaceHandler = ( saveOptions: { @@ -23,13 +23,11 @@ export function openSaveModal({ hasData, workspace, saveWorkspace, - showSaveModal, }: { savePolicy: GraphSavePolicy; hasData: boolean; workspace: GraphWorkspaceSavedObject; saveWorkspace: SaveWorkspaceHandler; - showSaveModal: (el: React.ReactNode) => void; }) { const currentTitle = workspace.title; const currentDescription = workspace.description; diff --git a/x-pack/legacy/plugins/graph/public/state_management/mocks.ts b/x-pack/legacy/plugins/graph/public/state_management/mocks.ts index 5a4f0d033aa42..518569fc23091 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/mocks.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/mocks.ts @@ -72,7 +72,6 @@ export function createMockGraphStore({ http: {} as HttpStart, notifyAngular: jest.fn(), savePolicy: 'configAndData', - showSaveModal: jest.fn(), setLiveResponseFields: jest.fn(), setUrlTemplates: jest.fn(), setWorkspaceInitialized: jest.fn(), diff --git a/x-pack/legacy/plugins/graph/public/state_management/persistence.ts b/x-pack/legacy/plugins/graph/public/state_management/persistence.ts index 0bc7827358b81..a7d8a2ca23d11 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/persistence.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/persistence.ts @@ -197,7 +197,6 @@ function showModal( savePolicy: deps.savePolicy, hasData: workspace.nodes.length > 0 || workspace.blacklistedNodes.length > 0, workspace: savedWorkspace, - showSaveModal: deps.showSaveModal, saveWorkspace: saveWorkspaceHandler, }); } diff --git a/x-pack/legacy/plugins/graph/public/state_management/store.ts b/x-pack/legacy/plugins/graph/public/state_management/store.ts index bb01f20196f87..4ae0a375dbce2 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/store.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/store.ts @@ -54,7 +54,6 @@ export interface GraphStoreDependencies { getSavedWorkspace: () => GraphWorkspaceSavedObject; notifications: CoreStart['notifications']; http: CoreStart['http']; - showSaveModal: (el: React.ReactNode) => void; savePolicy: GraphSavePolicy; changeUrl: (newUrl: string) => void; notifyAngular: () => void; diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index 35e45af6a3d68..0bc8a82c4a96c 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx @@ -9,12 +9,11 @@ import React, { useState, useEffect, useCallback } from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { Query, DataPublicPluginStart } from 'src/plugins/data/public'; -import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; import { AppMountContext, NotificationsStart } from 'src/core/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { npStart } from 'ui/new_platform'; import { FormattedMessage } from '@kbn/i18n/react'; -import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { KibanaContextProvider, SavedObjectSaveModal } from '../../../../../../src/core/public'; import { Document, SavedObjectStore } from '../persistence'; import { EditorFrameInstance } from '../types'; import { NativeRenderer } from '../native_renderer'; 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 5f058e2ba7806..d700bda840554 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -45,8 +45,6 @@ import { import { getInspectorAdapters } from '../reducers/non_serializable_instances'; import { docTitle } from 'ui/doc_title'; 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'; import { getInitialLayers } from './get_initial_layers'; import { getInitialQuery } from './get_initial_query'; @@ -55,6 +53,7 @@ import { getInitialRefreshConfig } from './get_initial_refresh_config'; import { MAP_SAVED_OBJECT_TYPE, MAP_APP_PATH } from '../../common/constants'; import { npStart } from 'ui/new_platform'; import { esFilters } from '../../../../../../src/plugins/data/public'; +import { showSaveModal, SavedObjectSaveModal } from '../../../../../../src/core/public'; const savedQueryService = npStart.plugins.data.query.savedQueries; diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx index cbbb4f8c6249e..305e8061e73bc 100644 --- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx +++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx @@ -25,10 +25,7 @@ import * as i18n from './translations'; import { MapEmbeddable, SetQuery } from './types'; import { Query, esFilters } from '../../../../../../../src/plugins/data/public'; import { useKibana, useUiSetting$ } from '../../lib/kibana'; -import { - SavedObjectFinderProps, - SavedObjectFinderUi, -} from '../../../../../../../src/plugins/kibana_react/public'; +import { SavedObjectFinder } from '../../../../../../../src/core/public'; interface EmbeddableMapProps { maintainRatio?: boolean; @@ -177,14 +174,6 @@ export const EmbeddedMapComponent = ({ } }, [startDate, endDate]); - const SavedObjectFinder = (props: SavedObjectFinderProps) => ( - - ); - return isError ? null : ( From f2f9f5e9356d0b0de8b18e9fceebf721393eacd0 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Thu, 30 Jan 2020 10:24:14 +0300 Subject: [PATCH 02/18] Fix TS --- src/core/public/saved_objects/saved_object_save_modal.tsx | 2 +- .../embeddable/public/lib/embeddables/embeddable_factory.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/public/saved_objects/saved_object_save_modal.tsx b/src/core/public/saved_objects/saved_object_save_modal.tsx index 3e15ae7fe04d1..e88752bfc4800 100644 --- a/src/core/public/saved_objects/saved_object_save_modal.tsx +++ b/src/core/public/saved_objects/saved_object_save_modal.tsx @@ -35,7 +35,7 @@ import { EuiSwitchEvent, EuiTextArea, } from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/target/types/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; import { EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts index cec0d1875d040..64d73327c12ca 100644 --- a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts +++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts @@ -39,7 +39,7 @@ export interface OutputSpec { [key: string]: PropertySpec; } -export interface EmbeddableFactoryOptions { +export interface EmbeddableFactoryOptions { savedObjectMetaData?: SavedObjectMetaData; } From 26f1398b2df1efa9738bb3ed3396dbfe0d8e2ba4 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Thu, 30 Jan 2020 10:24:56 +0300 Subject: [PATCH 03/18] Revert "Fix TS" This reverts commit f2f9f5e9356d0b0de8b18e9fceebf721393eacd0. --- src/core/public/saved_objects/saved_object_save_modal.tsx | 2 +- .../embeddable/public/lib/embeddables/embeddable_factory.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/public/saved_objects/saved_object_save_modal.tsx b/src/core/public/saved_objects/saved_object_save_modal.tsx index e88752bfc4800..3e15ae7fe04d1 100644 --- a/src/core/public/saved_objects/saved_object_save_modal.tsx +++ b/src/core/public/saved_objects/saved_object_save_modal.tsx @@ -35,7 +35,7 @@ import { EuiSwitchEvent, EuiTextArea, } from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/target/types/react'; import React from 'react'; import { EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts index 64d73327c12ca..cec0d1875d040 100644 --- a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts +++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts @@ -39,7 +39,7 @@ export interface OutputSpec { [key: string]: PropertySpec; } -export interface EmbeddableFactoryOptions { +export interface EmbeddableFactoryOptions { savedObjectMetaData?: SavedObjectMetaData; } From b8e736adfa83fd0494deb470b5fc874d878e3c71 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Thu, 30 Jan 2020 10:27:13 +0300 Subject: [PATCH 04/18] Revert "Move saved object modal into new platform" This reverts commit d0f0ea6e302e0b6acd7657b770946189143d187f. # Conflicts: # src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js --- src/core/MIGRATION.md | 1 + src/core/public/index.scss | 1 - src/core/public/index.ts | 9 -- src/core/public/saved_objects/index.ts | 8 -- .../kibana/public/dashboard/legacy_imports.ts | 2 + .../np_ready/dashboard_app_controller.tsx | 12 +-- .../np_ready/top_nav/save_modal.test.js | 2 +- .../dashboard/np_ready/top_nav/save_modal.tsx | 2 +- .../kibana/public/discover/kibana_services.ts | 2 + .../discover/np_ready/angular/discover.js | 3 +- .../kibana/public/visualize/legacy_imports.ts | 3 + .../visualize/np_ready/editor/editor.js | 3 +- .../components/saved_object_save_modal.tsx | 25 +++++ .../show_saved_object_save_modal.tsx | 3 +- .../dashboard_container_factory.tsx | 3 +- .../public/plugin.tsx | 11 +- .../public/types.ts | 8 ++ src/plugins/embeddable/public/index.ts | 1 + .../lib/embeddables/embeddable_factory.ts | 3 +- src/plugins/embeddable/public/lib/types.ts | 11 ++ src/plugins/kibana_react/public/index.ts | 1 + .../saved_object_save_modal.test.tsx.snap | 100 ++++++++++++++++++ .../public/saved_objects/_index.scss | 0 .../public/saved_objects/index.ts | 21 ++++ .../saved_object_finder.test.tsx | 2 +- .../saved_objects/saved_object_finder.tsx | 8 +- .../saved_object_save_modal.scss | 0 .../saved_object_save_modal.test.tsx | 0 .../saved_objects/saved_object_save_modal.tsx | 4 +- .../public/np_ready/public/plugin.tsx | 12 +-- .../renderers/embeddable/embeddable.tsx | 5 +- .../components/embeddable_flyout/flyout.tsx | 8 +- x-pack/legacy/plugins/graph/public/app.js | 3 +- .../graph/public/components/save_modal.tsx | 5 +- .../plugins/graph/public/legacy_imports.ts | 2 + .../graph/public/services/save_modal.tsx | 4 +- .../graph/public/state_management/mocks.ts | 1 + .../public/state_management/persistence.ts | 1 + .../graph/public/state_management/store.ts | 1 + .../plugins/lens/public/app_plugin/app.tsx | 3 +- .../maps/public/angular/map_controller.js | 3 +- .../components/embeddables/embedded_map.tsx | 13 ++- 42 files changed, 245 insertions(+), 65 deletions(-) create mode 100644 src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx rename src/{core => legacy/ui}/public/saved_objects/show_saved_object_save_modal.tsx (96%) create mode 100644 src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap rename src/{core => plugins/kibana_react}/public/saved_objects/_index.scss (100%) create mode 100644 src/plugins/kibana_react/public/saved_objects/index.ts rename src/{core => plugins/kibana_react}/public/saved_objects/saved_object_finder.test.tsx (99%) rename src/{core => plugins/kibana_react}/public/saved_objects/saved_object_finder.tsx (98%) rename src/{core => plugins/kibana_react}/public/saved_objects/saved_object_save_modal.scss (100%) rename src/{core => plugins/kibana_react}/public/saved_objects/saved_object_save_modal.test.tsx (100%) rename src/{core => plugins/kibana_react}/public/saved_objects/saved_object_save_modal.tsx (97%) diff --git a/src/core/MIGRATION.md b/src/core/MIGRATION.md index d21be843a175c..f8699364fa9e2 100644 --- a/src/core/MIGRATION.md +++ b/src/core/MIGRATION.md @@ -1168,6 +1168,7 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy'; | `import 'ui/query_bar'` | `import { QueryStringInput } from '../data/public'` | Directives are deprecated. | | `import 'ui/search_bar'` | `import { SearchBar } from '../data/public'` | Directive is deprecated. | | `import 'ui/kbn_top_nav'` | `import { TopNavMenu } from '../navigation/public'` | Directive is still available in `ui/kbn_top_nav`. | +| `ui/saved_objects/components/saved_object_finder` | `import { SavedObjectFinder } from '../kibana_react/public'` | | | `core_plugins/interpreter` | `data.expressions` | still in progress | | `ui/courier` | `data.search` | still in progress | | `ui/embeddable` | `embeddables` | still in progress | diff --git a/src/core/public/index.scss b/src/core/public/index.scss index 4c3f8eeb4393c..86f2efdff7702 100644 --- a/src/core/public/index.scss +++ b/src/core/public/index.scss @@ -9,4 +9,3 @@ @import './chrome/index'; @import './overlays/index'; -@import './saved_objects/index'; diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 563f05ec8a208..6d756e36d7379 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -137,15 +137,6 @@ export { SavedObjectsImportUnknownError, SavedObjectsImportError, SavedObjectsImportRetry, - showSaveModal, - SaveResult, - MinimalSaveModalProps, - SavedObjectSaveModal, - OnSaveProps, - SavedObjectMetaData, - SavedObjectFinderProps, - SavedObjectFinder, - SavedObjectFinderUi, } from './saved_objects'; export { diff --git a/src/core/public/saved_objects/index.ts b/src/core/public/saved_objects/index.ts index 8be1b16a8aa09..5015a9c3db78e 100644 --- a/src/core/public/saved_objects/index.ts +++ b/src/core/public/saved_objects/index.ts @@ -31,14 +31,6 @@ export { } from './saved_objects_client'; export { SimpleSavedObject } from './simple_saved_object'; export { SavedObjectsStart, SavedObjectsService } from './saved_objects_service'; -export { showSaveModal, SaveResult, MinimalSaveModalProps } from './show_saved_object_save_modal'; -export { SavedObjectSaveModal, OnSaveProps } from './saved_object_save_modal'; -export { - SavedObjectMetaData, - SavedObjectFinderProps, - SavedObjectFinder, - SavedObjectFinderUi, -} from './saved_object_finder'; export { SavedObject, SavedObjectAttribute, diff --git a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts index a0efb166c3203..97d165b6b5c23 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts @@ -30,9 +30,11 @@ export const legacyChrome = chrome; export { SavedObjectSaveOpts } from 'ui/saved_objects/types'; export { npSetup, npStart } from 'ui/new_platform'; export { IPrivate } from 'ui/private'; +export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; // @ts-ignore export { ConfirmationButtonTypes } from 'ui/modals/confirm_modal'; +export { showSaveModal, SaveResult } from 'ui/saved_objects/show_saved_object_save_modal'; export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; export { KbnUrl } from 'ui/url/kbn_url'; // @ts-ignore diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx index 5bd3736c763f7..e85054cd7fb34 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx @@ -24,18 +24,14 @@ import angular from 'angular'; import { Subscription } from 'rxjs'; import { map } from 'rxjs/operators'; -import { - SaveResult, - showSaveModal, - SavedObjectFinderProps, - SavedObjectFinderUi, -} from '../../../../../../core/public'; import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen'; import { ConfirmationButtonTypes, migrateLegacyQuery, SavedObjectSaveOpts, + SaveResult, + showSaveModal, subscribeWithScope, } from '../legacy_imports'; import { @@ -77,6 +73,10 @@ import { getDashboardTitle } from './dashboard_strings'; import { DashboardAppScope } from './dashboard_app'; import { convertSavedDashboardPanelToPanelState } from './lib/embeddable_saved_object_converters'; import { RenderDeps } from './application'; +import { + SavedObjectFinderProps, + SavedObjectFinderUi, +} from '../../../../../../plugins/kibana_react/public'; import { removeQueryParam, unhashUrl } from '../../../../../../plugins/kibana_utils/public'; export interface DashboardAppControllerDependencies extends RenderDeps { diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js index ca1efaf22ac31..5f708a22fd530 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js @@ -20,7 +20,7 @@ import React from 'react'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; -jest.mock('../../../../../../../core/public', () => ({ +jest.mock('../../legacy_imports', () => ({ SavedObjectSaveModal: () => null, })); diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx index 31e7e134d1935..bd53fd5a13083 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx @@ -21,7 +21,7 @@ import React, { Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFormRow, EuiTextArea, EuiSwitch } from '@elastic/eui'; -import { SavedObjectSaveModal } from '../../../../../../../core/public'; +import { SavedObjectSaveModal } from '../../legacy_imports'; interface SaveOptions { newTitle: string; 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 f70b8de08f144..9a0b0731b6b11 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -62,6 +62,8 @@ export { getRequestInspectorStats, getResponseInspectorStats } from '../../../da export { intervalOptions } from 'ui/agg_types/buckets/_interval_options'; // @ts-ignore export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; +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'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; // @ts-ignore 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 3e16dac0bc38f..5e99cab1b3297 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,7 +25,6 @@ import dateMath from '@elastic/datemath'; import { i18n } from '@kbn/i18n'; import '../components/field_chooser/field_chooser'; -import { showSaveModal, SavedObjectSaveModal } from '../../../../../../../core/public'; import { RequestAdapter } from '../../../../../../../plugins/inspector/public'; // doc table import './doc_table'; @@ -48,10 +47,12 @@ import { hasSearchStategyForIndexPattern, intervalOptions, migrateLegacyQuery, + showSaveModal, unhashUrl, stateMonitorFactory, subscribeWithScope, tabifyAggResponse, + SavedObjectSaveModal, getAngularModule, ensureDefaultIndexPattern, registerTimefilterWithGlobalStateFactory, diff --git a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts index bb24870c5a5f3..b185dc577a3aa 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts @@ -44,6 +44,9 @@ export { IPrivate } from 'ui/private'; // @ts-ignore export { PrivateProvider } from 'ui/private/private'; +export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; +export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; + export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; // @ts-ignore diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js index ea42dac8804d7..96a583bec7dc9 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js @@ -31,7 +31,6 @@ import { getEditBreadcrumbs } from '../breadcrumbs'; import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util'; import { FilterStateManager } from '../../../../../data/public'; import { unhashUrl } from '../../../../../../../plugins/kibana_utils/public'; -import { showSaveModal, SavedObjectSaveModal } from '../../../../../../../core/public'; import { initVisEditorDirective } from './visualization_editor'; import { initVisualizationDirective } from './visualization'; @@ -41,6 +40,8 @@ import { absoluteToParsedUrl, KibanaParsedUrl, migrateLegacyQuery, + SavedObjectSaveModal, + showSaveModal, stateMonitorFactory, DashboardConstants, } from '../../legacy_imports'; diff --git a/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx b/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx new file mode 100644 index 0000000000000..131f28059cebd --- /dev/null +++ b/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx @@ -0,0 +1,25 @@ +/* + * 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. + */ + +/** + * @deprecated + * + * Do not import this component from here. Import from `src/plugins/kibana_react` instead. + */ +export { SavedObjectSaveModal } from '../../../../../plugins/kibana_react/public'; diff --git a/src/core/public/saved_objects/show_saved_object_save_modal.tsx b/src/legacy/ui/public/saved_objects/show_saved_object_save_modal.tsx similarity index 96% rename from src/core/public/saved_objects/show_saved_object_save_modal.tsx rename to src/legacy/ui/public/saved_objects/show_saved_object_save_modal.tsx index d9ca99fd44e9b..3c691c692948a 100644 --- a/src/core/public/saved_objects/show_saved_object_save_modal.tsx +++ b/src/legacy/ui/public/saved_objects/show_saved_object_save_modal.tsx @@ -19,7 +19,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { npStart } from 'ui/new_platform'; +import { I18nContext } from 'ui/i18n'; /** * Represents the result of trying to persist the saved object. @@ -62,6 +62,5 @@ export function showSaveModal(saveModal: React.ReactElement{element}, container); } diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx index 2c8fba893ecf2..c8a2837fd77d0 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx @@ -18,7 +18,8 @@ */ import { i18n } from '@kbn/i18n'; -import { SavedObjectAttributes, SavedObjectMetaData } from '../../../../core/public'; +import { SavedObjectAttributes } from '../../../../core/public'; +import { SavedObjectMetaData } from '../types'; import { ContainerOutput, EmbeddableFactory, diff --git a/src/plugins/dashboard_embeddable_container/public/plugin.tsx b/src/plugins/dashboard_embeddable_container/public/plugin.tsx index eeb150965acaf..d18fbba239ec0 100644 --- a/src/plugins/dashboard_embeddable_container/public/plugin.tsx +++ b/src/plugins/dashboard_embeddable_container/public/plugin.tsx @@ -20,20 +20,15 @@ /* eslint-disable max-classes-per-file */ import * as React from 'react'; -import { - PluginInitializerContext, - CoreSetup, - CoreStart, - Plugin, - SavedObjectFinderUi, - SavedObjectFinderProps, -} from '../../../core/public'; +import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public'; import { IUiActionsSetup, IUiActionsStart } from '../../../plugins/ui_actions/public'; import { CONTEXT_MENU_TRIGGER, IEmbeddableSetup, IEmbeddableStart } from './embeddable_plugin'; import { ExpandPanelAction, ReplacePanelAction } from '.'; import { DashboardContainerFactory } from './embeddable/dashboard_container_factory'; import { Start as InspectorStartContract } from '../../../plugins/inspector/public'; import { + SavedObjectFinderUi, + SavedObjectFinderProps, ExitFullScreenButton as ExitFullScreenButtonUi, ExitFullScreenButtonProps, } from '../../../plugins/kibana_react/public'; diff --git a/src/plugins/dashboard_embeddable_container/public/types.ts b/src/plugins/dashboard_embeddable_container/public/types.ts index 895f61b617d2e..9c2d6c0ab388d 100644 --- a/src/plugins/dashboard_embeddable_container/public/types.ts +++ b/src/plugins/dashboard_embeddable_container/public/types.ts @@ -50,6 +50,14 @@ export interface SimpleSavedObject { delete(): void; } +export interface SavedObjectMetaData { + type: string; + name: string; + getIconForSavedObject(savedObject: SimpleSavedObject): IconType; + getTooltipForSavedObject?(savedObject: SimpleSavedObject): string; + showSavedObject?(savedObject: SimpleSavedObject): boolean; +} + interface FieldSubType { multi?: { parent: string }; nested?: { path: string }; diff --git a/src/plugins/embeddable/public/index.ts b/src/plugins/embeddable/public/index.ts index 21bc45c6c0312..583b21ddfa433 100644 --- a/src/plugins/embeddable/public/index.ts +++ b/src/plugins/embeddable/public/index.ts @@ -51,6 +51,7 @@ export { PanelNotFoundError, PanelState, PropertySpec, + SavedObjectMetaData, ViewMode, isErrorEmbeddable, openAddPanelFlyout, diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts index cec0d1875d040..acc2da1514483 100644 --- a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts +++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts @@ -17,7 +17,8 @@ * under the License. */ -import { SavedObjectAttributes, SavedObjectMetaData } from 'src/core/public'; +import { SavedObjectAttributes } from 'src/core/public'; +import { SavedObjectMetaData } from '../types'; import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from './i_embeddable'; import { ErrorEmbeddable } from './error_embeddable'; import { IContainer } from '../containers/i_container'; diff --git a/src/plugins/embeddable/public/lib/types.ts b/src/plugins/embeddable/public/lib/types.ts index 1bd71163db44c..5fc01a62351c0 100644 --- a/src/plugins/embeddable/public/lib/types.ts +++ b/src/plugins/embeddable/public/lib/types.ts @@ -42,5 +42,16 @@ export enum ViewMode { export { Adapters }; +// import { SavedObjectMetaData } from 'ui/saved_objects/components/saved_object_finder'; +// TODO: Figure out how to do this import in New Platform. +export interface SavedObjectMetaData { + type: string; + name: string; + getIconForSavedObject(savedObject: any): any; + getTooltipForSavedObject?(savedObject: any): any; + showSavedObject?(savedObject: any): boolean; + includeFields?: string[]; +} + export type GetEmbeddableFactory = (id: string) => EmbeddableFactory | undefined; export type GetEmbeddableFactories = () => IterableIterator; diff --git a/src/plugins/kibana_react/public/index.ts b/src/plugins/kibana_react/public/index.ts index 1108da1f778b7..81f2e694e8e5b 100644 --- a/src/plugins/kibana_react/public/index.ts +++ b/src/plugins/kibana_react/public/index.ts @@ -18,6 +18,7 @@ */ export * from './code_editor'; +export * from './saved_objects'; export * from './exit_full_screen_button'; export * from './context'; export * from './overlays'; diff --git a/src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap b/src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap new file mode 100644 index 0000000000000..18f84f41d5d99 --- /dev/null +++ b/src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap @@ -0,0 +1,100 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` + +
+ + + + + + + + + + } + labelType="label" + > + + + + } + labelType="label" + > + + + + + + + + + + Save + + + +
+
+`; diff --git a/src/core/public/saved_objects/_index.scss b/src/plugins/kibana_react/public/saved_objects/_index.scss similarity index 100% rename from src/core/public/saved_objects/_index.scss rename to src/plugins/kibana_react/public/saved_objects/_index.scss diff --git a/src/plugins/kibana_react/public/saved_objects/index.ts b/src/plugins/kibana_react/public/saved_objects/index.ts new file mode 100644 index 0000000000000..ade80d2cd2a92 --- /dev/null +++ b/src/plugins/kibana_react/public/saved_objects/index.ts @@ -0,0 +1,21 @@ +/* + * 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 * from './saved_object_finder'; +export * from './saved_object_save_modal'; diff --git a/src/core/public/saved_objects/saved_object_finder.test.tsx b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx similarity index 99% rename from src/core/public/saved_objects/saved_object_finder.test.tsx rename to src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx index bc57da1995ce3..58b396d57639b 100644 --- a/src/core/public/saved_objects/saved_object_finder.test.tsx +++ b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx @@ -37,7 +37,7 @@ import React from 'react'; import * as sinon from 'sinon'; import { SavedObjectFinderUi as SavedObjectFinder } from './saved_object_finder'; // eslint-disable-next-line -import { coreMock } from '../mocks'; +import { coreMock } from '../../../../core/public/mocks'; describe('SavedObjectsFinder', () => { const doc = { diff --git a/src/core/public/saved_objects/saved_object_finder.tsx b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx similarity index 98% rename from src/core/public/saved_objects/saved_object_finder.tsx rename to src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx index c47447d951326..2a43f29024ba7 100644 --- a/src/core/public/saved_objects/saved_object_finder.tsx +++ b/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx @@ -44,9 +44,9 @@ import { import { Direction } from '@elastic/eui/src/services/sort/sort_direction'; import { i18n } from '@kbn/i18n'; -import { SavedObjectAttributes } from '.'; -import { SimpleSavedObject, CoreStart } from '../'; -import { useKibana } from '../../../plugins/kibana_react/public'; // eslint-disable-line @kbn/eslint/no-restricted-paths +import { SavedObjectAttributes } from '../../../../core/public'; +import { SimpleSavedObject, CoreStart } from '../../../../core/public'; +import { useKibana } from '../context'; // TODO the typings for EuiListGroup are incorrect - maxWidth is missing. This can be removed when the types are adjusted const FixedEuiListGroup = (EuiListGroup as any) as React.FunctionComponent< @@ -108,7 +108,7 @@ interface SavedObjectFinderInitialPageSize extends BaseSavedObjectFinder { export type SavedObjectFinderProps = SavedObjectFinderFixedPage | SavedObjectFinderInitialPageSize; -type SavedObjectFinderUiProps = { +export type SavedObjectFinderUiProps = { savedObjects: CoreStart['savedObjects']; uiSettings: CoreStart['uiSettings']; } & SavedObjectFinderProps; diff --git a/src/core/public/saved_objects/saved_object_save_modal.scss b/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.scss similarity index 100% rename from src/core/public/saved_objects/saved_object_save_modal.scss rename to src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.scss diff --git a/src/core/public/saved_objects/saved_object_save_modal.test.tsx b/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.test.tsx similarity index 100% rename from src/core/public/saved_objects/saved_object_save_modal.test.tsx rename to src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.test.tsx diff --git a/src/core/public/saved_objects/saved_object_save_modal.tsx b/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.tsx similarity index 97% rename from src/core/public/saved_objects/saved_object_save_modal.tsx rename to src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.tsx index 3e15ae7fe04d1..cdbc2bb9b5473 100644 --- a/src/core/public/saved_objects/saved_object_save_modal.tsx +++ b/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.tsx @@ -35,11 +35,11 @@ import { EuiSwitchEvent, EuiTextArea, } from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/target/types/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; import { EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../legacy/core_plugins/visualizations/public/embeddable/constants'; // eslint-disable-line @kbn/eslint/no-restricted-paths +import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../../legacy/core_plugins/visualizations/public/embeddable/constants'; export interface OnSaveProps { newTitle: string; diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx index 64400566b437a..8f22e54bac3c1 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx @@ -18,13 +18,7 @@ */ import React from 'react'; import ReactDOM from 'react-dom'; -import { - CoreSetup, - CoreStart, - Plugin, - SavedObjectFinderProps, - SavedObjectFinderUi, -} from 'src/core/public'; +import { CoreSetup, CoreStart, Plugin } from 'src/core/public'; import { IUiActionsStart } from '../../../../../../../src/plugins/ui_actions/public'; import { createHelloWorldAction } from '../../../../../../../src/plugins/ui_actions/public/tests/test_samples'; @@ -43,6 +37,10 @@ import { ContactCardEmbeddableFactory, } from './embeddable_api'; import { App } from './app'; +import { + SavedObjectFinderProps, + SavedObjectFinderUi, +} from '../../../../../../../src/plugins/kibana_react/public/saved_objects'; import { HelloWorldEmbeddableFactory } from '../../../../../../../examples/embeddable_examples/public'; import { IEmbeddableStart, diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx index 94de87c27b7ec..8642ebd901bb4 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx @@ -17,7 +17,10 @@ import { import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; import { EmbeddableExpression } from '../../expression_types/embeddable'; import { RendererStrings } from '../../../i18n'; -import { SavedObjectFinderProps, SavedObjectFinderUi } from '../../../../../../../src/core/public'; +import { + SavedObjectFinderProps, + SavedObjectFinderUi, +} from '../../../../../../../src/plugins/kibana_react/public'; const { embeddable: strings } = RendererStrings; import { embeddableInputToExpression } from './embeddable_input_to_expression'; diff --git a/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx b/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx index 78af478085fd6..786403f2748fa 100644 --- a/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx @@ -7,13 +7,13 @@ import React from 'react'; import { EuiFlyout, EuiFlyoutHeader, EuiFlyoutBody, EuiTitle } from '@elastic/eui'; -import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; -import { ComponentStrings } from '../../../i18n'; import { - CoreStart, SavedObjectFinderUi, SavedObjectMetaData, -} from '../../../../../../../src/core/public'; +} from '../../../../../../../src/plugins/kibana_react/public/saved_objects'; // eslint-disable-line +import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; +import { ComponentStrings } from '../../../i18n'; +import { CoreStart } from '../../../../../../../src/core/public'; const { AddEmbeddableFlyout: strings } = ComponentStrings; diff --git a/x-pack/legacy/plugins/graph/public/app.js b/x-pack/legacy/plugins/graph/public/app.js index 37ceee2445629..d0dbf34abc055 100644 --- a/x-pack/legacy/plugins/graph/public/app.js +++ b/x-pack/legacy/plugins/graph/public/app.js @@ -12,7 +12,7 @@ import { Provider } from 'react-redux'; import { isColorDark, hexToRgb } from '@elastic/eui'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; -import { showSaveModal } from '../../../../../src/core/public'; +import { showSaveModal } from './legacy_imports'; import appTemplate from './angular/templates/index.html'; import listingTemplate from './angular/templates/listing_ng_wrapper.html'; @@ -276,6 +276,7 @@ export function initGraphApp(angularModule, deps) { }, notifications: coreStart.notifications, http: coreStart.http, + showSaveModal, setWorkspaceInitialized: () => { $scope.workspaceInitialized = true; }, diff --git a/x-pack/legacy/plugins/graph/public/components/save_modal.tsx b/x-pack/legacy/plugins/graph/public/components/save_modal.tsx index 56383409078a6..b60a444453f7d 100644 --- a/x-pack/legacy/plugins/graph/public/components/save_modal.tsx +++ b/x-pack/legacy/plugins/graph/public/components/save_modal.tsx @@ -7,7 +7,10 @@ import React, { useState } from 'react'; import { EuiFormRow, EuiTextArea, EuiCallOut, EuiSpacer, EuiSwitch } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { SavedObjectSaveModal, OnSaveProps } from '../../../../../../src/core/public'; +import { + SavedObjectSaveModal, + OnSaveProps, +} from '../../../../../../src/plugins/kibana_react/public'; import { GraphSavePolicy } from '../types/config'; diff --git a/x-pack/legacy/plugins/graph/public/legacy_imports.ts b/x-pack/legacy/plugins/graph/public/legacy_imports.ts index 702c6cb2d4542..7ea2cf6dd901b 100644 --- a/x-pack/legacy/plugins/graph/public/legacy_imports.ts +++ b/x-pack/legacy/plugins/graph/public/legacy_imports.ts @@ -15,4 +15,6 @@ export { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_to export { confirmModalFactory } from 'ui/modals/confirm_modal'; // @ts-ignore export { addAppRedirectMessageToUrl } from 'ui/notify'; +export { SaveResult } from 'ui/saved_objects/show_saved_object_save_modal'; export { createSavedObjectClass } from 'ui/saved_objects/saved_object'; +export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; diff --git a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx index cabb20941ca1d..d949ac1d4a600 100644 --- a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx +++ b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx @@ -5,9 +5,9 @@ */ import React from 'react'; -import { showSaveModal, SaveResult } from '../../../../../../src/core/public'; import { GraphWorkspaceSavedObject, GraphSavePolicy } from '../types'; import { SaveModal, OnSaveGraphProps } from '../components/save_modal'; +import { SaveResult } from '../legacy_imports'; export type SaveWorkspaceHandler = ( saveOptions: { @@ -23,11 +23,13 @@ export function openSaveModal({ hasData, workspace, saveWorkspace, + showSaveModal, }: { savePolicy: GraphSavePolicy; hasData: boolean; workspace: GraphWorkspaceSavedObject; saveWorkspace: SaveWorkspaceHandler; + showSaveModal: (el: React.ReactNode) => void; }) { const currentTitle = workspace.title; const currentDescription = workspace.description; diff --git a/x-pack/legacy/plugins/graph/public/state_management/mocks.ts b/x-pack/legacy/plugins/graph/public/state_management/mocks.ts index 518569fc23091..5a4f0d033aa42 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/mocks.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/mocks.ts @@ -72,6 +72,7 @@ export function createMockGraphStore({ http: {} as HttpStart, notifyAngular: jest.fn(), savePolicy: 'configAndData', + showSaveModal: jest.fn(), setLiveResponseFields: jest.fn(), setUrlTemplates: jest.fn(), setWorkspaceInitialized: jest.fn(), diff --git a/x-pack/legacy/plugins/graph/public/state_management/persistence.ts b/x-pack/legacy/plugins/graph/public/state_management/persistence.ts index a7d8a2ca23d11..0bc7827358b81 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/persistence.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/persistence.ts @@ -197,6 +197,7 @@ function showModal( savePolicy: deps.savePolicy, hasData: workspace.nodes.length > 0 || workspace.blacklistedNodes.length > 0, workspace: savedWorkspace, + showSaveModal: deps.showSaveModal, saveWorkspace: saveWorkspaceHandler, }); } diff --git a/x-pack/legacy/plugins/graph/public/state_management/store.ts b/x-pack/legacy/plugins/graph/public/state_management/store.ts index 4ae0a375dbce2..bb01f20196f87 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/store.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/store.ts @@ -54,6 +54,7 @@ export interface GraphStoreDependencies { getSavedWorkspace: () => GraphWorkspaceSavedObject; notifications: CoreStart['notifications']; http: CoreStart['http']; + showSaveModal: (el: React.ReactNode) => void; savePolicy: GraphSavePolicy; changeUrl: (newUrl: string) => void; notifyAngular: () => void; diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index 0bc8a82c4a96c..35e45af6a3d68 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx @@ -9,11 +9,12 @@ import React, { useState, useEffect, useCallback } from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { Query, DataPublicPluginStart } from 'src/plugins/data/public'; +import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; import { AppMountContext, NotificationsStart } from 'src/core/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { npStart } from 'ui/new_platform'; import { FormattedMessage } from '@kbn/i18n/react'; -import { KibanaContextProvider, SavedObjectSaveModal } from '../../../../../../src/core/public'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { Document, SavedObjectStore } from '../persistence'; import { EditorFrameInstance } from '../types'; import { NativeRenderer } from '../native_renderer'; 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 d700bda840554..5f058e2ba7806 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -45,6 +45,8 @@ import { import { getInspectorAdapters } from '../reducers/non_serializable_instances'; import { docTitle } from 'ui/doc_title'; 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'; import { getInitialLayers } from './get_initial_layers'; import { getInitialQuery } from './get_initial_query'; @@ -53,7 +55,6 @@ import { getInitialRefreshConfig } from './get_initial_refresh_config'; import { MAP_SAVED_OBJECT_TYPE, MAP_APP_PATH } from '../../common/constants'; import { npStart } from 'ui/new_platform'; import { esFilters } from '../../../../../../src/plugins/data/public'; -import { showSaveModal, SavedObjectSaveModal } from '../../../../../../src/core/public'; const savedQueryService = npStart.plugins.data.query.savedQueries; diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx index 305e8061e73bc..cbbb4f8c6249e 100644 --- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx +++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx @@ -25,7 +25,10 @@ import * as i18n from './translations'; import { MapEmbeddable, SetQuery } from './types'; import { Query, esFilters } from '../../../../../../../src/plugins/data/public'; import { useKibana, useUiSetting$ } from '../../lib/kibana'; -import { SavedObjectFinder } from '../../../../../../../src/core/public'; +import { + SavedObjectFinderProps, + SavedObjectFinderUi, +} from '../../../../../../../src/plugins/kibana_react/public'; interface EmbeddableMapProps { maintainRatio?: boolean; @@ -174,6 +177,14 @@ export const EmbeddedMapComponent = ({ } }, [startDate, endDate]); + const SavedObjectFinder = (props: SavedObjectFinderProps) => ( + + ); + return isError ? null : ( From b4e2c565d9882583cb50bbfdd3b8a596d7ee15f8 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Thu, 30 Jan 2020 11:48:11 +0300 Subject: [PATCH 05/18] Move save_object_save_modal --- .../kibana/public/dashboard/legacy_imports.ts | 1 - .../dashboard/np_ready/top_nav/save_modal.tsx | 2 +- .../kibana/public/discover/kibana_services.ts | 1 - .../discover/np_ready/angular/discover.js | 2 +- .../kibana/public/visualize/legacy_imports.ts | 1 - .../visualize/np_ready/editor/editor.js | 2 +- src/legacy/ui/public/_index.scss | 1 - .../ui/public/saved_objects/_index.scss | 1 - .../public/saved_objects/index.ts | 1 - .../saved_objects/public/index.ts} | 7 +------ .../saved_object_save_modal.test.tsx.snap | 0 .../public/save_modal}/_index.scss | 0 .../saved_objects/public/save_modal/index.ts | 20 +++++++++++++++++++ .../save_modal}/saved_object_save_modal.scss | 0 .../saved_object_save_modal.test.tsx | 0 .../save_modal}/saved_object_save_modal.tsx | 0 .../graph/public/components/save_modal.tsx | 2 +- .../plugins/lens/public/app_plugin/app.tsx | 2 +- .../maps/public/angular/map_controller.js | 2 +- 19 files changed, 27 insertions(+), 18 deletions(-) delete mode 100644 src/legacy/ui/public/saved_objects/_index.scss rename src/{legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx => plugins/saved_objects/public/index.ts} (80%) rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public/save_modal}/__snapshots__/saved_object_save_modal.test.tsx.snap (100%) rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public/save_modal}/_index.scss (100%) create mode 100644 src/plugins/saved_objects/public/save_modal/index.ts rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public/save_modal}/saved_object_save_modal.scss (100%) rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public/save_modal}/saved_object_save_modal.test.tsx (100%) rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public/save_modal}/saved_object_save_modal.tsx (100%) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts index 97d165b6b5c23..d0e35207e5ba2 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts @@ -30,7 +30,6 @@ export const legacyChrome = chrome; export { SavedObjectSaveOpts } from 'ui/saved_objects/types'; export { npSetup, npStart } from 'ui/new_platform'; export { IPrivate } from 'ui/private'; -export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; // @ts-ignore export { ConfirmationButtonTypes } from 'ui/modals/confirm_modal'; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx index bd53fd5a13083..026784fcae06f 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.tsx @@ -21,7 +21,7 @@ import React, { Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFormRow, EuiTextArea, EuiSwitch } from '@elastic/eui'; -import { SavedObjectSaveModal } from '../../legacy_imports'; +import { SavedObjectSaveModal } from '../../../../../../../plugins/saved_objects/public'; interface SaveOptions { newTitle: string; 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 9a0b0731b6b11..8e2d26010d12d 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -62,7 +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'; -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'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; 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 5e99cab1b3297..cf314870e83f1 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 @@ -26,6 +26,7 @@ import { i18n } from '@kbn/i18n'; import '../components/field_chooser/field_chooser'; import { RequestAdapter } from '../../../../../../../plugins/inspector/public'; +import { SavedObjectSaveModal } from '../../../../../../../plugins/saved_objects/public'; // doc table import './doc_table'; import { getSort } from './doc_table/lib/get_sort'; @@ -52,7 +53,6 @@ import { stateMonitorFactory, subscribeWithScope, tabifyAggResponse, - SavedObjectSaveModal, getAngularModule, ensureDefaultIndexPattern, registerTimefilterWithGlobalStateFactory, diff --git a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts index b185dc577a3aa..459a75ba674f2 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts @@ -44,7 +44,6 @@ export { IPrivate } from 'ui/private'; // @ts-ignore export { PrivateProvider } from 'ui/private/private'; -export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js index 96a583bec7dc9..b920c65baa3df 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js @@ -31,6 +31,7 @@ import { getEditBreadcrumbs } from '../breadcrumbs'; import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util'; import { FilterStateManager } from '../../../../../data/public'; import { unhashUrl } from '../../../../../../../plugins/kibana_utils/public'; +import { SavedObjectSaveModal } from '../../../../../../../plugins/saved_objects/public'; import { initVisEditorDirective } from './visualization_editor'; import { initVisualizationDirective } from './visualization'; @@ -40,7 +41,6 @@ import { absoluteToParsedUrl, KibanaParsedUrl, migrateLegacyQuery, - SavedObjectSaveModal, showSaveModal, stateMonitorFactory, DashboardConstants, diff --git a/src/legacy/ui/public/_index.scss b/src/legacy/ui/public/_index.scss index e4e58019dda69..3934e4dc41323 100644 --- a/src/legacy/ui/public/_index.scss +++ b/src/legacy/ui/public/_index.scss @@ -16,7 +16,6 @@ @import './error_url_overflow/index'; @import './exit_full_screen/index'; @import './field_editor/index'; -@import './saved_objects/index'; @import './share/index'; @import './style_compile/index'; @import '../../../plugins/management/public/components/index'; diff --git a/src/legacy/ui/public/saved_objects/_index.scss b/src/legacy/ui/public/saved_objects/_index.scss deleted file mode 100644 index 50a192b6a7b17..0000000000000 --- a/src/legacy/ui/public/saved_objects/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import '../../../../plugins/kibana_react/public/saved_objects/index'; diff --git a/src/plugins/kibana_react/public/saved_objects/index.ts b/src/plugins/kibana_react/public/saved_objects/index.ts index ade80d2cd2a92..bb804a84fff45 100644 --- a/src/plugins/kibana_react/public/saved_objects/index.ts +++ b/src/plugins/kibana_react/public/saved_objects/index.ts @@ -18,4 +18,3 @@ */ export * from './saved_object_finder'; -export * from './saved_object_save_modal'; diff --git a/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx b/src/plugins/saved_objects/public/index.ts similarity index 80% rename from src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx rename to src/plugins/saved_objects/public/index.ts index 131f28059cebd..cdcca6ab5c160 100644 --- a/src/legacy/ui/public/saved_objects/components/saved_object_save_modal.tsx +++ b/src/plugins/saved_objects/public/index.ts @@ -17,9 +17,4 @@ * under the License. */ -/** - * @deprecated - * - * Do not import this component from here. Import from `src/plugins/kibana_react` instead. - */ -export { SavedObjectSaveModal } from '../../../../../plugins/kibana_react/public'; +export * from './save_modal'; diff --git a/src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap b/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap similarity index 100% rename from src/plugins/kibana_react/public/saved_objects/__snapshots__/saved_object_save_modal.test.tsx.snap rename to src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap diff --git a/src/plugins/kibana_react/public/saved_objects/_index.scss b/src/plugins/saved_objects/public/save_modal/_index.scss similarity index 100% rename from src/plugins/kibana_react/public/saved_objects/_index.scss rename to src/plugins/saved_objects/public/save_modal/_index.scss diff --git a/src/plugins/saved_objects/public/save_modal/index.ts b/src/plugins/saved_objects/public/save_modal/index.ts new file mode 100644 index 0000000000000..0e9b7c6b3b0e7 --- /dev/null +++ b/src/plugins/saved_objects/public/save_modal/index.ts @@ -0,0 +1,20 @@ +/* + * 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 { SavedObjectSaveModal, OnSaveProps } from './saved_object_save_modal'; diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.scss b/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.scss similarity index 100% rename from src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.scss rename to src/plugins/saved_objects/public/save_modal/saved_object_save_modal.scss diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.test.tsx b/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.test.tsx similarity index 100% rename from src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.test.tsx rename to src/plugins/saved_objects/public/save_modal/saved_object_save_modal.test.tsx diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.tsx b/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx similarity index 100% rename from src/plugins/kibana_react/public/saved_objects/saved_object_save_modal.tsx rename to src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx diff --git a/x-pack/legacy/plugins/graph/public/components/save_modal.tsx b/x-pack/legacy/plugins/graph/public/components/save_modal.tsx index b60a444453f7d..3dede69d0ca93 100644 --- a/x-pack/legacy/plugins/graph/public/components/save_modal.tsx +++ b/x-pack/legacy/plugins/graph/public/components/save_modal.tsx @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { SavedObjectSaveModal, OnSaveProps, -} from '../../../../../../src/plugins/kibana_react/public'; +} from '../../../../../../src/plugins/saved_objects/public'; import { GraphSavePolicy } from '../types/config'; diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index 35e45af6a3d68..1cbfbc59c7b00 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx @@ -9,12 +9,12 @@ import React, { useState, useEffect, useCallback } from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { Query, DataPublicPluginStart } from 'src/plugins/data/public'; -import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; import { AppMountContext, NotificationsStart } from 'src/core/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { npStart } from 'ui/new_platform'; import { FormattedMessage } from '@kbn/i18n/react'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { SavedObjectSaveModal } from '../../../../../../src/plugins/saved_objects/public'; import { Document, SavedObjectStore } from '../persistence'; import { EditorFrameInstance } from '../types'; import { NativeRenderer } from '../native_renderer'; 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 5f058e2ba7806..ae21e65b76ff9 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -45,7 +45,6 @@ import { import { getInspectorAdapters } from '../reducers/non_serializable_instances'; import { docTitle } from 'ui/doc_title'; 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'; import { getInitialLayers } from './get_initial_layers'; @@ -55,6 +54,7 @@ import { getInitialRefreshConfig } from './get_initial_refresh_config'; import { MAP_SAVED_OBJECT_TYPE, MAP_APP_PATH } from '../../common/constants'; import { npStart } from 'ui/new_platform'; import { esFilters } from '../../../../../../src/plugins/data/public'; +import { SavedObjectSaveModal } from '../../../../../../src/plugins/saved_objects/public'; const savedQueryService = npStart.plugins.data.query.savedQueries; From e9ff0e93210d437451fb2ca74baaac351a07aa6e Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Thu, 30 Jan 2020 15:00:59 +0300 Subject: [PATCH 06/18] Move show_saved_object_save_modal.tsx --- .../kibana/public/dashboard/legacy_imports.ts | 1 - .../np_ready/dashboard_app_controller.tsx | 16 ++++++++++++---- .../np_ready/top_nav/save_modal.test.js | 2 +- .../kibana/public/discover/kibana_services.ts | 1 - .../public/discover/np_ready/angular/discover.js | 8 +++++--- .../kibana/public/visualize/legacy_imports.ts | 2 -- .../public/visualize/np_ready/editor/editor.js | 6 ++++-- .../saved_objects/public/save_modal/index.ts | 1 + .../save_modal}/show_saved_object_save_modal.tsx | 10 +++++++--- x-pack/legacy/plugins/graph/public/app.js | 3 ++- .../plugins/graph/public/legacy_imports.ts | 2 -- .../plugins/graph/public/services/save_modal.tsx | 10 +++++++--- .../graph/public/state_management/mocks.ts | 3 +++ .../graph/public/state_management/persistence.ts | 1 + .../graph/public/state_management/store.ts | 5 +++-- .../maps/public/angular/map_controller.js | 8 +++++--- 16 files changed, 51 insertions(+), 28 deletions(-) rename src/{legacy/ui/public/saved_objects => plugins/saved_objects/public/save_modal}/show_saved_object_save_modal.tsx (91%) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts index d0e35207e5ba2..a0efb166c3203 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts @@ -33,7 +33,6 @@ export { IPrivate } from 'ui/private'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; // @ts-ignore export { ConfirmationButtonTypes } from 'ui/modals/confirm_modal'; -export { showSaveModal, SaveResult } from 'ui/saved_objects/show_saved_object_save_modal'; export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; export { KbnUrl } from 'ui/url/kbn_url'; // @ts-ignore diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx index e85054cd7fb34..e8a906a9417f2 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx @@ -30,8 +30,6 @@ import { ConfirmationButtonTypes, migrateLegacyQuery, SavedObjectSaveOpts, - SaveResult, - showSaveModal, subscribeWithScope, } from '../legacy_imports'; import { @@ -44,6 +42,7 @@ import { syncAppFilters, syncQuery, } from '../../../../../../plugins/data/public'; +import { SaveResult, showSaveModal } from '../../../../../../plugins/saved_objects/public'; import { DASHBOARD_CONTAINER_TYPE, @@ -109,7 +108,16 @@ export class DashboardAppController { share, dashboardCapabilities, npDataStart: { query: queryService }, - core: { notifications, overlays, chrome, injectedMetadata, uiSettings, savedObjects, http }, + core: { + notifications, + overlays, + chrome, + injectedMetadata, + uiSettings, + savedObjects, + http, + i18n: i18nStart, + }, history, kbnUrlStateStorage, }: DashboardAppControllerDependencies) { @@ -772,7 +780,7 @@ export class DashboardAppController { showCopyOnSave={dash.id ? true : false} /> ); - showSaveModal(dashboardSaveModal); + showSaveModal(dashboardSaveModal, i18nStart.Context); }; navActions[TopNavIds.CLONE] = () => { const currentTitle = dashboardStateManager.getTitle(); diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js index 5f708a22fd530..e3933ce9d0143 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/top_nav/save_modal.test.js @@ -20,7 +20,7 @@ import React from 'react'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; -jest.mock('../../legacy_imports', () => ({ +jest.mock('../../../../../../../plugins/saved_objects/public', () => ({ SavedObjectSaveModal: () => null, })); 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 8e2d26010d12d..f70b8de08f144 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -62,7 +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'; -export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory'; export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; // @ts-ignore 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 cf314870e83f1..f80ee7b3c30b3 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 @@ -26,7 +26,10 @@ import { i18n } from '@kbn/i18n'; import '../components/field_chooser/field_chooser'; import { RequestAdapter } from '../../../../../../../plugins/inspector/public'; -import { SavedObjectSaveModal } from '../../../../../../../plugins/saved_objects/public'; +import { + SavedObjectSaveModal, + showSaveModal, +} from '../../../../../../../plugins/saved_objects/public'; // doc table import './doc_table'; import { getSort } from './doc_table/lib/get_sort'; @@ -48,7 +51,6 @@ import { hasSearchStategyForIndexPattern, intervalOptions, migrateLegacyQuery, - showSaveModal, unhashUrl, stateMonitorFactory, subscribeWithScope, @@ -310,7 +312,7 @@ function discoverController( })} /> ); - showSaveModal(saveModal); + showSaveModal(saveModal, core.i18n.Context); }, }; diff --git a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts index 459a75ba674f2..bb24870c5a5f3 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts @@ -44,8 +44,6 @@ export { IPrivate } from 'ui/private'; // @ts-ignore export { PrivateProvider } from 'ui/private/private'; -export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; - export { subscribeWithScope } from 'ui/utils/subscribe_with_scope'; export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; // @ts-ignore diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js index b920c65baa3df..adee5e3dfed01 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js @@ -31,7 +31,10 @@ import { getEditBreadcrumbs } from '../breadcrumbs'; import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util'; import { FilterStateManager } from '../../../../../data/public'; import { unhashUrl } from '../../../../../../../plugins/kibana_utils/public'; -import { SavedObjectSaveModal } from '../../../../../../../plugins/saved_objects/public'; +import { + SavedObjectSaveModal, + showSaveModal, +} from '../../../../../../../plugins/saved_objects/public'; import { initVisEditorDirective } from './visualization_editor'; import { initVisualizationDirective } from './visualization'; @@ -41,7 +44,6 @@ import { absoluteToParsedUrl, KibanaParsedUrl, migrateLegacyQuery, - showSaveModal, stateMonitorFactory, DashboardConstants, } from '../../legacy_imports'; diff --git a/src/plugins/saved_objects/public/save_modal/index.ts b/src/plugins/saved_objects/public/save_modal/index.ts index 0e9b7c6b3b0e7..f26aa732f30a1 100644 --- a/src/plugins/saved_objects/public/save_modal/index.ts +++ b/src/plugins/saved_objects/public/save_modal/index.ts @@ -18,3 +18,4 @@ */ export { SavedObjectSaveModal, OnSaveProps } from './saved_object_save_modal'; +export { showSaveModal, SaveResult } from './show_saved_object_save_modal'; diff --git a/src/legacy/ui/public/saved_objects/show_saved_object_save_modal.tsx b/src/plugins/saved_objects/public/save_modal/show_saved_object_save_modal.tsx similarity index 91% rename from src/legacy/ui/public/saved_objects/show_saved_object_save_modal.tsx rename to src/plugins/saved_objects/public/save_modal/show_saved_object_save_modal.tsx index 3c691c692948a..632291be9f069 100644 --- a/src/legacy/ui/public/saved_objects/show_saved_object_save_modal.tsx +++ b/src/plugins/saved_objects/public/save_modal/show_saved_object_save_modal.tsx @@ -19,7 +19,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { I18nContext } from 'ui/i18n'; + +import { I18nStart } from 'src/core/public'; /** * Represents the result of trying to persist the saved object. @@ -34,12 +35,15 @@ function isSuccess(result: SaveResult): result is { id?: string } { return 'id' in result; } -export interface MinimalSaveModalProps { +interface MinimalSaveModalProps { onSave: (...args: any[]) => Promise; onClose: () => void; } -export function showSaveModal(saveModal: React.ReactElement) { +export function showSaveModal( + saveModal: React.ReactElement, + I18nContext: I18nStart['Context'] +) { const container = document.createElement('div'); const closeModal = () => { ReactDOM.unmountComponentAtNode(container); diff --git a/x-pack/legacy/plugins/graph/public/app.js b/x-pack/legacy/plugins/graph/public/app.js index d0dbf34abc055..38a601daa178e 100644 --- a/x-pack/legacy/plugins/graph/public/app.js +++ b/x-pack/legacy/plugins/graph/public/app.js @@ -12,7 +12,7 @@ import { Provider } from 'react-redux'; import { isColorDark, hexToRgb } from '@elastic/eui'; import { toMountPoint } from '../../../../../src/plugins/kibana_react/public'; -import { showSaveModal } from './legacy_imports'; +import { showSaveModal } from '../../../../../src/plugins/saved_objects/public'; import appTemplate from './angular/templates/index.html'; import listingTemplate from './angular/templates/listing_ng_wrapper.html'; @@ -290,6 +290,7 @@ export function initGraphApp(angularModule, deps) { $scope.$digest(); }, chrome, + I18nContext: coreStart.i18n.Context, }); // register things on scope passed down to react components diff --git a/x-pack/legacy/plugins/graph/public/legacy_imports.ts b/x-pack/legacy/plugins/graph/public/legacy_imports.ts index 7ea2cf6dd901b..702c6cb2d4542 100644 --- a/x-pack/legacy/plugins/graph/public/legacy_imports.ts +++ b/x-pack/legacy/plugins/graph/public/legacy_imports.ts @@ -15,6 +15,4 @@ export { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_to export { confirmModalFactory } from 'ui/modals/confirm_modal'; // @ts-ignore export { addAppRedirectMessageToUrl } from 'ui/notify'; -export { SaveResult } from 'ui/saved_objects/show_saved_object_save_modal'; export { createSavedObjectClass } from 'ui/saved_objects/saved_object'; -export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; diff --git a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx index d949ac1d4a600..127ff6a2b4c37 100644 --- a/x-pack/legacy/plugins/graph/public/services/save_modal.tsx +++ b/x-pack/legacy/plugins/graph/public/services/save_modal.tsx @@ -5,9 +5,10 @@ */ import React from 'react'; +import { I18nStart } from 'src/core/public'; +import { SaveResult } from 'src/plugins/saved_objects/public'; import { GraphWorkspaceSavedObject, GraphSavePolicy } from '../types'; import { SaveModal, OnSaveGraphProps } from '../components/save_modal'; -import { SaveResult } from '../legacy_imports'; export type SaveWorkspaceHandler = ( saveOptions: { @@ -24,12 +25,14 @@ export function openSaveModal({ workspace, saveWorkspace, showSaveModal, + I18nContext, }: { savePolicy: GraphSavePolicy; hasData: boolean; workspace: GraphWorkspaceSavedObject; saveWorkspace: SaveWorkspaceHandler; - showSaveModal: (el: React.ReactNode) => void; + showSaveModal: (el: React.ReactNode, I18nContext: I18nStart['Context']) => void; + I18nContext: I18nStart['Context']; }) { const currentTitle = workspace.title; const currentDescription = workspace.description; @@ -67,6 +70,7 @@ export function openSaveModal({ title={workspace.title} description={workspace.description} showCopyOnSave={Boolean(workspace.id)} - /> + />, + I18nContext ); } diff --git a/x-pack/legacy/plugins/graph/public/state_management/mocks.ts b/x-pack/legacy/plugins/graph/public/state_management/mocks.ts index 5a4f0d033aa42..01d6927b9b886 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/mocks.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/mocks.ts @@ -63,6 +63,9 @@ export function createMockGraphStore({ indexPatterns: [ ({ id: '123', attributes: { title: 'test-pattern' } } as unknown) as IndexPatternSavedObject, ], + I18nContext: jest + .fn() + .mockImplementation(({ children }: { children: React.ReactNode }) => children), notifications: ({ toasts: { addDanger: jest.fn(), diff --git a/x-pack/legacy/plugins/graph/public/state_management/persistence.ts b/x-pack/legacy/plugins/graph/public/state_management/persistence.ts index 0bc7827358b81..0f72186af031f 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/persistence.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/persistence.ts @@ -199,5 +199,6 @@ function showModal( workspace: savedWorkspace, showSaveModal: deps.showSaveModal, saveWorkspace: saveWorkspaceHandler, + I18nContext: deps.I18nContext, }); } diff --git a/x-pack/legacy/plugins/graph/public/state_management/store.ts b/x-pack/legacy/plugins/graph/public/state_management/store.ts index bb01f20196f87..ecb7335fee5aa 100644 --- a/x-pack/legacy/plugins/graph/public/state_management/store.ts +++ b/x-pack/legacy/plugins/graph/public/state_management/store.ts @@ -6,7 +6,7 @@ import createSagaMiddleware, { SagaMiddleware } from 'redux-saga'; import { combineReducers, createStore, Store, AnyAction, Dispatch, applyMiddleware } from 'redux'; -import { ChromeStart } from 'kibana/public'; +import { ChromeStart, I18nStart } from 'kibana/public'; import { CoreStart } from 'src/core/public'; import { fieldsReducer, @@ -54,7 +54,7 @@ export interface GraphStoreDependencies { getSavedWorkspace: () => GraphWorkspaceSavedObject; notifications: CoreStart['notifications']; http: CoreStart['http']; - showSaveModal: (el: React.ReactNode) => void; + showSaveModal: (el: React.ReactNode, I18nContext: I18nStart['Context']) => void; savePolicy: GraphSavePolicy; changeUrl: (newUrl: string) => void; notifyAngular: () => void; @@ -62,6 +62,7 @@ export interface GraphStoreDependencies { setUrlTemplates: (templates: UrlTemplate[]) => void; setWorkspaceInitialized: () => void; chrome: ChromeStart; + I18nContext: I18nStart['Context']; } export function createRootReducer(basePath: string) { 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 ae21e65b76ff9..810c4220c96c5 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -45,7 +45,6 @@ import { import { getInspectorAdapters } from '../reducers/non_serializable_instances'; import { docTitle } from 'ui/doc_title'; import { indexPatternService, getInspector } from '../kibana_services'; -import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal'; import { toastNotifications } from 'ui/notify'; import { getInitialLayers } from './get_initial_layers'; import { getInitialQuery } from './get_initial_query'; @@ -54,7 +53,10 @@ import { getInitialRefreshConfig } from './get_initial_refresh_config'; import { MAP_SAVED_OBJECT_TYPE, MAP_APP_PATH } from '../../common/constants'; import { npStart } from 'ui/new_platform'; import { esFilters } from '../../../../../../src/plugins/data/public'; -import { SavedObjectSaveModal } from '../../../../../../src/plugins/saved_objects/public'; +import { + SavedObjectSaveModal, + showSaveModal, +} from '../../../../../../src/plugins/saved_objects/public'; const savedQueryService = npStart.plugins.data.query.savedQueries; @@ -566,7 +568,7 @@ app.controller( objectType={MAP_SAVED_OBJECT_TYPE} /> ); - showSaveModal(saveModal); + showSaveModal(saveModal, npStart.i18n.Context); }, }, ] From 3b365d1bcb4da90399263e6386df43fc8e14fead Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Thu, 30 Jan 2020 16:38:24 +0300 Subject: [PATCH 07/18] Move save_object_finder.tsx --- .../np_ready/dashboard_app_controller.tsx | 16 +++++-------- .../components/top_nav/open_search_panel.js | 2 +- .../search_selection/search_selection.tsx | 2 +- .../dashboard_container_factory.tsx | 2 +- .../public/plugin.tsx | 14 ++--------- .../public/types.ts | 9 -------- src/plugins/embeddable/public/index.ts | 1 - .../lib/embeddables/embeddable_factory.ts | 4 ++-- src/plugins/embeddable/public/lib/types.ts | 11 --------- src/plugins/kibana_react/public/index.ts | 1 - .../public/saved_objects/index.ts | 20 ---------------- src/plugins/saved_objects/public/index.ts | 6 +++++ .../public}/saved_object_finder.test.tsx | 3 +-- .../public}/saved_object_finder.tsx | 23 +++++++++---------- .../public/np_ready/public/plugin.tsx | 14 ++--------- .../renderers/embeddable/embeddable.tsx | 17 ++++---------- .../components/embeddable_flyout/flyout.tsx | 2 +- .../graph/public/components/source_picker.tsx | 2 +- .../new_job/pages/index_or_search/page.tsx | 2 +- .../components/embeddables/embedded_map.tsx | 15 ++---------- .../search_selection/search_selection.tsx | 2 +- 21 files changed, 44 insertions(+), 124 deletions(-) delete mode 100644 src/plugins/kibana_react/public/saved_objects/index.ts rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public}/saved_object_finder.test.tsx (99%) rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public}/saved_object_finder.tsx (97%) diff --git a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx index e8a906a9417f2..0787627f29bb3 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/np_ready/dashboard_app_controller.tsx @@ -42,7 +42,11 @@ import { syncAppFilters, syncQuery, } from '../../../../../../plugins/data/public'; -import { SaveResult, showSaveModal } from '../../../../../../plugins/saved_objects/public'; +import { + SaveResult, + showSaveModal, + getSavedObjectFinder, +} from '../../../../../../plugins/saved_objects/public'; import { DASHBOARD_CONTAINER_TYPE, @@ -72,10 +76,6 @@ import { getDashboardTitle } from './dashboard_strings'; import { DashboardAppScope } from './dashboard_app'; import { convertSavedDashboardPanelToPanelState } from './lib/embeddable_saved_object_converters'; import { RenderDeps } from './application'; -import { - SavedObjectFinderProps, - SavedObjectFinderUi, -} from '../../../../../../plugins/kibana_react/public'; import { removeQueryParam, unhashUrl } from '../../../../../../plugins/kibana_utils/public'; export interface DashboardAppControllerDependencies extends RenderDeps { @@ -809,17 +809,13 @@ export class DashboardAppController { }; navActions[TopNavIds.ADD] = () => { if (dashboardContainer && !isErrorEmbeddable(dashboardContainer)) { - const SavedObjectFinder = (props: SavedObjectFinderProps) => ( - - ); - openAddPanelFlyout({ embeddable: dashboardContainer, getAllFactories: embeddables.getEmbeddableFactories, getFactory: embeddables.getEmbeddableFactory, notifications, overlays, - SavedObjectFinder, + SavedObjectFinder: getSavedObjectFinder(savedObjects, uiSettings), }); } }; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/top_nav/open_search_panel.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/top_nav/open_search_panel.js index ebe4cbb1ddb69..747dd9abe2f2a 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/top_nav/open_search_panel.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/top_nav/open_search_panel.js @@ -32,7 +32,7 @@ import { EuiFlyoutBody, EuiTitle, } from '@elastic/eui'; -import { SavedObjectFinderUi } from '../../../../../../../../plugins/kibana_react/public'; +import { SavedObjectFinderUi } from '../../../../../../../../plugins/saved_objects/public'; import { getServices } from '../../../kibana_services'; const SEARCH_OBJECT_TYPE = 'search'; diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/search_selection/search_selection.tsx b/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/search_selection/search_selection.tsx index 5cab85c11c3c7..1c94fa4b1e109 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/search_selection/search_selection.tsx +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/wizard/search_selection/search_selection.tsx @@ -23,7 +23,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; import { IUiSettingsClient, SavedObjectsStart } from 'kibana/public'; -import { SavedObjectFinderUi } from '../../../../../../../../plugins/kibana_react/public'; +import { SavedObjectFinderUi } from '../../../../../../../../plugins/saved_objects/public'; import { VisType } from '../../../legacy_imports'; interface SearchSelectionProps { diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx index c8a2837fd77d0..c3866e7b26370 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx @@ -18,8 +18,8 @@ */ import { i18n } from '@kbn/i18n'; +import { SavedObjectMetaData } from 'src/plugins/saved_objects/public'; import { SavedObjectAttributes } from '../../../../core/public'; -import { SavedObjectMetaData } from '../types'; import { ContainerOutput, EmbeddableFactory, diff --git a/src/plugins/dashboard_embeddable_container/public/plugin.tsx b/src/plugins/dashboard_embeddable_container/public/plugin.tsx index d18fbba239ec0..f9cdecc4483fc 100644 --- a/src/plugins/dashboard_embeddable_container/public/plugin.tsx +++ b/src/plugins/dashboard_embeddable_container/public/plugin.tsx @@ -26,9 +26,8 @@ import { CONTEXT_MENU_TRIGGER, IEmbeddableSetup, IEmbeddableStart } from './embe import { ExpandPanelAction, ReplacePanelAction } from '.'; import { DashboardContainerFactory } from './embeddable/dashboard_container_factory'; import { Start as InspectorStartContract } from '../../../plugins/inspector/public'; +import { getSavedObjectFinder } from '../../../plugins/saved_objects/public'; import { - SavedObjectFinderUi, - SavedObjectFinderProps, ExitFullScreenButton as ExitFullScreenButtonUi, ExitFullScreenButtonProps, } from '../../../plugins/kibana_react/public'; @@ -61,16 +60,7 @@ export class DashboardEmbeddableContainerPublicPlugin const { application, notifications, overlays } = core; const { embeddable, inspector, uiActions } = plugins; - const SavedObjectFinder: React.FC> = props => ( - - ); + const SavedObjectFinder = getSavedObjectFinder(core.savedObjects, core.uiSettings); const useHideChrome = () => { React.useEffect(() => { diff --git a/src/plugins/dashboard_embeddable_container/public/types.ts b/src/plugins/dashboard_embeddable_container/public/types.ts index 9c2d6c0ab388d..f58be10e11ba6 100644 --- a/src/plugins/dashboard_embeddable_container/public/types.ts +++ b/src/plugins/dashboard_embeddable_container/public/types.ts @@ -17,7 +17,6 @@ * under the License. */ -import { IconType } from '@elastic/eui'; import { SavedObject as SavedObjectType, SavedObjectAttributes } from '../../../core/public'; export interface DashboardCapabilities { @@ -50,14 +49,6 @@ export interface SimpleSavedObject { delete(): void; } -export interface SavedObjectMetaData { - type: string; - name: string; - getIconForSavedObject(savedObject: SimpleSavedObject): IconType; - getTooltipForSavedObject?(savedObject: SimpleSavedObject): string; - showSavedObject?(savedObject: SimpleSavedObject): boolean; -} - interface FieldSubType { multi?: { parent: string }; nested?: { path: string }; diff --git a/src/plugins/embeddable/public/index.ts b/src/plugins/embeddable/public/index.ts index 583b21ddfa433..21bc45c6c0312 100644 --- a/src/plugins/embeddable/public/index.ts +++ b/src/plugins/embeddable/public/index.ts @@ -51,7 +51,6 @@ export { PanelNotFoundError, PanelState, PropertySpec, - SavedObjectMetaData, ViewMode, isErrorEmbeddable, openAddPanelFlyout, diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts index acc2da1514483..4ff52583cbbfb 100644 --- a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts +++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts @@ -18,7 +18,7 @@ */ import { SavedObjectAttributes } from 'src/core/public'; -import { SavedObjectMetaData } from '../types'; +import { SavedObjectMetaData } from 'src/plugins/saved_objects/public'; import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from './i_embeddable'; import { ErrorEmbeddable } from './error_embeddable'; import { IContainer } from '../containers/i_container'; @@ -40,7 +40,7 @@ export interface OutputSpec { [key: string]: PropertySpec; } -export interface EmbeddableFactoryOptions { +export interface EmbeddableFactoryOptions { savedObjectMetaData?: SavedObjectMetaData; } diff --git a/src/plugins/embeddable/public/lib/types.ts b/src/plugins/embeddable/public/lib/types.ts index 5fc01a62351c0..1bd71163db44c 100644 --- a/src/plugins/embeddable/public/lib/types.ts +++ b/src/plugins/embeddable/public/lib/types.ts @@ -42,16 +42,5 @@ export enum ViewMode { export { Adapters }; -// import { SavedObjectMetaData } from 'ui/saved_objects/components/saved_object_finder'; -// TODO: Figure out how to do this import in New Platform. -export interface SavedObjectMetaData { - type: string; - name: string; - getIconForSavedObject(savedObject: any): any; - getTooltipForSavedObject?(savedObject: any): any; - showSavedObject?(savedObject: any): boolean; - includeFields?: string[]; -} - export type GetEmbeddableFactory = (id: string) => EmbeddableFactory | undefined; export type GetEmbeddableFactories = () => IterableIterator; diff --git a/src/plugins/kibana_react/public/index.ts b/src/plugins/kibana_react/public/index.ts index 81f2e694e8e5b..1108da1f778b7 100644 --- a/src/plugins/kibana_react/public/index.ts +++ b/src/plugins/kibana_react/public/index.ts @@ -18,7 +18,6 @@ */ export * from './code_editor'; -export * from './saved_objects'; export * from './exit_full_screen_button'; export * from './context'; export * from './overlays'; diff --git a/src/plugins/kibana_react/public/saved_objects/index.ts b/src/plugins/kibana_react/public/saved_objects/index.ts deleted file mode 100644 index bb804a84fff45..0000000000000 --- a/src/plugins/kibana_react/public/saved_objects/index.ts +++ /dev/null @@ -1,20 +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 * from './saved_object_finder'; diff --git a/src/plugins/saved_objects/public/index.ts b/src/plugins/saved_objects/public/index.ts index cdcca6ab5c160..9fa2f448c64c0 100644 --- a/src/plugins/saved_objects/public/index.ts +++ b/src/plugins/saved_objects/public/index.ts @@ -18,3 +18,9 @@ */ export * from './save_modal'; +export { + SavedObjectMetaData, + SavedObjectFinderProps, + SavedObjectFinderUi, + getSavedObjectFinder, +} from './saved_object_finder'; diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx b/src/plugins/saved_objects/public/saved_object_finder.test.tsx similarity index 99% rename from src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx rename to src/plugins/saved_objects/public/saved_object_finder.test.tsx index 58b396d57639b..a5f18d428ed8f 100644 --- a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx +++ b/src/plugins/saved_objects/public/saved_object_finder.test.tsx @@ -36,8 +36,7 @@ import { shallow } from 'enzyme'; import React from 'react'; import * as sinon from 'sinon'; import { SavedObjectFinderUi as SavedObjectFinder } from './saved_object_finder'; -// eslint-disable-next-line -import { coreMock } from '../../../../core/public/mocks'; +import { coreMock } from '../../../core/public/mocks'; describe('SavedObjectsFinder', () => { const doc = { diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx b/src/plugins/saved_objects/public/saved_object_finder.tsx similarity index 97% rename from src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx rename to src/plugins/saved_objects/public/saved_object_finder.tsx index 2a43f29024ba7..0d883c28f999e 100644 --- a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx +++ b/src/plugins/saved_objects/public/saved_object_finder.tsx @@ -44,9 +44,13 @@ import { import { Direction } from '@elastic/eui/src/services/sort/sort_direction'; import { i18n } from '@kbn/i18n'; -import { SavedObjectAttributes } from '../../../../core/public'; -import { SimpleSavedObject, CoreStart } from '../../../../core/public'; -import { useKibana } from '../context'; +import { + SavedObjectAttributes, + SimpleSavedObject, + CoreStart, + IUiSettingsClient, + SavedObjectsStart, +} from 'src/core/public'; // TODO the typings for EuiListGroup are incorrect - maxWidth is missing. This can be removed when the types are adjusted const FixedEuiListGroup = (EuiListGroup as any) as React.FunctionComponent< @@ -534,15 +538,10 @@ class SavedObjectFinderUi extends React.Component< } } -const SavedObjectFinder = (props: SavedObjectFinderProps) => { - const { services } = useKibana(); - return ( - +const getSavedObjectFinder = (savedObject: SavedObjectsStart, uiSettings: IUiSettingsClient) => { + return (props: SavedObjectFinderProps) => ( + ); }; -export { SavedObjectFinder, SavedObjectFinderUi }; +export { getSavedObjectFinder, SavedObjectFinderUi }; diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx index 8f22e54bac3c1..bdbd0b6dbb490 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/public/np_ready/public/plugin.tsx @@ -37,10 +37,7 @@ import { ContactCardEmbeddableFactory, } from './embeddable_api'; import { App } from './app'; -import { - SavedObjectFinderProps, - SavedObjectFinderUi, -} from '../../../../../../../src/plugins/kibana_react/public/saved_objects'; +import { getSavedObjectFinder } from '../../../../../../../src/plugins/saved_objects/public'; import { HelloWorldEmbeddableFactory } from '../../../../../../../examples/embeddable_examples/public'; import { IEmbeddableStart, @@ -101,13 +98,6 @@ export class EmbeddableExplorerPublicPlugin plugins.__LEGACY.onRenderComplete(() => { const root = document.getElementById(REACT_ROOT_ID); - const SavedObjectFinder = (props: SavedObjectFinderProps) => ( - - ); ReactDOM.render( , root diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx index 8642ebd901bb4..0c48f9794e2b9 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx @@ -17,10 +17,7 @@ import { import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; import { EmbeddableExpression } from '../../expression_types/embeddable'; import { RendererStrings } from '../../../i18n'; -import { - SavedObjectFinderProps, - SavedObjectFinderUi, -} from '../../../../../../../src/plugins/kibana_react/public'; +import { getSavedObjectFinder } from '../../../../../../../src/plugins/saved_objects/public'; const { embeddable: strings } = RendererStrings; import { embeddableInputToExpression } from './embeddable_input_to_expression'; @@ -32,13 +29,6 @@ const embeddablesRegistry: { } = {}; const renderEmbeddable = (embeddableObject: IEmbeddable, domNode: HTMLElement) => { - const SavedObjectFinder = (props: SavedObjectFinderProps) => ( - - ); return (
diff --git a/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx b/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx index 786403f2748fa..576c7c4794b08 100644 --- a/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/embeddable_flyout/flyout.tsx @@ -10,7 +10,7 @@ import { EuiFlyout, EuiFlyoutHeader, EuiFlyoutBody, EuiTitle } from '@elastic/eu import { SavedObjectFinderUi, SavedObjectMetaData, -} from '../../../../../../../src/plugins/kibana_react/public/saved_objects'; // eslint-disable-line +} from '../../../../../../../src/plugins/saved_objects/public/'; import { start } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy'; import { ComponentStrings } from '../../../i18n'; import { CoreStart } from '../../../../../../../src/core/public'; diff --git a/x-pack/legacy/plugins/graph/public/components/source_picker.tsx b/x-pack/legacy/plugins/graph/public/components/source_picker.tsx index de920af8a48a5..65a431202fc98 100644 --- a/x-pack/legacy/plugins/graph/public/components/source_picker.tsx +++ b/x-pack/legacy/plugins/graph/public/components/source_picker.tsx @@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n'; import React from 'react'; import { CoreStart } from 'src/core/public'; -import { SavedObjectFinderUi } from '../../../../../../src/plugins/kibana_react/public'; +import { SavedObjectFinderUi } from '../../../../../../src/plugins/saved_objects/public'; import { IndexPatternSavedObject } from '../types'; export interface SourcePickerProps { diff --git a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx index cb311f04dd1d7..2fbedc1cd39bb 100644 --- a/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx +++ b/x-pack/legacy/plugins/ml/public/application/jobs/new_job/pages/index_or_search/page.tsx @@ -16,7 +16,7 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { npStart } from 'ui/new_platform'; -import { SavedObjectFinderUi } from '../../../../../../../../../../src/plugins/kibana_react/public'; +import { SavedObjectFinderUi } from '../../../../../../../../../../src/plugins/saved_objects/public'; export interface PageProps { nextStepPath: string; diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx index cbbb4f8c6249e..b1b47f7c6b775 100644 --- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx +++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx @@ -25,10 +25,7 @@ import * as i18n from './translations'; import { MapEmbeddable, SetQuery } from './types'; import { Query, esFilters } from '../../../../../../../src/plugins/data/public'; import { useKibana, useUiSetting$ } from '../../lib/kibana'; -import { - SavedObjectFinderProps, - SavedObjectFinderUi, -} from '../../../../../../../src/plugins/kibana_react/public'; +import { getSavedObjectFinder } from '../../../../../../../src/plugins/saved_objects/public'; interface EmbeddableMapProps { maintainRatio?: boolean; @@ -177,14 +174,6 @@ export const EmbeddedMapComponent = ({ } }, [startDate, endDate]); - const SavedObjectFinder = (props: SavedObjectFinderProps) => ( - - ); - return isError ? null : ( @@ -213,7 +202,7 @@ export const EmbeddedMapComponent = ({ notifications={services.notifications} overlays={services.overlays} inspector={services.inspector} - SavedObjectFinder={SavedObjectFinder} + SavedObjectFinder={getSavedObjectFinder(services.savedObjects, services.uiSettings)} /> ) : !isLoading && isIndexError ? ( diff --git a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx b/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx index 368c5aa806fe8..ff8bb7e2f432d 100644 --- a/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx +++ b/x-pack/legacy/plugins/transform/public/app/sections/transform_management/components/search_selection/search_selection.tsx @@ -8,7 +8,7 @@ import { EuiModalBody, EuiModalHeader, EuiModalHeaderTitle } from '@elastic/eui' import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { FC } from 'react'; -import { SavedObjectFinderUi } from '../../../../../../../../../../src/plugins/kibana_react/public'; +import { SavedObjectFinderUi } from '../../../../../../../../../../src/plugins/saved_objects/public'; import { useAppDependencies } from '../../../../app_dependencies'; interface SearchSelectionProps { From 053c675cb384bb8ee35ec710a995b77f8aac6d8c Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Thu, 30 Jan 2020 16:50:43 +0300 Subject: [PATCH 08/18] Remove unused export --- src/plugins/saved_objects/public/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/saved_objects/public/index.ts b/src/plugins/saved_objects/public/index.ts index 9fa2f448c64c0..2889e20b7925e 100644 --- a/src/plugins/saved_objects/public/index.ts +++ b/src/plugins/saved_objects/public/index.ts @@ -20,7 +20,6 @@ export * from './save_modal'; export { SavedObjectMetaData, - SavedObjectFinderProps, SavedObjectFinderUi, getSavedObjectFinder, } from './saved_object_finder'; From 8d9573b0546e358563d41ee014ae1448567dbbad Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Thu, 30 Jan 2020 17:29:23 +0300 Subject: [PATCH 09/18] Pass I18nContext to showSaveModal --- .../core_plugins/kibana/public/visualize/kibana_services.ts | 2 ++ .../kibana/public/visualize/np_ready/editor/editor.js | 3 ++- src/legacy/core_plugins/kibana/public/visualize/plugin.ts | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) 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 f7fd19e8288e7..1cbe339dd32c8 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts @@ -23,6 +23,7 @@ import { SavedObjectsClientContract, ToastsStart, IUiSettingsClient, + I18nStart, } from 'kibana/public'; import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public'; @@ -55,6 +56,7 @@ export interface VisualizeKibanaServices { visualizeCapabilities: any; visualizations: VisualizationsStart; usageCollection?: UsageCollectionSetup; + I18nContext: I18nStart['Context']; } let services: VisualizeKibanaServices | null = null; diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js index adee5e3dfed01..a12492fafc3b8 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js @@ -96,6 +96,7 @@ function VisualizeAppController( core: { docLinks }, savedQueryService, uiSettings, + I18nContext, } = getServices(); const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager); @@ -194,7 +195,7 @@ function VisualizeAppController( description={savedVis.description} /> ); - showSaveModal(saveModal); + showSaveModal(saveModal, I18nContext); }, }, ] diff --git a/src/legacy/core_plugins/kibana/public/visualize/plugin.ts b/src/legacy/core_plugins/kibana/public/visualize/plugin.ts index 26c6691a3613f..40a1059442871 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/plugin.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/plugin.ts @@ -111,6 +111,7 @@ export class VisualizePlugin implements Plugin { visualizeCapabilities: contextCore.application.capabilities.visualize, visualizations, usageCollection, + I18nContext: contextCore.i18n.Context, }; setServices(deps); From d0e3f99ab6bccbd203891df3346f9baaac8ff602 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Mon, 3 Feb 2020 14:34:11 +0300 Subject: [PATCH 10/18] Update i18n ids --- .i18nrc.json | 1 + .../saved_object_save_modal.test.tsx.snap | 8 +++--- .../save_modal/saved_object_save_modal.tsx | 18 ++++++------ .../public/saved_object_finder.tsx | 14 +++++----- .../translations/translations/ja-JP.json | 28 +++++++++---------- .../translations/translations/zh-CN.json | 28 +++++++++---------- 6 files changed, 49 insertions(+), 48 deletions(-) diff --git a/.i18nrc.json b/.i18nrc.json index 1230151212f57..5a0a0102fb8d0 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -29,6 +29,7 @@ "navigation": "src/plugins/navigation", "newsfeed": "src/plugins/newsfeed", "regionMap": "src/legacy/core_plugins/region_map", + "savedObjects": "src/plugins/saved_objects", "server": "src/legacy/server", "statusPage": "src/legacy/core_plugins/status_page", "telemetry": "src/legacy/core_plugins/telemetry", diff --git a/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap b/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap index 18f84f41d5d99..38f654c225326 100644 --- a/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap +++ b/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap @@ -15,7 +15,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` } @@ -59,7 +59,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` label={ } @@ -80,7 +80,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` > diff --git a/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx b/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx index cdbc2bb9b5473..da70d9fe89525 100644 --- a/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx +++ b/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx @@ -97,7 +97,7 @@ export class SavedObjectSaveModal extends React.Component { @@ -119,7 +119,7 @@ export class SavedObjectSaveModal extends React.Component { fullWidth label={ } @@ -146,7 +146,7 @@ export class SavedObjectSaveModal extends React.Component { @@ -169,7 +169,7 @@ export class SavedObjectSaveModal extends React.Component { fullWidth label={ } @@ -243,7 +243,7 @@ export class SavedObjectSaveModal extends React.Component { const { isLoading, title } = this.state; let confirmLabel: string | React.ReactNode = i18n.translate( - 'kibana-react.savedObjects.saveModal.saveButtonLabel', + 'savedObjects.saveModal.saveButtonLabel', { defaultMessage: 'Save', } @@ -277,7 +277,7 @@ export class SavedObjectSaveModal extends React.Component { @@ -288,7 +288,7 @@ export class SavedObjectSaveModal extends React.Component { >

{ {this.props.confirmButtonLabel ? this.props.confirmButtonLabel - : i18n.translate('kibana-react.savedObjects.saveModal.saveButtonLabel', { + : i18n.translate('savedObjects.saveModal.saveButtonLabel', { defaultMessage: 'Save', })} @@ -324,7 +324,7 @@ export class SavedObjectSaveModal extends React.Component { onChange={this.onCopyOnSaveChange} label={ diff --git a/src/plugins/saved_objects/public/saved_object_finder.tsx b/src/plugins/saved_objects/public/saved_object_finder.tsx index 0d883c28f999e..b9298f9c80eda 100644 --- a/src/plugins/saved_objects/public/saved_object_finder.tsx +++ b/src/plugins/saved_objects/public/saved_object_finder.tsx @@ -303,7 +303,7 @@ class SavedObjectFinderUi extends React.Component< }); }} > - {i18n.translate('kibana-react.savedObjects.finder.sortAsc', { + {i18n.translate('savedObjects.finder.sortAsc', { defaultMessage: 'Ascending', })} , @@ -316,7 +316,7 @@ class SavedObjectFinderUi extends React.Component< }); }} > - {i18n.translate('kibana-react.savedObjects.finder.sortDesc', { + {i18n.translate('savedObjects.finder.sortDesc', { defaultMessage: 'Descending', })} , @@ -332,7 +332,7 @@ class SavedObjectFinderUi extends React.Component< }); }} > - {i18n.translate('kibana-react.savedObjects.finder.sortAuto', { + {i18n.translate('savedObjects.finder.sortAuto', { defaultMessage: 'Best match', })} @@ -348,10 +348,10 @@ class SavedObjectFinderUi extends React.Component< - {i18n.translate('kibana-react.savedObjects.finder.sortButtonLabel', { + {i18n.translate('savedObjects.finder.sortButtonLabel', { defaultMessage: 'Sort', })} @@ -419,7 +419,7 @@ class SavedObjectFinderUi extends React.Component< hasActiveFilters={this.state.filteredTypes.length > 0} numActiveFilters={this.state.filteredTypes.length} > - {i18n.translate('kibana-react.savedObjects.finder.filterButtonLabel', { + {i18n.translate('savedObjects.finder.filterButtonLabel', { defaultMessage: 'Types', })} diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 47e11817ffa5d..5d4274be3d343 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -2435,20 +2435,6 @@ "visTypeVislib.vislib.legend.toggleOptionsButtonAriaLabel": "{legendDataLabel}、トグルオプション", "kibana-react.exitFullScreenButton.exitFullScreenModeButtonLabel": "全画面を終了", "kibana-react.exitFullScreenButton.fullScreenModeDescription": "ESC キーで全画面モードを終了します。", - "kibana-react.savedObjects.finder.filterButtonLabel": "タイプ", - "kibana-react.savedObjects.finder.searchPlaceholder": "検索...", - "kibana-react.savedObjects.finder.sortAsc": "昇順", - "kibana-react.savedObjects.finder.sortAuto": "ベストマッチ", - "kibana-react.savedObjects.finder.sortButtonLabel": "並べ替え", - "kibana-react.savedObjects.finder.sortDesc": "降順", - "kibana-react.savedObjects.saveModal.cancelButtonLabel": "キャンセル", - "kibana-react.savedObjects.saveModal.descriptionLabel": "説明", - "kibana-react.savedObjects.saveModal.duplicateTitleDescription": "{confirmSaveLabel} をクリックすると、既存の {objectType} が上書きされます。", - "kibana-react.savedObjects.saveModal.duplicateTitleLabel": "「{title}」というタイトルの {objectType} が既に存在します", - "kibana-react.savedObjects.saveModal.saveAsNewLabel": "新規 {objectType} として保存", - "kibana-react.savedObjects.saveModal.saveButtonLabel": "保存", - "kibana-react.savedObjects.saveModal.saveTitle": "{objectType} を保存", - "kibana-react.savedObjects.saveModal.titleLabel": "タイトル", "newsfeed.emptyPrompt.noNewsText": "Kibanaインスタンスがインターネットにアクセスできない場合、管理者にこの機能を無効にするように依頼してください。そうでない場合は、ニュースを取り込み続けます。", "newsfeed.emptyPrompt.noNewsTitle": "ニュースがない場合", "newsfeed.flyoutList.closeButtonLabel": "閉じる", @@ -2478,6 +2464,20 @@ "regionMap.visParams.vectorMapLabel": "ベクトルマップ", "regionMap.visualization.unableToShowMismatchesWarningText": "次の各用語がシェイプの結合フィールドのシェイプと一致することを確認してください: {mismatches}", "regionMap.visualization.unableToShowMismatchesWarningTitle": "{mismatchesLength} {oneMismatch, plural, one { 件の結果} other { 件の結果}}をマップに表示できません", + "savedObjects.finder.filterButtonLabel": "タイプ", + "savedObjects.finder.searchPlaceholder": "検索...", + "savedObjects.finder.sortAsc": "昇順", + "savedObjects.finder.sortAuto": "ベストマッチ", + "savedObjects.finder.sortButtonLabel": "並べ替え", + "savedObjects.finder.sortDesc": "降順", + "savedObjects.saveModal.cancelButtonLabel": "キャンセル", + "savedObjects.saveModal.descriptionLabel": "説明", + "savedObjects.saveModal.duplicateTitleDescription": "{confirmSaveLabel} をクリックすると、既存の {objectType} が上書きされます。", + "savedObjects.saveModal.duplicateTitleLabel": "「{title}」というタイトルの {objectType} が既に存在します", + "savedObjects.saveModal.saveAsNewLabel": "新規 {objectType} として保存", + "savedObjects.saveModal.saveButtonLabel": "保存", + "savedObjects.saveModal.saveTitle": "{objectType} を保存", + "savedObjects.saveModal.titleLabel": "タイトル", "server.stats.notReadyMessage": "まだ統計が準備できていません。後程再試行してください", "server.status.disabledTitle": "無効", "server.status.greenTitle": "緑", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 86d9a69dc0900..0cc0c6a2afefe 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -2435,20 +2435,6 @@ "visTypeVislib.vislib.legend.toggleOptionsButtonAriaLabel": "{legendDataLabel}切换选项", "kibana-react.exitFullScreenButton.exitFullScreenModeButtonLabel": "退出全屏", "kibana-react.exitFullScreenButton.fullScreenModeDescription": "在全屏模式下,按 ESC 键可退出。", - "kibana-react.savedObjects.finder.filterButtonLabel": "类型", - "kibana-react.savedObjects.finder.searchPlaceholder": "搜索……", - "kibana-react.savedObjects.finder.sortAsc": "升序", - "kibana-react.savedObjects.finder.sortAuto": "最佳匹配", - "kibana-react.savedObjects.finder.sortButtonLabel": "排序", - "kibana-react.savedObjects.finder.sortDesc": "降序", - "kibana-react.savedObjects.saveModal.cancelButtonLabel": "取消", - "kibana-react.savedObjects.saveModal.descriptionLabel": "描述", - "kibana-react.savedObjects.saveModal.duplicateTitleDescription": "单击“{confirmSaveLabel}”可覆盖现有 {objectType}。", - "kibana-react.savedObjects.saveModal.duplicateTitleLabel": "具有标题“{title}”的 {objectType} 已存在", - "kibana-react.savedObjects.saveModal.saveAsNewLabel": "另存为新的 {objectType}", - "kibana-react.savedObjects.saveModal.saveButtonLabel": "保存", - "kibana-react.savedObjects.saveModal.saveTitle": "保存 {objectType}", - "kibana-react.savedObjects.saveModal.titleLabel": "标题", "newsfeed.emptyPrompt.noNewsText": "如果您的 Kibana 实例没有 Internet 连接,请让您的管理员禁用此功能。否则,我们将不断尝试获取新闻。", "newsfeed.emptyPrompt.noNewsTitle": "无新闻?", "newsfeed.flyoutList.closeButtonLabel": "鍏抽棴", @@ -2478,6 +2464,20 @@ "regionMap.visParams.vectorMapLabel": "矢量地图", "regionMap.visualization.unableToShowMismatchesWarningText": "确保每个字词与该形状的联接字段匹配:{mismatches}", "regionMap.visualization.unableToShowMismatchesWarningTitle": "无法在地图上显示 {mismatchesLength} {oneMismatch, plural, one { 个结果} other { 个结果}}", + "savedObjects.finder.filterButtonLabel": "类型", + "savedObjects.finder.searchPlaceholder": "搜索……", + "savedObjects.finder.sortAsc": "升序", + "savedObjects.finder.sortAuto": "最佳匹配", + "savedObjects.finder.sortButtonLabel": "排序", + "savedObjects.finder.sortDesc": "降序", + "savedObjects.saveModal.cancelButtonLabel": "取消", + "savedObjects.saveModal.descriptionLabel": "描述", + "savedObjects.saveModal.duplicateTitleDescription": "单击“{confirmSaveLabel}”可覆盖现有 {objectType}。", + "savedObjects.saveModal.duplicateTitleLabel": "具有标题“{title}”的 {objectType} 已存在", + "savedObjects.saveModal.saveAsNewLabel": "另存为新的 {objectType}", + "savedObjects.saveModal.saveButtonLabel": "保存", + "savedObjects.saveModal.saveTitle": "保存 {objectType}", + "savedObjects.saveModal.titleLabel": "标题", "server.stats.notReadyMessage": "统计尚未就绪。请稍后重试", "server.status.disabledTitle": "已禁用", "server.status.greenTitle": "绿", From 255b5053ce310984271dd449cb6be9eaf462ae65 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Mon, 3 Feb 2020 14:35:15 +0300 Subject: [PATCH 11/18] Fix map save --- x-pack/legacy/plugins/maps/public/angular/map_controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 810c4220c96c5..c90560a4fcfdf 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -568,7 +568,7 @@ app.controller( objectType={MAP_SAVED_OBJECT_TYPE} /> ); - showSaveModal(saveModal, npStart.i18n.Context); + showSaveModal(saveModal, npStart.core.i18n.Context); }, }, ] From 0d6f07898d1db8a7e8b7a5b1c5391715054f4d29 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Mon, 3 Feb 2020 15:40:24 +0300 Subject: [PATCH 12/18] Refactoring --- .../dashboard_container_factory.tsx | 2 +- .../lib/embeddables/embeddable_factory.ts | 2 +- src/plugins/saved_objects/public/_index.scss | 1 + .../show_saved_object_save_modal.tsx | 2 +- .../public/saved_object_finder.tsx | 22 +++++-------------- 5 files changed, 9 insertions(+), 20 deletions(-) create mode 100644 src/plugins/saved_objects/public/_index.scss diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx index c3866e7b26370..d08fcfef3529e 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container_factory.tsx @@ -18,7 +18,7 @@ */ import { i18n } from '@kbn/i18n'; -import { SavedObjectMetaData } from 'src/plugins/saved_objects/public'; +import { SavedObjectMetaData } from '../../../saved_objects/public'; import { SavedObjectAttributes } from '../../../../core/public'; import { ContainerOutput, diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts index 4ff52583cbbfb..162da75c228aa 100644 --- a/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts +++ b/src/plugins/embeddable/public/lib/embeddables/embeddable_factory.ts @@ -18,7 +18,7 @@ */ import { SavedObjectAttributes } from 'src/core/public'; -import { SavedObjectMetaData } from 'src/plugins/saved_objects/public'; +import { SavedObjectMetaData } from '../../../../saved_objects/public'; import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from './i_embeddable'; import { ErrorEmbeddable } from './error_embeddable'; import { IContainer } from '../containers/i_container'; diff --git a/src/plugins/saved_objects/public/_index.scss b/src/plugins/saved_objects/public/_index.scss new file mode 100644 index 0000000000000..b3655a61feb21 --- /dev/null +++ b/src/plugins/saved_objects/public/_index.scss @@ -0,0 +1 @@ +@import './save_modal'; diff --git a/src/plugins/saved_objects/public/save_modal/show_saved_object_save_modal.tsx b/src/plugins/saved_objects/public/save_modal/show_saved_object_save_modal.tsx index 632291be9f069..66705985c7b99 100644 --- a/src/plugins/saved_objects/public/save_modal/show_saved_object_save_modal.tsx +++ b/src/plugins/saved_objects/public/save_modal/show_saved_object_save_modal.tsx @@ -20,7 +20,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { I18nStart } from 'src/core/public'; +import { I18nStart } from '../../../../core/public'; /** * Represents the result of trying to persist the saved object. diff --git a/src/plugins/saved_objects/public/saved_object_finder.tsx b/src/plugins/saved_objects/public/saved_object_finder.tsx index b9298f9c80eda..d6bc95ffe5a0a 100644 --- a/src/plugins/saved_objects/public/saved_object_finder.tsx +++ b/src/plugins/saved_objects/public/saved_object_finder.tsx @@ -22,10 +22,8 @@ import PropTypes from 'prop-types'; import React from 'react'; import { - CommonProps, EuiContextMenuItem, EuiContextMenuPanel, - EuiContextMenuPanelProps, EuiEmptyPrompt, EuiFieldSearch, EuiFilterButton, @@ -50,17 +48,7 @@ import { CoreStart, IUiSettingsClient, SavedObjectsStart, -} from 'src/core/public'; - -// TODO the typings for EuiListGroup are incorrect - maxWidth is missing. This can be removed when the types are adjusted -const FixedEuiListGroup = (EuiListGroup as any) as React.FunctionComponent< - CommonProps & { maxWidth: boolean } ->; - -// TODO the typings for EuiContextMenuPanel are incorrect - watchedItemProps is missing. This can be removed when the types are adjusted -const FixedEuiContextMenuPanel = (EuiContextMenuPanel as any) as React.FunctionComponent< - EuiContextMenuPanelProps & { watchedItemProps: string[] } ->; +} from '../../../core/public'; export interface SavedObjectMetaData { type: string; @@ -393,7 +381,7 @@ class SavedObjectFinderUi extends React.Component< } > - @@ -425,7 +413,7 @@ class SavedObjectFinderUi extends React.Component< } > - ( )} {items.length > 0 ? ( - + {items.map(item => { const currentSavedObjectMetaData = savedObjectMetaData.find( metaData => metaData.type === item.type @@ -500,7 +488,7 @@ class SavedObjectFinderUi extends React.Component< /> ); })} - + ) : ( !this.state.isFetchingItems && )} From b2855df84d6f26c31215e5b5daa4f56203ee9acc Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Mon, 3 Feb 2020 18:54:42 +0300 Subject: [PATCH 13/18] Load styles --- src/legacy/ui/public/saved_objects/_index.scss | 1 + src/plugins/saved_objects/public/_index.scss | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/legacy/ui/public/saved_objects/_index.scss diff --git a/src/legacy/ui/public/saved_objects/_index.scss b/src/legacy/ui/public/saved_objects/_index.scss new file mode 100644 index 0000000000000..89cda29f67744 --- /dev/null +++ b/src/legacy/ui/public/saved_objects/_index.scss @@ -0,0 +1 @@ +@import '../../../../plugins/saved_objects/public/index'; diff --git a/src/plugins/saved_objects/public/_index.scss b/src/plugins/saved_objects/public/_index.scss index b3655a61feb21..fc7bb35f38b10 100644 --- a/src/plugins/saved_objects/public/_index.scss +++ b/src/plugins/saved_objects/public/_index.scss @@ -1 +1 @@ -@import './save_modal'; +@import './save_modal/index'; From e1861a2ca853a48ecf6c6dd4058ac159b5ef4b2e Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Tue, 4 Feb 2020 11:19:56 +0300 Subject: [PATCH 14/18] Revert importing styles --- src/legacy/ui/public/_index.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/legacy/ui/public/_index.scss b/src/legacy/ui/public/_index.scss index 3934e4dc41323..e4e58019dda69 100644 --- a/src/legacy/ui/public/_index.scss +++ b/src/legacy/ui/public/_index.scss @@ -16,6 +16,7 @@ @import './error_url_overflow/index'; @import './exit_full_screen/index'; @import './field_editor/index'; +@import './saved_objects/index'; @import './share/index'; @import './style_compile/index'; @import '../../../plugins/management/public/components/index'; From 3507f21a09146773f72091983af5a3312d2ef0da Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Tue, 4 Feb 2020 11:27:19 +0300 Subject: [PATCH 15/18] Update snapshot --- .../__snapshots__/saved_object_save_modal.test.tsx.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap b/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap index eff5ab4f1e2c7..38f654c225326 100644 --- a/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap +++ b/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap @@ -8,6 +8,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` From 8c883c0c079a75cea89ed4b759b3c1c388b4f144 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Tue, 4 Feb 2020 12:52:09 +0300 Subject: [PATCH 16/18] Update snapshot --- .../__snapshots__/saved_object_save_modal.test.tsx.snap | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap b/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap index 38f654c225326..eff5ab4f1e2c7 100644 --- a/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap +++ b/src/plugins/saved_objects/public/save_modal/__snapshots__/saved_object_save_modal.test.tsx.snap @@ -8,7 +8,6 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` From 91bc118ea397d699d63ecbd666408816c5bea9d3 Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Wed, 5 Feb 2020 15:48:51 +0300 Subject: [PATCH 17/18] Structural refactoring --- .../saved_objects/public/finder/index.ts | 24 +++++++++++++++++++ .../{ => finder}/saved_object_finder.test.tsx | 2 +- .../{ => finder}/saved_object_finder.tsx | 0 src/plugins/saved_objects/public/index.ts | 8 ++----- 4 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 src/plugins/saved_objects/public/finder/index.ts rename src/plugins/saved_objects/public/{ => finder}/saved_object_finder.test.tsx (99%) rename src/plugins/saved_objects/public/{ => finder}/saved_object_finder.tsx (100%) diff --git a/src/plugins/saved_objects/public/finder/index.ts b/src/plugins/saved_objects/public/finder/index.ts new file mode 100644 index 0000000000000..54a05cdfbadc3 --- /dev/null +++ b/src/plugins/saved_objects/public/finder/index.ts @@ -0,0 +1,24 @@ +/* + * 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 { + SavedObjectMetaData, + SavedObjectFinderUi, + getSavedObjectFinder, +} from './saved_object_finder'; diff --git a/src/plugins/saved_objects/public/saved_object_finder.test.tsx b/src/plugins/saved_objects/public/finder/saved_object_finder.test.tsx similarity index 99% rename from src/plugins/saved_objects/public/saved_object_finder.test.tsx rename to src/plugins/saved_objects/public/finder/saved_object_finder.test.tsx index a5f18d428ed8f..97ac25dca8cf1 100644 --- a/src/plugins/saved_objects/public/saved_object_finder.test.tsx +++ b/src/plugins/saved_objects/public/finder/saved_object_finder.test.tsx @@ -36,7 +36,7 @@ import { shallow } from 'enzyme'; import React from 'react'; import * as sinon from 'sinon'; import { SavedObjectFinderUi as SavedObjectFinder } from './saved_object_finder'; -import { coreMock } from '../../../core/public/mocks'; +import { coreMock } from '../../../../core/public/mocks'; describe('SavedObjectsFinder', () => { const doc = { diff --git a/src/plugins/saved_objects/public/saved_object_finder.tsx b/src/plugins/saved_objects/public/finder/saved_object_finder.tsx similarity index 100% rename from src/plugins/saved_objects/public/saved_object_finder.tsx rename to src/plugins/saved_objects/public/finder/saved_object_finder.tsx diff --git a/src/plugins/saved_objects/public/index.ts b/src/plugins/saved_objects/public/index.ts index 2889e20b7925e..5dae8b055d2db 100644 --- a/src/plugins/saved_objects/public/index.ts +++ b/src/plugins/saved_objects/public/index.ts @@ -17,9 +17,5 @@ * under the License. */ -export * from './save_modal'; -export { - SavedObjectMetaData, - SavedObjectFinderUi, - getSavedObjectFinder, -} from './saved_object_finder'; +export { OnSaveProps, SavedObjectSaveModal, SaveResult, showSaveModal } from './save_modal'; +export { getSavedObjectFinder, SavedObjectFinderUi, SavedObjectMetaData } from './finder'; From f1faec46a19594f1ccdf9d9d8c9532cce48c115f Mon Sep 17 00:00:00 2001 From: maryia-lapata Date: Wed, 5 Feb 2020 15:54:44 +0300 Subject: [PATCH 18/18] Fix path --- src/plugins/saved_objects/public/finder/saved_object_finder.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/saved_objects/public/finder/saved_object_finder.tsx b/src/plugins/saved_objects/public/finder/saved_object_finder.tsx index d6bc95ffe5a0a..0658ed64df84c 100644 --- a/src/plugins/saved_objects/public/finder/saved_object_finder.tsx +++ b/src/plugins/saved_objects/public/finder/saved_object_finder.tsx @@ -48,7 +48,7 @@ import { CoreStart, IUiSettingsClient, SavedObjectsStart, -} from '../../../core/public'; +} from '../../../../core/public'; export interface SavedObjectMetaData { type: string;