Skip to content

Commit

Permalink
[8.x] [embeddable] remove reactEmbeddableRegistryHasKey from start API (
Browse files Browse the repository at this point in the history
#203673) (#203951)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[embeddable] remove reactEmbeddableRegistryHasKey from start API
(#203673)](#203673)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nathan
Reese","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-11T20:25:21Z","message":"[embeddable]
remove reactEmbeddableRegistryHasKey from start API (#203673)\n\nCloses
https://github.com/elastic/kibana/issues/203250\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"7b9dd357ef568f25427b7bf70fa00e057f952c05","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Embedding","Team:Presentation","release_note:skip","v9.0.0","project:embeddableRebuild","backport:version","v8.18.0"],"number":203673,"url":"https://github.com/elastic/kibana/pull/203673","mergeCommit":{"message":"[embeddable]
remove reactEmbeddableRegistryHasKey from start API (#203673)\n\nCloses
https://github.com/elastic/kibana/issues/203250\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"7b9dd357ef568f25427b7bf70fa00e057f952c05"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203673","number":203673,"mergeCommit":{"message":"[embeddable]
remove reactEmbeddableRegistryHasKey from start API (#203673)\n\nCloses
https://github.com/elastic/kibana/issues/203250\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"7b9dd357ef568f25427b7bf70fa00e057f952c05"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
nreese and elasticmachine authored Dec 12, 2024
1 parent 224e36e commit acefaf4
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 acefaf4

Please sign in to comment.