Skip to content

Commit

Permalink
[8.x] [embeddable] remove getAttributeService from start API (#203660) (
Browse files Browse the repository at this point in the history
#204059)

# Backport

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

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Nathan
Reese","email":"reese.nathan@elastic.co"},"sourceCommit":{"committedDate":"2024-12-12T15:38:11Z","message":"[embeddable]
remove getAttributeService from start API (#203660)\n\nPart of
embeddable refactor cleanup\r\n\r\nAttributeService is moved from
embeddable plugin to visualizations\r\nplugin.\r\n\r\nPR reduces
visualizations bundle size by avoiding
importing\r\n`legacy/embeddable/index.ts` in plugin page
load\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"9ce523939279bdeba399b447849db47fa0877a23","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"],"title":"[embeddable]
remove getAttributeService from start
API","number":203660,"url":"https://github.com/elastic/kibana/pull/203660","mergeCommit":{"message":"[embeddable]
remove getAttributeService from start API (#203660)\n\nPart of
embeddable refactor cleanup\r\n\r\nAttributeService is moved from
embeddable plugin to visualizations\r\nplugin.\r\n\r\nPR reduces
visualizations bundle size by avoiding
importing\r\n`legacy/embeddable/index.ts` in plugin page
load\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"9ce523939279bdeba399b447849db47fa0877a23"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203660","number":203660,"mergeCommit":{"message":"[embeddable]
remove getAttributeService from start API (#203660)\n\nPart of
embeddable refactor cleanup\r\n\r\nAttributeService is moved from
embeddable plugin to visualizations\r\nplugin.\r\n\r\nPR reduces
visualizations bundle size by avoiding
importing\r\n`legacy/embeddable/index.ts` in plugin page
load\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"9ce523939279bdeba399b447849db47fa0877a23"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Nathan Reese <reese.nathan@elastic.co>
  • Loading branch information
kibanamachine and nreese authored Dec 12, 2024
1 parent 0211643 commit 4d0170a
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 316 deletions.
2 changes: 1 addition & 1 deletion src/plugins/embeddable/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"contentManagement"
],
"optionalPlugins": ["savedObjectsTaggingOss", "usageCollection"],
"requiredBundles": ["savedObjects", "kibanaUtils", "presentationPanel"],
"requiredBundles": ["kibanaUtils", "presentationPanel"],
"extraPublicDirs": ["common"]
}
}
1 change: 0 additions & 1 deletion src/plugins/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export type {
SelfStyledEmbeddable,
ValueClickContext,
} from './lib';
export { AttributeService, ATTRIBUTE_SERVICE_KEY } from './lib/attribute_service';
export type {
EmbeddableSetup,
EmbeddableSetupDependencies,
Expand Down

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/plugins/embeddable/public/lib/attribute_service/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/plugins/embeddable/public/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { EmbeddablePublicPlugin } from './plugin';
import { registerReactEmbeddableFactory } from './react_embeddable_system';
import { registerAddFromLibraryType } from './add_from_library/registry';

export { mockAttributeService } from './lib/attribute_service/attribute_service.mock';
export type Setup = jest.Mocked<EmbeddableSetup>;
export type Start = jest.Mocked<EmbeddableStart>;

Expand Down Expand Up @@ -114,7 +113,6 @@ const createStartContract = (): Start => {
inject: jest.fn(),
getAllMigrations: jest.fn(),
getStateTransfer: jest.fn(() => createEmbeddableStateTransferMock() as EmbeddableStateTransfer),
getAttributeService: jest.fn(),
};
return startContract;
};
Expand Down
18 changes: 0 additions & 18 deletions src/plugins/embeddable/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ import {
EmbeddableOutput,
defaultEmbeddableFactoryProvider,
IEmbeddable,
SavedObjectEmbeddableInput,
} from './lib';
import { EmbeddableFactoryDefinition } from './lib/embeddables/embeddable_factory_definition';
import { EmbeddableStateTransfer } from './lib/state_transfer';
import { ATTRIBUTE_SERVICE_KEY, AttributeService } from './lib/attribute_service';
import { AttributeServiceOptions } from './lib/attribute_service/attribute_service';
import { EmbeddableStateWithType, CommonEmbeddableStartContract } from '../common/types';
import {
getExtractFunction,
Expand Down Expand Up @@ -134,19 +131,6 @@ export interface EmbeddableStart extends PersistableStateService<EmbeddableState
*/
getEmbeddableFactories: () => IterableIterator<EmbeddableFactory>;
getStateTransfer: (storage?: Storage) => EmbeddableStateTransfer;
getAttributeService: <
A extends { title: string },
V extends EmbeddableInput & {
[ATTRIBUTE_SERVICE_KEY]: A;
} = EmbeddableInput & {
[ATTRIBUTE_SERVICE_KEY]: A;
},
R extends SavedObjectEmbeddableInput = SavedObjectEmbeddableInput,
M extends unknown = unknown
>(
type: string,
options: AttributeServiceOptions<A, M>
) => AttributeService<A, V, R, M>;
}
export class EmbeddablePublicPlugin implements Plugin<EmbeddableSetup, EmbeddableStart> {
private readonly embeddableFactoryDefinitions: Map<string, EmbeddableFactoryDefinition> =
Expand Down Expand Up @@ -218,8 +202,6 @@ export class EmbeddablePublicPlugin implements Plugin<EmbeddableSetup, Embeddabl
const embeddableStart: EmbeddableStart = {
getEmbeddableFactory: this.getEmbeddableFactory,
getEmbeddableFactories: this.getEmbeddableFactories,
getAttributeService: (type: string, options) =>
new AttributeService(type, core.notifications.toasts, options, this.getEmbeddableFactory),
getStateTransfer: (storage?: Storage) =>
storage
? new EmbeddableStateTransfer(
Expand Down
1 change: 0 additions & 1 deletion src/plugins/embeddable/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"kbn_references": [
"@kbn/core",
"@kbn/inspector-plugin",
"@kbn/saved-objects-plugin",
"@kbn/kibana-utils-plugin",
"@kbn/ui-actions-plugin",
"@kbn/utility-types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@
*/

import { contentManagementMock } from '@kbn/content-management-plugin/public/mocks';
import { coreMock } from '@kbn/core/public/mocks';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import { AttributeService, type EmbeddableStart } from '@kbn/embeddable-plugin/public';
import { spacesPluginMock } from '@kbn/spaces-plugin/public/mocks';
import { SavedSearchByValueAttributes, byValueToSavedSearch } from '.';

const mockServices = {
contentManagement: contentManagementMock.createStartContract().client,
search: dataPluginMock.createStartContract().search,
spaces: spacesPluginMock.createStartContract(),
embeddable: {
getAttributeService: jest.fn(
(_, opts) => new AttributeService('search', coreMock.createStart().notifications.toasts, opts)
),
} as unknown as EmbeddableStart,
};

describe('toSavedSearch', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import {
import { Action } from '@kbn/ui-actions-plugin/public';
import React from 'react';
import { take } from 'rxjs';
import { apiHasVisualizeConfig, HasVisualizeConfig } from '../legacy/embeddable';
import {
apiHasVisualizeConfig,
type HasVisualizeConfig,
} from '../embeddable/interfaces/has_visualize_config';
import {
apiHasExpressionVariables,
HasExpressionVariables,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/visualizations/public/embeddable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
SerializedTitles,
} from '@kbn/presentation-publishing';
import { DeepPartial } from '@kbn/utility-types';
import { HasVisualizeConfig } from '../legacy/embeddable';
import type { HasVisualizeConfig } from './interfaces/has_visualize_config';
import type { Vis, VisParams, VisSavedObject } from '../types';
import type { SerializedVis } from '../vis';

Expand Down
6 changes: 4 additions & 2 deletions src/plugins/visualizations/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export function plugin(initializerContext: PluginInitializerContext) {
/** @public static code */
export { TypesService } from './vis_types/types_service';
export { VIS_EVENT_TO_TRIGGER } from './embeddable';
export { apiHasVisualizeConfig, COMMON_VISUALIZATION_GROUPING } from './legacy/embeddable';
export { apiHasVisualizeConfig } from './embeddable/interfaces/has_visualize_config';
export { COMMON_VISUALIZATION_GROUPING } from './legacy/embeddable/constants';
export { VisualizationContainer } from './components';
export { getVisSchemas } from './vis_schemas';

Expand All @@ -41,7 +42,8 @@ export type VisualizeEmbeddableFactoryContract = PublicContract<VisualizeEmbedda
export type VisualizeEmbeddableContract = PublicContract<VisualizeEmbeddable>;
export type { SchemaConfig } from '../common/types';
export { updateOldState } from './legacy/vis_update_state';
export type { VisualizeInput, VisualizeEmbeddable, HasVisualizeConfig } from './legacy/embeddable';
export type { VisualizeInput, VisualizeEmbeddable } from './legacy/embeddable';
export type { HasVisualizeConfig } from './embeddable/interfaces/has_visualize_config';
export type { PersistedState } from './persisted_state';
export type {
ISavedVis,
Expand Down
Loading

0 comments on commit 4d0170a

Please sign in to comment.