Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to get rid of SavedObjectClass #192265

Merged
merged 10 commits into from
Sep 20, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const savedObjectsTaggingServiceFactory: SavedObjectsTaggingServiceFactor

// I'm not defining components so that I don't have to update the snapshot of `save_modal.test`
// However, if it's ever necessary, it can be done via: `components: pluginMock.components`,
hasTagDecoration: pluginMock.hasTagDecoration,
parseSearchQuery: pluginMock.parseSearchQuery,
getSearchBarFilter: pluginMock.getSearchBarFilter,
getTagIdsFromReferences: pluginMock.getTagIdsFromReferences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const savedObjectsTaggingServiceFactory: SavedObjectsTaggingServiceFactor
ui: {
components,
parseSearchQuery,
hasTagDecoration,
getSearchBarFilter,
updateTagsReferences,
getTagIdsFromReferences,
Expand All @@ -42,7 +41,6 @@ export const savedObjectsTaggingServiceFactory: SavedObjectsTaggingServiceFactor
hasApi: true,
api: taggingApi,
components,
hasTagDecoration,
parseSearchQuery,
getSearchBarFilter,
updateTagsReferences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface DashboardSavedObjectsTaggingService {
hasApi: boolean; // remove this once the entire service is optional
api?: SavedObjectsTaggingApi;
components?: SavedObjectsTaggingApi['ui']['components'];
hasTagDecoration?: SavedObjectsTaggingApi['ui']['hasTagDecoration'];
parseSearchQuery?: SavedObjectsTaggingApi['ui']['parseSearchQuery'];
getSearchBarFilter?: SavedObjectsTaggingApi['ui']['getSearchBarFilter'];
updateTagsReferences?: SavedObjectsTaggingApi['ui']['updateTagsReferences'];
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/saved_objects/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"requiredPlugins": [
"data",
"dataViews"
],
"requiredBundles": [
"kibanaUtils"
]
}
}
6 changes: 0 additions & 6 deletions src/plugins/saved_objects/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import { SavedObjectsPublicPlugin } from './plugin';

export type { OnSaveProps, OriginSaveModalProps, SaveModalState, SaveResult } from './save_modal';
export { SavedObjectSaveModal, SavedObjectSaveModalOrigin, showSaveModal } from './save_modal';
export type {
SavedObjectDecorator,
SavedObjectDecoratorFactory,
SavedObjectDecoratorConfig,
} from './saved_object';
export { checkForDuplicateTitle, saveWithConfirmation, isErrorNonFatal } from './saved_object';
export type { SavedObjectSaveOpts, SavedObject, SavedObjectConfig } from './types';
export type { SavedObjectsStart, SavedObjectSetup } from './plugin';

export const plugin = () => new SavedObjectsPublicPlugin();
19 changes: 1 addition & 18 deletions src/plugins/saved_objects/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,4 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { SavedObjectsStart, SavedObjectSetup } from './plugin';

const createStartContract = (): SavedObjectsStart => {
return {
SavedObjectClass: jest.fn(),
};
};

const createSetupContract = (): jest.Mocked<SavedObjectSetup> => {
return {
registerDecorator: jest.fn(),
};
};

export const savedObjectsPluginMock = {
createStartContract,
createSetupContract,
};
export const savedObjectsPluginMock = {};
44 changes: 4 additions & 40 deletions src/plugins/saved_objects/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,19 @@ import { CoreStart, Plugin } from '@kbn/core/public';
import './index.scss';
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import {
createSavedObjectClass,
SavedObjectDecoratorRegistry,
SavedObjectDecoratorConfig,
} from './saved_object';
import { SavedObject } from './types';
import { setStartServices } from './kibana_services';

export interface SavedObjectSetup {
registerDecorator: (config: SavedObjectDecoratorConfig<any>) => void;
}

export interface SavedObjectsStart {
/**
* @deprecated
* @removeBy 8.8.0
*/
SavedObjectClass: new (raw: Record<string, any>) => SavedObject;
}

export interface SavedObjectsStartDeps {
data: DataPublicPluginStart;
dataViews: DataViewsPublicPluginStart;
}

export class SavedObjectsPublicPlugin
implements Plugin<SavedObjectSetup, SavedObjectsStart, object, SavedObjectsStartDeps>
{
private decoratorRegistry = new SavedObjectDecoratorRegistry();

public setup(): SavedObjectSetup {
return {
registerDecorator: (config) => this.decoratorRegistry.register(config),
};
export class SavedObjectsPublicPlugin implements Plugin<{}, {}, object, SavedObjectsStartDeps> {
public setup() {
return {};
}
public start(core: CoreStart, { data, dataViews }: SavedObjectsStartDeps) {
setStartServices(core);
return {
SavedObjectClass: createSavedObjectClass(
{
dataViews,
savedObjectsClient: core.savedObjects.client,
search: data.search,
chrome: core.chrome,
overlays: core.overlays,
},
core,
this.decoratorRegistry
),
};
return {};
}
}
12 changes: 0 additions & 12 deletions src/plugins/saved_objects/public/saved_object/decorators/index.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions src/plugins/saved_objects/public/saved_object/decorators/types.ts

This file was deleted.

Loading