Skip to content

Commit

Permalink
Move saved object modal into new platform
Browse files Browse the repository at this point in the history
  • Loading branch information
maryia-lapata committed Jan 29, 2020
1 parent fd597e0 commit d0f0ea6
Show file tree
Hide file tree
Showing 42 changed files with 65 additions and 245 deletions.
1 change: 0 additions & 1 deletion src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,6 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy';
| `import 'ui/query_bar'` | `import { QueryStringInput } from '../data/public'` | Directives are deprecated. |
| `import 'ui/search_bar'` | `import { SearchBar } from '../data/public'` | Directive is deprecated. |
| `import 'ui/kbn_top_nav'` | `import { TopNavMenu } from '../navigation/public'` | Directive is still available in `ui/kbn_top_nav`. |
| `ui/saved_objects/components/saved_object_finder` | `import { SavedObjectFinder } from '../kibana_react/public'` | |
| `core_plugins/interpreter` | `data.expressions` | still in progress |
| `ui/courier` | `data.search` | still in progress |
| `ui/embeddable` | `embeddables` | still in progress |
Expand Down
1 change: 1 addition & 0 deletions src/core/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

@import './chrome/index';
@import './overlays/index';
@import './saved_objects/index';
9 changes: 9 additions & 0 deletions src/core/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ export {
SavedObjectsImportUnknownError,
SavedObjectsImportError,
SavedObjectsImportRetry,
showSaveModal,
SaveResult,
MinimalSaveModalProps,
SavedObjectSaveModal,
OnSaveProps,
SavedObjectMetaData,
SavedObjectFinderProps,
SavedObjectFinder,
SavedObjectFinderUi,
} from './saved_objects';

