[NP] Move saved object modal into new platform (#56383) (#57007)

* Move saved object modal into new platform

* Fix TS

* Revert "Fix TS"

This reverts commit f2f9f5e935.

* Revert "Move saved object modal into new platform"

This reverts commit d0f0ea6e30.

# 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 <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Maryia Lapata 2020-02-07 10:28:17 +03:00 committed by GitHub
parent 085f52dd8d
commit 05574a9119
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 177 additions and 210 deletions

View file

@ -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",

View file

@ -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

View file

@ -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) => (
<SavedObjectFinderUi {...props} savedObjects={savedObjects} uiSettings={uiSettings} />
);
openAddPanelFlyout({
embeddable: dashboardContainer,
getAllFactories: embeddables.getEmbeddableFactories,
getFactory: embeddables.getEmbeddableFactory,
notifications,
overlays,
SavedObjectFinder,
SavedObjectFinder: getSavedObjectFinder(savedObjects, uiSettings),
});
}
};

View file

@ -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,
}));

View file

@ -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;

View file

@ -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

View file

@ -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);
},
};

View file

@ -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';

View file

@ -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;

View file

@ -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

View file

@ -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);
},
},
]

View file

@ -112,6 +112,7 @@ export class VisualizePlugin implements Plugin {
visualizeCapabilities: contextCore.application.capabilities.visualize,
visualizations,
usageCollection,
I18nContext: contextCore.i18n.Context,
};
setServices(deps);

View file

