Skip to content

Commit

Permalink
Migrate SO management section to NP (elastic#61700)
Browse files Browse the repository at this point in the history
* move libs to new plugin

* adapt libs to use NP apis

* add required plugins

* add get_allowed_types route

* move object_view components

* add service registry

* migrate table header component

* migrate table component

* migrate saved_objects_table component

* remove migrated legacy files

* fix re-export from legacy management + section label

* migrate services registration

* adapt management section mock

* fix imports

* migrate flyout component

* migrate relationships component

* migrate saved_objects_table tests

* migrate breadcrumb

* add redirect if unauthorized check

* migrate translations to new savedObjectsManagement prefix

* remove obsolete translations

* convert action registry to service pattern

* wire extra actions

* remove importAndExportableTypes from injected vars

* handle newIndexPatternUrl

* remove duplicate dashboard dependency

* remove old TODO

* remove old TODO

* properly mock lodash in tests

* add async management section loading

* expose createSavedSearchesLoader from discover plugin contract

* address most review comments

* fix merge conflicts
  • Loading branch information
pgayvallet committed Apr 13, 2020
1 parent f410b63 commit a2b168a
Show file tree
Hide file tree
Showing 110 changed files with 2,184 additions and 1,689 deletions.
6 changes: 3 additions & 3 deletions src/core/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export { overlayServiceMock } from './overlays/overlay_service.mock';
export { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
export { savedObjectsServiceMock } from './saved_objects/saved_objects_service.mock';
export { scopedHistoryMock } from './application/scoped_history.mock';
export { applicationServiceMock } from './application/application_service.mock';

function createCoreSetupMock({
basePath = '',
Expand All @@ -62,9 +63,8 @@ function createCoreSetupMock({
application: applicationServiceMock.createSetupContract(),
context: contextServiceMock.createSetupContract(),
fatalErrors: fatalErrorsServiceMock.createSetupContract(),
getStartServices: jest.fn<Promise<[ReturnType<typeof createCoreStartMock>, object, any]>, []>(
() =>
Promise.resolve([createCoreStartMock({ basePath }), pluginStartDeps, pluginStartContract])
getStartServices: jest.fn<Promise<[ReturnType<typeof createCoreStartMock>, any, any]>, []>(() =>
Promise.resolve([createCoreStartMock({ basePath }), pluginStartDeps, pluginStartContract])
),
http: httpServiceMock.createSetupContract({ basePath }),
notifications: notificationServiceMock.createSetupContract(),
Expand Down
1 change: 0 additions & 1 deletion src/core/server/saved_objects/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export interface SavedObjectsLegacyService {
getScopedSavedObjectsClient: SavedObjectsClientProvider['getClient'];
SavedObjectsClient: typeof SavedObjectsClient;
types: string[];
importAndExportableTypes: string[];
schema: SavedObjectsSchema;
getSavedObjectsRepository(...rest: any[]): any;
importExport: {
Expand Down
2 changes: 0 additions & 2 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2084,8 +2084,6 @@ export interface SavedObjectsLegacyService {
// (undocumented)
getScopedSavedObjectsClient: SavedObjectsClientProvider['getClient'];
// (undocumented)
importAndExportableTypes: string[];
// (undocumented)
importExport: {
objectLimit: number;
importSavedObjects(options: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse>;
Expand Down
3 changes: 0 additions & 3 deletions src/legacy/core_plugins/kibana/inject_vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
export function injectVars(server) {
const serverConfig = server.config();

const { importAndExportableTypes } = server.savedObjects;

return {
importAndExportableTypes,
autocompleteTerminateAfter: serverConfig.get('kibana.autocompleteTerminateAfter'),
autocompleteTimeout: serverConfig.get('kibana.autocompleteTimeout'),
};
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
export {
ProcessedImportResponse,
processImportResponse,
} from './management/sections/objects/lib/process_import_response';
} from '../../../../plugins/saved_objects_management/public/lib';
Original file line number Diff line number Diff line change
Expand Up @@ -17,66 +17,8 @@
* under the License.
*/

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { npStart } from 'ui/new_platform';
import { SavedObjectLoader } from '../../../../../plugins/saved_objects/public';
import { createSavedSearchesLoader } from '../../../../../plugins/discover/public';
import { npSetup } from 'ui/new_platform';

/**
* This registry is used for the editing mode of Saved Searches, Visualizations,
* Dashboard and Time Lion saved objects.
*/
interface SavedObjectRegistryEntry {
id: string;
service: SavedObjectLoader;
title: string;
}

export interface ISavedObjectsManagementRegistry {
register(service: SavedObjectRegistryEntry): void;
all(): SavedObjectRegistryEntry[];
get(id: string): SavedObjectRegistryEntry | undefined;
}

const registry: SavedObjectRegistryEntry[] = [];

export const savedObjectManagementRegistry: ISavedObjectsManagementRegistry = {
register: (service: SavedObjectRegistryEntry) => {
registry.push(service);
},
all: () => {
return registry;
},
get: (id: string) => {
return _.find(registry, { id });
},
};

const services = {
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
search: npStart.plugins.data.search,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
};

savedObjectManagementRegistry.register({
id: 'savedVisualizations',
service: npStart.plugins.visualizations.savedVisualizationsLoader,
title: 'visualizations',
});

savedObjectManagementRegistry.register({
id: 'savedDashboards',
service: npStart.plugins.dashboard.getSavedDashboardLoader(),
title: i18n.translate('kbn.dashboard.savedDashboardsTitle', {
defaultMessage: 'dashboards',
}),
});
const registry = npSetup.plugins.savedObjectsManagement?.serviceRegistry;

savedObjectManagementRegistry.register({
id: 'savedSearches',
service: createSavedSearchesLoader(services),
title: 'searches',
});
export const savedObjectManagementRegistry = registry!;
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
* under the License.
*/

import './objects';
import './index_patterns';

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a2b168a

Please sign in to comment.