Skip to content

Commit

Permalink
[embeddable] remove reactEmbeddableRegistryHasKey from start API (#20…
Browse files Browse the repository at this point in the history
…3673)

Closes #203250

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 11, 2024
1 parent 520c7c6 commit 7b9dd35
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 40 deletions.
12 changes: 0 additions & 12 deletions src/plugins/embeddable/public/lib/containers/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
IContainer,
PanelState,
} from './i_container';
import { reactEmbeddableRegistryHasKey } from '../../react_embeddable_system';

const getKeys = <T extends {}>(o: T): Array<keyof T> => Object.keys(o) as Array<keyof T>;

Expand Down Expand Up @@ -548,17 +547,6 @@ export abstract class Container<
}

private async onPanelAdded(panel: PanelState) {
// do nothing if this panel's type is in the new Embeddable registry.
if (reactEmbeddableRegistryHasKey(panel.type)) {
this.updateOutput({
embeddableLoaded: {
...this.output.embeddableLoaded,
[panel.explicitInput.id]: true,
},
} as Partial<TContainerOutput>);
return;
}

this.updateOutput({
embeddableLoaded: {
...this.output.embeddableLoaded,
Expand Down
6 changes: 1 addition & 5 deletions src/plugins/embeddable/public/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ import {
import { setKibanaServices } from './kibana_services';
import { SelfStyledOptions } from './lib/self_styled_embeddable/types';
import { EmbeddablePublicPlugin } from './plugin';
import {
reactEmbeddableRegistryHasKey,
registerReactEmbeddableFactory,
} from './react_embeddable_system';
import { registerReactEmbeddableFactory } from './react_embeddable_system';
import { registerAddFromLibraryType } from './add_from_library/registry';

export { mockAttributeService } from './lib/attribute_service/attribute_service.mock';
Expand Down Expand Up @@ -110,7 +107,6 @@ const createSetupContract = (): Setup => {

const createStartContract = (): Start => {
const startContract: Start = {
reactEmbeddableRegistryHasKey: jest.fn().mockImplementation(reactEmbeddableRegistryHasKey),
getEmbeddableFactories: jest.fn(),
getEmbeddableFactory: jest.fn(),
telemetry: jest.fn(),
Expand Down
12 changes: 1 addition & 11 deletions src/plugins/embeddable/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ import {
} from '../common/lib';
import { getAllMigrations } from '../common/lib/get_all_migrations';
import { setKibanaServices } from './kibana_services';
import {
reactEmbeddableRegistryHasKey,
registerReactEmbeddableFactory,
} from './react_embeddable_system';
import { registerReactEmbeddableFactory } from './react_embeddable_system';
import { registerAddFromLibraryType } from './add_from_library/registry';

export interface EmbeddableSetupDependencies {
Expand Down Expand Up @@ -121,11 +118,6 @@ export interface EmbeddableSetup {
}

export interface EmbeddableStart extends PersistableStateService<EmbeddableStateWithType> {
/**
* Checks if a {@link ReactEmbeddableFactory} has been registered using {@link registerReactEmbeddableFactory}
*/
reactEmbeddableRegistryHasKey: (type: string) => boolean;

/**
* @deprecated use {@link registerReactEmbeddableFactory} instead.
*/
Expand Down Expand Up @@ -224,8 +216,6 @@ export class EmbeddablePublicPlugin implements Plugin<EmbeddableSetup, Embeddabl
);

const embeddableStart: EmbeddableStart = {
reactEmbeddableRegistryHasKey,

getEmbeddableFactory: this.getEmbeddableFactory,
getEmbeddableFactories: this.getEmbeddableFactories,
getAttributeService: (type: string, options) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export {
reactEmbeddableRegistryHasKey,
registerReactEmbeddableFactory,
} from './react_embeddable_registry';
export { registerReactEmbeddableFactory } from './react_embeddable_registry';
export { ReactEmbeddableRenderer } from './react_embeddable_renderer';
export type { DefaultEmbeddableApi, ReactEmbeddableFactory } from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import {
registerReactEmbeddableFactory,
reactEmbeddableRegistryHasKey,
getReactEmbeddableFactory,
} from './react_embeddable_registry';
import { ReactEmbeddableFactory } from './types';
Expand All @@ -33,9 +32,4 @@ describe('react embeddable registry', () => {
registerReactEmbeddableFactory('test', getTestEmbeddableFactory);
expect(getReactEmbeddableFactory('test')).toEqual(returnedFactory);
});

it('can check if a factory is registered', () => {
expect(reactEmbeddableRegistryHasKey('test')).toBe(true);
expect(reactEmbeddableRegistryHasKey('notRegistered')).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export const registerReactEmbeddableFactory = <
registry[type] = getFactory;
};

export const reactEmbeddableRegistryHasKey = (key: string) => registry[key] !== undefined;

export const getReactEmbeddableFactory = async <
SerializedState extends object = object,
RuntimeState extends object = SerializedState,
Expand Down

0 comments on commit 7b9dd35

Please sign in to comment.