@ -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 {

View file

@ -1 +1 @@
@import '../../../../plugins/kibana_react/public/saved_objects/index';
@import '../../../../plugins/saved_objects/public/index';

View file

@ -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,

View file

@ -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<Exclude<
SavedObjectFinderProps,
'savedObjects' | 'uiSettings'
>> = props => (
<SavedObjectFinderUi
{...props}
savedObjects={core.savedObjects}
uiSettings={core.uiSettings}
/>
);
const SavedObjectFinder = getSavedObjectFinder(core.savedObjects, core.uiSettings);
const useHideChrome = () => {
React.useEffect(() => {

View file

@ -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<T extends SavedObjectAttributes> {
delete(): void;
}
export interface SavedObjectMetaData<T extends SavedObjectAttributes> {
type: string;
name: string;
getIconForSavedObject(savedObject: SimpleSavedObject<T>): IconType;
getTooltipForSavedObject?(savedObject: SimpleSavedObject<T>): string;
showSavedObject?(savedObject: SimpleSavedObject<T>): boolean;
}
interface FieldSubType {
multi?: { parent: string };
nested?: { path: string };

View file

@ -53,7 +53,6 @@ export {
PanelNotFoundError,
PanelState,
PropertySpec,
SavedObjectMetaData,
ViewMode,
isErrorEmbeddable,
openAddPanelFlyout,

View file

@ -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<T> {
export interface EmbeddableFactoryOptions<T extends SavedObjectAttributes> {
savedObjectMetaData?: SavedObjectMetaData<T>;
}

View file

@ -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<T> {
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<EmbeddableFactory>;

View file

@ -18,7 +18,6 @@
*/
export * from './code_editor';
export * from './saved_objects';
export * from './exit_full_screen_button';
export * from './context';
export * from './overlays';

View file

@ -0,0 +1 @@
@import './save_modal/index';

View file

@ -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';

View file

@ -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', () => {

View file

@ -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<T extends SavedObjectAttributes> {
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',
})}
</EuiContextMenuItem>,
@ -312,7 +304,7 @@ class SavedObjectFinderUi extends React.Component<
});
}}
>
{i18n.translate('kibana-react.savedObjects.finder.sortDesc', {
{i18n.translate('savedObjects.finder.sortDesc', {
defaultMessage: 'Descending',
})}
</EuiContextMenuItem>,
@ -328,7 +320,7 @@ class SavedObjectFinderUi extends React.Component<
});
}}
>
{i18n.translate('kibana-react.savedObjects.finder.sortAuto', {
{i18n.translate('savedObjects.finder.sortAuto', {
defaultMessage: 'Best match',
})}
</EuiContextMenuItem>
@ -344,10 +336,10 @@ class SavedObjectFinderUi extends React.Component<
<EuiFlexGroup gutterSize="m">
<EuiFlexItem grow={true}>
<EuiFieldSearch
placeholder={i18n.translate('kibana-react.savedObjects.finder.searchPlaceholder', {
placeholder={i18n.translate('savedObjects.finder.searchPlaceholder', {
defaultMessage: 'Search…',
})}
aria-label={i18n.translate('kibana-react.savedObjects.finder.searchPlaceholder', {
aria-label={i18n.translate('savedObjects.finder.searchPlaceholder', {
defaultMessage: 'Search…',
})}
fullWidth
@ -383,13 +375,13 @@ class SavedObjectFinderUi extends React.Component<
isSelected={this.state.sortOpen}
data-test-subj="savedObjectFinderSortButton"
>
{i18n.translate('kibana-react.savedObjects.finder.sortButtonLabel', {
{i18n.translate('savedObjects.finder.sortButtonLabel', {
defaultMessage: 'Sort',
})}
</EuiFilterButton>
}
>
<FixedEuiContextMenuPanel
<EuiContextMenuPanel
watchedItemProps={['icon', 'disabled']}
items={this.getSortOptions()}
/>
@ -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',
})}
</EuiFilterButton>
}
>
<FixedEuiContextMenuPanel
<EuiContextMenuPanel
watchedItemProps={['icon', 'disabled']}
items={this.props.savedObjectMetaData.map(metaData => (
<EuiContextMenuItem
@ -465,7 +457,7 @@ class SavedObjectFinderUi extends React.Component<
</EuiFlexGroup>
)}
{items.length > 0 ? (
<FixedEuiListGroup data-test-subj="savedObjectFinderItemList" maxWidth={false}>
<EuiListGroup data-test-subj="savedObjectFinderItemList" maxWidth={false}>
{items.map(item => {
const currentSavedObjectMetaData = savedObjectMetaData.find(
metaData => metaData.type === item.type
@ -496,7 +488,7 @@ class SavedObjectFinderUi extends React.Component<
/>
);
})}
</FixedEuiListGroup>
</EuiListGroup>
) : (
!this.state.isFetchingItems && <EuiEmptyPrompt body={this.props.noItemsMessage} />
)}
@ -534,15 +526,10 @@ class SavedObjectFinderUi extends React.Component<
}
}
const SavedObjectFinder = (props: SavedObjectFinderProps) => {
const { services } = useKibana();
return (
<SavedObjectFinderUi
{...props}
savedObjects={services.savedObject}
uiSettings={services.uiSettings}
/>
const getSavedObjectFinder = (savedObject: SavedObjectsStart, uiSettings: IUiSettingsClient) => {
return (props: SavedObjectFinderProps) => (
<SavedObjectFinderUi {...props} savedObjects={savedObject} uiSettings={uiSettings} />
);
};
export { SavedObjectFinder, SavedObjectFinderUi };
export { getSavedObjectFinder, SavedObjectFinderUi };

View file

@ -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';

View file

@ -14,7 +14,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = `
<EuiModalHeaderTitle>
<FormattedMessage
defaultMessage="Save {objectType}"
id="kibana-react.savedObjects.saveModal.saveTitle"
id="savedObjects.saveModal.saveTitle"
values={
Object {
"objectType": "visualization",
@ -34,7 +34,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = `
label={
<FormattedMessage
defaultMessage="Title"
id="kibana-react.savedObjects.saveModal.titleLabel"
id="savedObjects.saveModal.titleLabel"
values={Object {}}
/>
}
@ -58,7 +58,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = `
label={
<FormattedMessage
defaultMessage="Description"
id="kibana-react.savedObjects.saveModal.descriptionLabel"
id="savedObjects.saveModal.descriptionLabel"
values={Object {}}
/>
}
@ -79,7 +79,7 @@ exports[`SavedObjectSaveModal should render matching snapshot 1`] = `
>
<FormattedMessage
defaultMessage="Cancel"
id="kibana-react.savedObjects.saveModal.cancelButtonLabel"
id="savedObjects.saveModal.cancelButtonLabel"
values={Object {}}
/>
</EuiButtonEmpty>

View file

@ -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';

View file

@ -97,7 +97,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
<EuiModalHeader>
<EuiModalHeaderTitle>
<FormattedMessage
id="kibana-react.savedObjects.saveModal.saveTitle"
id="savedObjects.saveModal.saveTitle"
defaultMessage="Save {objectType}"
values={{ objectType: this.props.objectType }}
/>
@ -119,7 +119,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
fullWidth
label={
<FormattedMessage
id="kibana-react.savedObjects.saveModal.titleLabel"
id="savedObjects.saveModal.titleLabel"
defaultMessage="Title"
/>
}
@ -146,7 +146,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
<EuiModalFooter>
<EuiButtonEmpty data-test-subj="saveCancelButton" onClick={this.props.onClose}>
<FormattedMessage
id="kibana-react.savedObjects.saveModal.cancelButtonLabel"
id="savedObjects.saveModal.cancelButtonLabel"
defaultMessage="Cancel"
/>
</EuiButtonEmpty>
@ -169,7 +169,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
fullWidth
label={
<FormattedMessage
id="kibana-react.savedObjects.saveModal.descriptionLabel"
id="savedObjects.saveModal.descriptionLabel"
defaultMessage="Description"
/>
}
@ -243,7 +243,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
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<Props, State> {
<EuiCallOut
title={
<FormattedMessage
id="kibana-react.savedObjects.saveModal.duplicateTitleLabel"
id="savedObjects.saveModal.duplicateTitleLabel"
defaultMessage="A {objectType} with the title '{title}' already exists"
values={{ objectType: this.props.objectType, title: this.state.title }}
/>
@ -288,7 +288,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
>
<p>
<FormattedMessage
id="kibana-react.savedObjects.saveModal.duplicateTitleDescription"
id="savedObjects.saveModal.duplicateTitleDescription"
defaultMessage="Clicking {confirmSaveLabel} overwrites the existing {objectType}."
values={{
objectType: this.props.objectType,
@ -296,7 +296,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
<strong>
{this.props.confirmButtonLabel
? this.props.confirmButtonLabel
: i18n.translate('kibana-react.savedObjects.saveModal.saveButtonLabel', {
: i18n.translate('savedObjects.saveModal.saveButtonLabel', {
defaultMessage: 'Save',
})}
</strong>
@ -324,7 +324,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
onChange={this.onCopyOnSaveChange}
label={
<FormattedMessage
id="kibana-react.savedObjects.saveModal.saveAsNewLabel"
id="savedObjects.saveModal.saveAsNewLabel"
defaultMessage="Save as new {objectType}"
values={{ objectType: this.props.objectType }}
/>

View file

@ -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<SaveResult>;
onClose: () => void;
}
export function showSaveModal(saveModal: React.ReactElement<MinimalSaveModalProps>) {
export function showSaveModal(
saveModal: React.ReactElement<MinimalSaveModalProps>,
I18nContext: I18nStart['Context']
) {
const container = document.createElement('div');
const closeModal = () => {
ReactDOM.unmountComponentAtNode(container);

View file

@ -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) => (
<SavedObjectFinderUi
{...props}
savedObjects={core.savedObjects}
uiSettings={core.uiSettings}
/>
);
ReactDOM.render(
<App
getActions={plugins.uiActions.getTriggerCompatibleActions}
@ -116,7 +106,7 @@ export class EmbeddableExplorerPublicPlugin
notifications={core.notifications}
overlays={core.overlays}
inspector={plugins.inspector}
SavedObjectFinder={SavedObjectFinder}
SavedObjectFinder={getSavedObjectFinder(core.savedObjects, core.uiSettings)}
I18nContext={core.i18n.Context}
/>,
root

View file

@ -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) => (
<SavedObjectFinderUi
{...props}
savedObjects={npStart.core.savedObjects}
uiSettings={npStart.core.uiSettings}
/>
);
return (
<div
className="embeddable"
@ -53,7 +43,10 @@ const renderEmbeddable = (embeddableObject: IEmbeddable, domNode: HTMLElement) =
notifications={npStart.core.notifications}
overlays={npStart.core.overlays}
inspector={npStart.plugins.inspector}
SavedObjectFinder={SavedObjectFinder}
SavedObjectFinder={getSavedObjectFinder(
npStart.core.savedObjects,
npStart.core.uiSettings
)}
/>
</I18nContext>
</div>

View file

@ -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';

View file

@ -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

View file

@ -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';

View file

@ -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 {

View file

@ -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';

View file

@ -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
);
}

View file

@ -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(),

View file

@ -199,5 +199,6 @@ function showModal(
workspace: savedWorkspace,
showSaveModal: deps.showSaveModal,
saveWorkspace: saveWorkspaceHandler,
I18nContext: deps.I18nContext,
});
}

View file

@ -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) {

View file

@ -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';

View file

@ -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);
},
},
]

View file

@ -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;

View file

@ -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) => (
<SavedObjectFinderUi
{...props}
savedObjects={services.savedObjects}
uiSettings={services.uiSettings}
/>
);
return isError ? null : (
<Embeddable>
<EmbeddableHeader title={i18n.EMBEDDABLE_HEADER_TITLE}>
@ -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 ? (
<IndexPatternsMissingPrompt data-test-subj="missing-prompt" />

View file

@ -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 {

View file

@ -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": "緑",

View file

@ -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": "绿",