export {
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions src/core/public/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export {
} from './saved_objects_client';
export { SimpleSavedObject } from './simple_saved_object';
export { SavedObjectsStart, SavedObjectsService } from './saved_objects_service';
export { showSaveModal, SaveResult, MinimalSaveModalProps } from './show_saved_object_save_modal';
export { SavedObjectSaveModal, OnSaveProps } from './saved_object_save_modal';
export {
SavedObjectMetaData,
SavedObjectFinderProps,
SavedObjectFinder,
SavedObjectFinderUi,
} from './saved_object_finder';
export {
SavedObject,
SavedObjectAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import React from 'react';
import * as sinon from 'sinon';
import { SavedObjectFinderUi as SavedObjectFinder } from './saved_object_finder';
// eslint-disable-next-line
import { coreMock } from '../../../../core/public/mocks';
import { coreMock } from '../mocks';

describe('SavedObjectsFinder', () => {
const doc = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ import {
import { Direction } from '@elastic/eui/src/services/sort/sort_direction';
import { i18n } from '@kbn/i18n';

import { SavedObjectAttributes } from '../../../../core/public';
import { SimpleSavedObject, CoreStart } from '../../../../core/public';
import { useKibana } from '../context';
import { SavedObjectAttributes } from '.';
import { SimpleSavedObject, CoreStart } from '../';
import { useKibana } from '../../../plugins/kibana_react/public'; // eslint-disable-line @kbn/eslint/no-restricted-paths

// TODO the typings for EuiListGroup are incorrect - maxWidth is missing. This can be removed when the types are adjusted
const FixedEuiListGroup = (EuiListGroup as any) as React.FunctionComponent<
Expand Down Expand Up @@ -108,7 +108,7 @@ interface SavedObjectFinderInitialPageSize extends BaseSavedObjectFinder {

export type SavedObjectFinderProps = SavedObjectFinderFixedPage | SavedObjectFinderInitialPageSize;

export type SavedObjectFinderUiProps = {
type SavedObjectFinderUiProps = {
savedObjects: CoreStart['savedObjects'];
uiSettings: CoreStart['uiSettings'];
} & SavedObjectFinderProps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ import {
EuiSwitchEvent,
EuiTextArea,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@kbn/i18n/target/types/react';
import React from 'react';
import { EuiText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../../legacy/core_plugins/visualizations/public/embeddable/constants';
import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../legacy/core_plugins/visualizations/public/embeddable/constants'; // eslint-disable-line @kbn/eslint/no-restricted-paths

export interface OnSaveProps {
newTitle: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React from 'react';
import ReactDOM from 'react-dom';
import { I18nContext } from 'ui/i18n';
import { npStart } from 'ui/new_platform';

/**
* Represents the result of trying to persist the saved object.
Expand Down Expand Up @@ -62,5 +62,6 @@ export function showSaveModal(saveModal: React.ReactElement<MinimalSaveModalProp
onClose: closeModal,
});

const I18nContext = npStart.core.i18n.Context;
ReactDOM.render(<I18nContext>{element}</I18nContext>, container);
}
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 @@ -24,14 +24,18 @@ import angular from 'angular';

import { Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import {
SaveResult,
showSaveModal,
SavedObjectFinderProps,
SavedObjectFinderUi,
} from '../../../../../../core/public';
import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen';

import {
ConfirmationButtonTypes,
migrateLegacyQuery,
SavedObjectSaveOpts,
SaveResult,
showSaveModal,
subscribeWithScope,
} from '../legacy_imports';
import {
Expand Down Expand Up @@ -73,10 +77,6 @@ import { getDashboardTitle } from './dashboard_strings';
import { DashboardAppScope } from './dashboard_app';
import { convertSavedDashboardPanelToPanelState } from './lib/embeddable_saved_object_converters';
import { RenderDeps } from './application';
import {
SavedObjectFinderProps,
SavedObjectFinderUi,
} from '../../../../../../plugins/kibana_react/public';
import { removeQueryParam, unhashUrl } from '../../../../../../plugins/kibana_utils/public';

export interface DashboardAppControllerDependencies extends RenderDeps {
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('../../../../../../../core/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 '../../../../../../../core/public';

interface SaveOptions {
newTitle: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export { getRequestInspectorStats, getResponseInspectorStats } from '../../../da
export { intervalOptions } from 'ui/agg_types/buckets/_interval_options';
// @ts-ignore
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import dateMath from '@elastic/datemath';
import { i18n } from '@kbn/i18n';
import '../components/field_chooser/field_chooser';

import { showSaveModal, SavedObjectSaveModal } from '../../../../../../../core/public';
import { RequestAdapter } from '../../../../../../../plugins/inspector/public';
// doc table
import './doc_table';
Expand All @@ -47,13 +48,11 @@ import {
hasSearchStategyForIndexPattern,
intervalOptions,
migrateLegacyQuery,
showSaveModal,
unhashUrl,
stateMonitorFactory,
subscribeWithScope,
tabifyAggResponse,
Vis,
SavedObjectSaveModal,
getAngularModule,
ensureDefaultIndexPattern,
registerTimefilterWithGlobalStateFactory,
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,7 @@ import { getEditBreadcrumbs } from '../breadcrumbs';
import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util';
import { FilterStateManager } from '../../../../../data/public';
import { unhashUrl } from '../../../../../../../plugins/kibana_utils/public';
import { showSaveModal, SavedObjectSaveModal } from '../../../../../../../core/public';

import { initVisEditorDirective } from './visualization_editor';
import { initVisualizationDirective } from './visualization';
Expand All @@ -40,8 +41,6 @@ import {
absoluteToParsedUrl,
KibanaParsedUrl,
migrateLegacyQuery,
SavedObjectSaveModal,
showSaveModal,
stateMonitorFactory,
DashboardConstants,
} from '../../legacy_imports';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/

import { i18n } from '@kbn/i18n';
import { SavedObjectAttributes } from '../../../../core/public';
import { SavedObjectMetaData } from '../types';
import { SavedObjectAttributes, SavedObjectMetaData } from '../../../../core/public';
import {
ContainerOutput,
EmbeddableFactory,
Expand Down
11 changes: 8 additions & 3 deletions src/plugins/dashboard_embeddable_container/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@
/* eslint-disable max-classes-per-file */

import * as React from 'react';
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
import {
PluginInitializerContext,
CoreSetup,
CoreStart,
Plugin,
SavedObjectFinderUi,
SavedObjectFinderProps,
} from '../../../core/public';
import { IUiActionsSetup, IUiActionsStart } from '../../../plugins/ui_actions/public';
import { CONTEXT_MENU_TRIGGER, IEmbeddableSetup, IEmbeddableStart } from './embeddable_plugin';
import { ExpandPanelAction, ReplacePanelAction } from '.';
import { DashboardContainerFactory } from './embeddable/dashboard_container_factory';
import { Start as InspectorStartContract } from '../../../plugins/inspector/public';
import {
SavedObjectFinderUi,
SavedObjectFinderProps,
ExitFullScreenButton as ExitFullScreenButtonUi,
ExitFullScreenButtonProps,
} from '../../../plugins/kibana_react/public';
Expand Down
8 changes: 0 additions & 8 deletions src/plugins/dashboard_embeddable_container/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,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 @@ -51,7 +51,6 @@ export {
PanelNotFoundError,
PanelState,
PropertySpec,
SavedObjectMetaData,
ViewMode,
isErrorEmbeddable,
openAddPanelFlyout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* under the License.
*/

import { SavedObjectAttributes } from 'src/core/public';
import { SavedObjectMetaData } from '../types';
import { SavedObjectAttributes, SavedObjectMetaData } from 'src/core/public';
import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from './i_embeddable';
import { ErrorEmbeddable } from './error_embeddable';
import { IContainer } from '../containers/i_container';
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
Loading

0 comments on commit d0f0ea6

Please sign in to comment.