From f4f5b04e8d0ecde072bab0a1e264bafa182c39b1 Mon Sep 17 00:00:00 2001 From: Maryia Lapata Date: Thu, 6 Feb 2020 19:56:51 +0300 Subject: [PATCH] [NP] Move saved object modal into new platform (#56383) * Move saved object modal into new platform * Fix TS * Revert "Fix TS" This reverts commit f2f9f5e9356d0b0de8b18e9fceebf721393eacd0. * 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 * Move save_object_save_modal * Move show_saved_object_save_modal.tsx * Move save_object_finder.tsx * Remove unused export * Pass I18nContext to showSaveModal * Update i18n ids * Fix map save * Refactoring * Load styles * Revert importing styles * Update snapshot * Update snapshot * Structural refactoring * Fix path Co-authored-by: Elastic Machine --- .i18nrc.json | 1 + .../kibana/public/dashboard/legacy_imports.ts | 2 - .../np_ready/dashboard_app_controller.tsx | 30 +++++----- .../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 | 8 ++- .../components/top_nav/open_search_panel.js | 2 +- .../public/visualize/kibana_services.ts | 2 + .../kibana/public/visualize/legacy_imports.ts | 3 - .../visualize/np_ready/editor/editor.js | 9 ++- .../kibana/public/visualize/plugin.ts | 1 + .../search_selection/search_selection.tsx | 2 +- .../ui/public/saved_objects/_index.scss | 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 - src/plugins/saved_objects/public/_index.scss | 1 + .../public/finder}/index.ts | 7 ++- .../finder}/saved_object_finder.test.tsx | 1 - .../public/finder}/saved_object_finder.tsx | 57 +++++++------------ .../saved_objects/public/index.ts} | 8 +-- .../saved_object_save_modal.test.tsx.snap | 8 +-- .../public/save_modal}/_index.scss | 0 .../saved_objects/public/save_modal/index.ts | 21 +++++++ .../save_modal}/saved_object_save_modal.scss | 0 .../saved_object_save_modal.test.tsx | 0 .../save_modal}/saved_object_save_modal.tsx | 18 +++--- .../show_saved_object_save_modal.tsx | 10 +++- .../public/np_ready/public/plugin.tsx | 14 +---- .../renderers/embeddable/embeddable.tsx | 17 ++---- .../components/embeddable_flyout/flyout.tsx | 2 +- x-pack/legacy/plugins/graph/public/app.js | 3 +- .../graph/public/components/save_modal.tsx | 2 +- .../graph/public/components/source_picker.tsx | 2 +- .../plugins/graph/public/legacy_imports.ts | 2 - .../graph/public/services/save_modal.tsx | 10 +++- .../graph/public/state_management/mocks.ts | 3 + .../public/state_management/persistence.ts | 1 + .../graph/public/state_management/store.ts | 5 +- .../plugins/lens/public/app_plugin/app.tsx | 2 +- .../maps/public/angular/map_controller.js | 8 ++- .../new_job/pages/index_or_search/page.tsx | 2 +- .../components/embeddables/embedded_map.tsx | 15 +---- .../search_selection/search_selection.tsx | 2 +- .../translations/translations/ja-JP.json | 28 ++++----- .../translations/translations/zh-CN.json | 28 ++++----- 51 files changed, 177 insertions(+), 210 deletions(-) create mode 100644 src/plugins/saved_objects/public/_index.scss rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public/finder}/index.ts (87%) rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public/finder}/saved_object_finder.test.tsx (99%) rename src/plugins/{kibana_react/public/saved_objects => saved_objects/public/finder}/saved_object_finder.tsx (89%) 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 (90%) 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 (93%) rename src/{legacy/ui/public/saved_objects => plugins/saved_objects/public/save_modal}/show_saved_object_save_modal.tsx (91%) diff --git a/.i18nrc.json b/.i18nrc.json index e0acda70cc348..08cf5a2823203 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -33,6 +33,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/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/dashboard/legacy_imports.ts index 14bdef99ca894..ff70ed9dc2eb7 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 624be02ac3b9d..9f6b01d5beb49 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 @@ -31,8 +31,6 @@ import { ConfirmationButtonTypes, migrateLegacyQuery, SavedObjectSaveOpts, - SaveResult, - showSaveModal, subscribeWithScope, } from '../legacy_imports'; import { @@ -45,6 +43,11 @@ import { syncAppFilters, syncQuery, } from '../../../../../../plugins/data/public'; +import { + SaveResult, + showSaveModal, + getSavedObjectFinder, +} from '../../../../../../plugins/saved_objects/public'; import { DASHBOARD_CONTAINER_TYPE, @@ -74,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 { IKbnUrlStateStorage, removeQueryParam, @@ -114,7 +113,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) { @@ -777,7 +785,7 @@ export class DashboardAppController { showCopyOnSave={dash.id ? true : false} /> ); - showSaveModal(dashboardSaveModal); + showSaveModal(dashboardSaveModal, i18nStart.Context); }; navActions[TopNavIds.CLONE] = () => { const currentTitle = dashboardStateManager.getTitle(); @@ -806,17 +814,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/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/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 f698a2ee361e0..820c9949342a4 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -58,8 +58,6 @@ export { getRequestInspectorStats, getResponseInspectorStats } from '../../../da export { intervalOptions } from 'ui/agg_types'; // @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 978a58ef5b2c4..69f69d449354c 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 @@ -27,6 +27,10 @@ import { i18n } from '@kbn/i18n'; import '../components/field_chooser/field_chooser'; import { RequestAdapter } from '../../../../../../../plugins/inspector/public'; +import { + SavedObjectSaveModal, + showSaveModal, +} from '../../../../../../../plugins/saved_objects/public'; // doc table import './doc_table'; import { getSortArray } from './doc_table/lib/get_sort'; @@ -48,12 +52,10 @@ import { hasSearchStategyForIndexPattern, intervalOptions, migrateLegacyQuery, - showSaveModal, unhashUrl, stateMonitorFactory, subscribeWithScope, tabifyAggResponse, - SavedObjectSaveModal, getAngularModule, ensureDefaultIndexPattern, registerTimefilterWithGlobalStateFactory, @@ -305,7 +307,7 @@ function discoverController( })} /> ); - showSaveModal(saveModal); + showSaveModal(saveModal, core.i18n.Context); }, }; 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/kibana_services.ts b/src/legacy/core_plugins/kibana/public/visualize/kibana_services.ts index 15e9c73a39eff..428e6cb225710 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'; @@ -57,6 +58,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/legacy_imports.ts b/src/legacy/core_plugins/kibana/public/visualize/legacy_imports.ts index b185dc577a3aa..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,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 886187cbb942e..46ae45c3a5fa2 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,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, + showSaveModal, +} from '../../../../../../../plugins/saved_objects/public'; import { initVisEditorDirective } from './visualization_editor'; import { initVisualizationDirective } from './visualization'; @@ -40,8 +44,6 @@ import { absoluteToParsedUrl, KibanaParsedUrl, migrateLegacyQuery, - SavedObjectSaveModal, - showSaveModal, stateMonitorFactory, DashboardConstants, } from '../../legacy_imports'; @@ -94,6 +96,7 @@ function VisualizeAppController( core: { docLinks }, savedQueryService, uiSettings, + I18nContext, } = getServices(); const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager); @@ -191,7 +194,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 a888fc8e19f14..ce93fe7c2d578 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/plugin.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/plugin.ts @@ -112,6 +112,7 @@ export class VisualizePlugin implements Plugin { visualizeCapabilities: contextCore.application.capabilities.visualize, visualizations, usageCollection, + I18nContext: contextCore.i18n.Context, }; setServices(deps); diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/search_selection/search_selection.tsx b/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/search_selection/search_selection.tsx index 5a665a193ab39..9b3b8a6425e52 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/wizard/search_selection/search_selection.tsx +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/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 '../../types'; interface SearchSelectionProps { diff --git a/src/legacy/ui/public/saved_objects/_index.scss b/src/legacy/ui/public/saved_objects/_index.scss index 50a192b6a7b17..89cda29f67744 100644 --- a/src/legacy/ui/public/saved_objects/_index.scss +++ b/src/legacy/ui/public/saved_objects/_index.scss @@ -1 +1 @@ -@import '../../../../plugins/kibana_react/public/saved_objects/index'; +@import '../../../../plugins/saved_objects/public/index'; 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..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,8 +18,8 @@ */ import { i18n } from '@kbn/i18n'; +import { SavedObjectMetaData } from '../../../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 1227c011dc7f8..44c9dbf2dcc4b 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 ec71a1e724c7d..af6c2acd3a9b1 100644 --- a/src/plugins/embeddable/public/index.ts +++ b/src/plugins/embeddable/public/index.ts @@ -53,7 +53,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..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 '../types'; +import { SavedObjectMetaData } from '../../../../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 e1f90b9c60199..a9087a772a970 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/saved_objects/public/_index.scss b/src/plugins/saved_objects/public/_index.scss new file mode 100644 index 0000000000000..fc7bb35f38b10 --- /dev/null +++ b/src/plugins/saved_objects/public/_index.scss @@ -0,0 +1 @@ +@import './save_modal/index'; diff --git a/src/plugins/kibana_react/public/saved_objects/index.ts b/src/plugins/saved_objects/public/finder/index.ts similarity index 87% rename from src/plugins/kibana_react/public/saved_objects/index.ts rename to src/plugins/saved_objects/public/finder/index.ts index ade80d2cd2a92..54a05cdfbadc3 100644 --- a/src/plugins/kibana_react/public/saved_objects/index.ts +++ b/src/plugins/saved_objects/public/finder/index.ts @@ -17,5 +17,8 @@ * under the License. */ -export * from './saved_object_finder'; -export * from './saved_object_save_modal'; +export { + SavedObjectMetaData, + 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/finder/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/finder/saved_object_finder.test.tsx index 58b396d57639b..97ac25dca8cf1 100644 --- a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.test.tsx +++ b/src/plugins/saved_objects/public/finder/saved_object_finder.test.tsx @@ -36,7 +36,6 @@ 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'; describe('SavedObjectsFinder', () => { diff --git a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx b/src/plugins/saved_objects/public/finder/saved_object_finder.tsx similarity index 89% rename from src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx rename to src/plugins/saved_objects/public/finder/saved_object_finder.tsx index 2a43f29024ba7..0658ed64df84c 100644 --- a/src/plugins/kibana_react/public/saved_objects/saved_object_finder.tsx +++ b/src/plugins/saved_objects/public/finder/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, @@ -44,19 +42,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'; - -// 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[] } ->; +import { + SavedObjectAttributes, + SimpleSavedObject, + CoreStart, + IUiSettingsClient, + SavedObjectsStart, +} from '../../../../core/public'; export interface SavedObjectMetaData { type: string; @@ -299,7 +291,7 @@ class SavedObjectFinderUi extends React.Component< }); }} > - {i18n.translate('kibana-react.savedObjects.finder.sortAsc', { + {i18n.translate('savedObjects.finder.sortAsc', { defaultMessage: 'Ascending', })} , @@ -312,7 +304,7 @@ class SavedObjectFinderUi extends React.Component< }); }} > - {i18n.translate('kibana-react.savedObjects.finder.sortDesc', { + {i18n.translate('savedObjects.finder.sortDesc', { defaultMessage: 'Descending', })} , @@ -328,7 +320,7 @@ class SavedObjectFinderUi extends React.Component< }); }} > - {i18n.translate('kibana-react.savedObjects.finder.sortAuto', { + {i18n.translate('savedObjects.finder.sortAuto', { defaultMessage: 'Best match', })} @@ -344,10 +336,10 @@ class SavedObjectFinderUi extends React.Component< - {i18n.translate('kibana-react.savedObjects.finder.sortButtonLabel', { + {i18n.translate('savedObjects.finder.sortButtonLabel', { defaultMessage: 'Sort', })} } > - @@ -415,13 +407,13 @@ 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', })} } > - ( )} {items.length > 0 ? ( - + {items.map(item => { const currentSavedObjectMetaData = savedObjectMetaData.find( metaData => metaData.type === item.type @@ -496,7 +488,7 @@ class SavedObjectFinderUi extends React.Component< /> ); })} - + ) : ( !this.state.isFetchingItems && )} @@ -534,15 +526,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/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..5dae8b055d2db 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,5 @@ * 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 { OnSaveProps, SavedObjectSaveModal, SaveResult, showSaveModal } from './save_modal'; +export { getSavedObjectFinder, SavedObjectFinderUi, SavedObjectMetaData } from './finder'; 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 90% 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 index 307c0760de7ba..eff5ab4f1e2c7 100644 --- 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 @@ -14,7 +14,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` } @@ -58,7 +58,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` label={ } @@ -79,7 +79,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = ` > 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..f26aa732f30a1 --- /dev/null +++ b/src/plugins/saved_objects/public/save_modal/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 { SavedObjectSaveModal, OnSaveProps } from './saved_object_save_modal'; +export { showSaveModal, SaveResult } from './show_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 93% 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 index cdbc2bb9b5473..da70d9fe89525 100644 --- 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 @@ -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/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..66705985c7b99 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 '../../../../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/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 18ece42122da7..2c58abba60558 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 c8cc1fe389619..549e69e57e921 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/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/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/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/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/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index 6d2ebee1d88db..23c595bf770d2 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..c90560a4fcfdf 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,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, + 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.core.i18n.Context); }, }, ] 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 { diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 3944b3e240abf..16b96ffe283f0 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -2416,20 +2416,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": "閉じる", @@ -2459,6 +2445,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 4315722a888eb..6a352b41235a2 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -2416,20 +2416,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": "鍏抽棴", @@ -2459,6 +2445,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": "绿",