Skip to content

Commit

Permalink
[NP] Move saved object modal into new platform (#56383)
Browse files Browse the repository at this point in the history
* Move saved object modal into new platform

* Fix TS

* Revert "Fix TS"

This reverts commit f2f9f5e.

* Revert "Move saved object modal into new platform"

This reverts commit d0f0ea6.

# 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 <[email protected]>
  • Loading branch information
maryia-lapata and elasticmachine authored Feb 6, 2020
1 parent f736072 commit f4f5b04
Show file tree
Hide file tree
Showing 51 changed files with 177 additions and 210 deletions.
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import {
ConfirmationButtonTypes,
migrateLegacyQuery,
SavedObjectSaveOpts,
SaveResult,
showSaveModal,
subscribeWithScope,
} from '../legacy_imports';
import {
Expand All @@ -45,6 +43,11 @@ import {
syncAppFilters,
syncQuery,
} from '../../../../../../plugins/data/public';
import {
SaveResult,
showSaveModal,
getSavedObjectFinder,
} from '../../../../../../plugins/saved_objects/public';

import {
DASHBOARD_CONTAINER_TYPE,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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),
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -48,12 +52,10 @@ import {
hasSearchStategyForIndexPattern,
intervalOptions,
migrateLegacyQuery,
showSaveModal,
unhashUrl,
stateMonitorFactory,
subscribeWithScope,
tabifyAggResponse,
SavedObjectSaveModal,
getAngularModule,
ensureDefaultIndexPattern,
registerTimefilterWithGlobalStateFactory,
Expand Down Expand Up @@ -305,7 +307,7 @@ function discoverController(
})}
/>
);
showSaveModal(saveModal);
showSaveModal(saveModal, core.i18n.Context);
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
SavedObjectsClientContract,
ToastsStart,
IUiSettingsClient,
I18nStart,
} from 'kibana/public';

import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public';
Expand Down Expand Up @@ -57,6 +58,7 @@ export interface VisualizeKibanaServices {
visualizeCapabilities: any;
visualizations: VisualizationsStart;
usageCollection?: UsageCollectionSetup;
I18nContext: I18nStart['Context'];
}

let services: VisualizeKibanaServices | null = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -40,8 +44,6 @@ import {
absoluteToParsedUrl,
KibanaParsedUrl,
migrateLegacyQuery,
SavedObjectSaveModal,
showSaveModal,
stateMonitorFactory,
DashboardConstants,
} from '../../legacy_imports';
Expand Down Expand Up @@ -94,6 +96,7 @@ function VisualizeAppController(
core: { docLinks },
savedQueryService,
uiSettings,
I18nContext,
} = getServices();

const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager);
Expand Down Expand Up @@ -191,7 +194,7 @@ function VisualizeAppController(
description={savedVis.description}
/>
);
showSaveModal(saveModal);
showSaveModal(saveModal, I18nContext);
},
},
]
Expand Down
1 change: 1 addition & 0 deletions src/legacy/core_plugins/kibana/public/visualize/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class VisualizePlugin implements Plugin {
visualizeCapabilities: contextCore.application.capabilities.visualize,
visualizations,
usageCollection,
I18nContext: contextCore.i18n.Context,
};
setServices(deps);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/saved_objects/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@import '../../../../plugins/kibana_react/public/saved_objects/index';
@import '../../../../plugins/saved_objects/public/index';
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 2 additions & 12 deletions src/plugins/dashboard_embeddable_container/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(() => {
Expand Down
9 changes: 0 additions & 9 deletions src/plugins/dashboard_embeddable_container/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import { IconType } from '@elastic/eui';
import { SavedObject as SavedObjectType, SavedObjectAttributes } from '../../../core/public';

export interface DashboardCapabilities {
Expand Down Expand Up @@ -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 };
Expand Down
1 change: 0 additions & 1 deletion src/plugins/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export {
PanelNotFoundError,
PanelState,
PropertySpec,
SavedObjectMetaData,
ViewMode,
isErrorEmbeddable,
openAddPanelFlyout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -40,7 +40,7 @@ export interface OutputSpec {
[key: string]: PropertySpec;
}

export interface EmbeddableFactoryOptions<T> {
export interface EmbeddableFactoryOptions<T extends SavedObjectAttributes> {
savedObjectMetaData?: SavedObjectMetaData<T>;
}

Expand Down
11 changes: 0 additions & 11 deletions src/plugins/embeddable/public/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
1 change: 0 additions & 1 deletion src/plugins/kibana_react/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

export * from './code_editor';
export * from './saved_objects';
export * from './exit_full_screen_button';
export * from './context';
export * from './overlays';
Expand Down
1 change: 1 addition & 0 deletions src/plugins/saved_objects/public/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './save_modal/index';
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading

0 comments on commit f4f5b04

Please sign in to comment.