Skip to content

Commit

Permalink
[8.x] Backport Attempt to get rid of SavedObjectClass (#192265) (#196130
Browse files Browse the repository at this point in the history
)

## Summary

Manual backport of "Attempt to get rid of SavedObjectClass (#192265)"

### Checklist

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine
<[email protected]>
(cherry picked from commit ac29d0f)

# Conflicts:
#
src/plugins/dashboard/public/services/saved_objects_tagging/saved_objects_tagging.stub.ts
#
src/plugins/dashboard/public/services/saved_objects_tagging/saved_objects_tagging_service.ts
# src/plugins/dashboard/public/services/saved_objects_tagging/types.ts

## Summary

Summarize your PR. If it involves visual changes include a screenshot or
gif.


### Checklist
  • Loading branch information
rudolf authored Oct 15, 2024
1 parent 89f85ab commit 0e205fa
Show file tree
Hide file tree
Showing 41 changed files with 10 additions and 2,022 deletions.
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

0 comments on commit 0e205fa

Please sign in to comment.