Skip to content

Commit

Permalink
[embeddable] remove embeddable class (#205164)
Browse files Browse the repository at this point in the history
Part of embeddable rebuild clean-up.

Removes legacy Embeddable class and types from embeddable plugin.

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
3 people authored Jan 2, 2025
1 parent ca28d2d commit 2ee9cbf
Show file tree
Hide file tree
Showing 33 changed files with 77 additions and 188 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export interface EmbeddableApiContext {
/**
* TODO: once all actions are entirely decoupled from the embeddable system, this key should be renamed to "api"
* to reflect the fact that this context could contain any api.
*/
embeddable: unknown;
}

export const isEmbeddableApiContext = (context: unknown): context is EmbeddableApiContext =>
!!context &&
typeof context === 'object' &&
!!(context as EmbeddableApiContext).embeddable &&
typeof (context as EmbeddableApiContext).embeddable === 'object';
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export interface EmbeddableApiContext {
/**
* TODO: once all actions are entirely decoupled from the embeddable system, this key should be renamed to "api"
* to reflect the fact that this context could contain any api.
*/
embeddable: unknown;
}
export { isEmbeddableApiContext, type EmbeddableApiContext } from './embeddable_api_context';

export {
getInitialValuesFromComparators,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ import {
ControlGroupSerializedState,
} from '@kbn/controls-plugin/public';
import { Filter, Query, TimeRange } from '@kbn/es-query';
import {
DefaultEmbeddableApi,
EmbeddablePackageState,
ErrorEmbeddable,
IEmbeddable,
} from '@kbn/embeddable-plugin/public';
import type { DefaultEmbeddableApi, EmbeddablePackageState } from '@kbn/embeddable-plugin/public';
import { Observable, Subject } from 'rxjs';
import { RefreshInterval, SearchSessionInfoProvider } from '@kbn/data-plugin/public';
import { IKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public';
Expand Down Expand Up @@ -175,9 +170,7 @@ export type DashboardApi = CanExpandPanels &
setTags: (tags: string[]) => void;
setTimeRange: (timeRange?: TimeRange | undefined) => void;
unifiedSearchFilters$: PublishesUnifiedSearch['filters$'];

// TODO remove types below this line - from legacy embeddable system
untilEmbeddableLoaded: (id: string) => Promise<IEmbeddable | ErrorEmbeddable>;
untilEmbeddableLoaded: (id: string) => Promise<unknown | undefined>;
};

export interface DashboardInternalApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ export const LATEST_DASHBOARD_CONTAINER_VERSION = convertNumberToDashboardVersio

export { LazyDashboardRenderer } from './external_api/lazy_dashboard_renderer';
export type { DashboardLocatorParams } from './types';
export type { IProvidesLegacyPanelPlacementSettings } from './panel_placement';
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export { placeClonePanel } from './place_clone_panel_strategy';

export { registerDashboardPanelPlacementSetting } from './panel_placement_registry';

export type { GetPanelPlacementSettings, IProvidesLegacyPanelPlacementSettings } from './types';
export type { GetPanelPlacementSettings } from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { EmbeddableInput } from '@kbn/embeddable-plugin/public';
import { MaybePromise } from '@kbn/utility-types';
import { DashboardPanelState } from '../../../common';
import type { GridData } from '../../../server/content_management';
Expand All @@ -30,16 +29,6 @@ export interface PanelPlacementProps {
currentPanels: { [key: string]: DashboardPanelState };
}

export interface IProvidesLegacyPanelPlacementSettings<
InputType extends EmbeddableInput = EmbeddableInput,
AttributesType = unknown
> {
getLegacyPanelPlacementSettings: (
input: InputType,
attributes?: AttributesType
) => Partial<PanelPlacementSettings>;
}

export type GetPanelPlacementSettings<SerializedState extends object = object> = (
serializedState?: SerializedState
) => MaybePromise<PanelPlacementSettings>;
1 change: 0 additions & 1 deletion src/platform/plugins/shared/dashboard/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export {
LazyDashboardRenderer as DashboardRenderer,
DASHBOARD_CONTAINER_TYPE,
type DashboardLocatorParams,
type IProvidesLegacyPanelPlacementSettings,
} from './dashboard_container';
export type { DashboardSetup, DashboardStart, DashboardFeatureFlagConfig } from './plugin';

Expand Down
7 changes: 0 additions & 7 deletions src/platform/plugins/shared/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export {
CELL_VALUE_TRIGGER,
contextMenuTrigger,
CONTEXT_MENU_TRIGGER,
Embeddable,
EmbeddableStateTransfer,
ErrorEmbeddable,
isContextMenuTriggerContext,
isMultiValueClickTriggerContext,
isRangeSelectTriggerContext,
isRowClickTriggerContext,
Expand All @@ -41,12 +38,8 @@ export {
export type {
CellValueContext,
ChartActionContext,
EmbeddableContext,
EmbeddableEditorState,
EmbeddableInput,
EmbeddableOutput,
EmbeddablePackageState,
IEmbeddable,
MultiValueClickContext,
PropertySpec,
RangeSelectContext,
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/platform/plugins/shared/embeddable/public/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

export * from './errors';
export * from './embeddables';
export * from './types';
export * from './triggers';
export * from './state_transfer';
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ import type { EmbeddableApiContext } from '@kbn/presentation-publishing';
import { Datatable, DatatableColumnMeta } from '@kbn/expressions-plugin/common';
import { Trigger, RowClickContext } from '@kbn/ui-actions-plugin/public';
import { BooleanRelation } from '@kbn/es-query';
import { IEmbeddable } from '..';

/**
* @deprecated use `EmbeddableApiContext` from `@kbn/presentation-publishing`
*/
export interface EmbeddableContext<T extends IEmbeddable = IEmbeddable> {
embeddable: T;
}

export type ValueClickContext = Partial<EmbeddableApiContext> & {
data: {
Expand Down Expand Up @@ -192,9 +184,3 @@ export const isRowClickTriggerContext = (context: ChartActionContext): context i
!!context.data &&
typeof context.data === 'object' &&
typeof (context as RowClickContext).data.rowIndex === 'number';

export const isContextMenuTriggerContext = (context: unknown): context is EmbeddableContext =>
!!context &&
typeof context === 'object' &&
!!(context as EmbeddableContext).embeddable &&
typeof (context as EmbeddableContext).embeddable === 'object';
1 change: 0 additions & 1 deletion src/platform/plugins/shared/embeddable/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"@kbn/utility-types",
"@kbn/es-query",
"@kbn/i18n",
"@kbn/std",
"@kbn/expressions-plugin",
"@kbn/saved-objects-management-plugin",
"@kbn/saved-objects-tagging-oss-plugin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Subscription } from 'rxjs';
import {
PANEL_HOVER_TRIGGER,
panelHoverTrigger,
type EmbeddableInput,
type ViewMode,
} from '@kbn/embeddable-plugin/public';
import { apiHasUniqueId } from '@kbn/presentation-publishing';
Expand All @@ -31,7 +30,7 @@ export interface FloatingActionsProps {
isEnabled?: boolean;
api?: unknown;
viewMode?: ViewMode;
disabledActions?: EmbeddableInput['disabledActions'];
disabledActions?: string[];
}

export type FloatingActionItem = AnyApiAction & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
*/

import { i18n } from '@kbn/i18n';
import { IEmbeddable } from '@kbn/embeddable-plugin/public';
import type { EmbeddableApiContext } from '@kbn/presentation-publishing';
import { UiActionsPresentableGrouping as PresentableGrouping } from '@kbn/ui-actions-plugin/public';

export const dynamicActionGrouping: PresentableGrouping<{
embeddable?: IEmbeddable;
}> = [
export const dynamicActionGrouping: PresentableGrouping<EmbeddableApiContext> = [
{
id: 'dynamicActions',
getDisplayName: () =>
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/visualizations/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"kibanaUtils",
"kibanaReact",
"charts",
"savedObjects"
"savedObjects",
"presentationPanel"
],
"extraPublicDirs": [
"common/constants",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { ErrorEmbeddable } from '@kbn/embeddable-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import { Vis } from '../../types';
import type {
Expand All @@ -22,6 +21,7 @@ import { getHttp, getTimeFilter, getCapabilities } from '../../services';
import { urlFor } from '../../utils/saved_visualize_utils';
import { createVisualizeEmbeddableAsync } from './visualize_embeddable_async';
import { AttributeService } from './attribute_service';
import { ErrorEmbeddable } from './error_embeddable';

/** @deprecated
* VisualizeEmbeddable is no longer registered with the legacy embeddable system and is only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { ViewMode } from '..';
import { KibanaExecutionContext } from '@kbn/core/types';
import { EmbeddableInput } from '.';
import { EmbeddableInput, ViewMode } from '@kbn/embeddable-plugin/common';
import { omitGenericEmbeddableInput, genericEmbeddableInputIsEqual } from './diff_embeddable_input';

const getGenericEmbeddableState = (state?: Partial<EmbeddableInput>): EmbeddableInput => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import fastIsEqual from 'fast-deep-equal';
import { pick, omit } from 'lodash';
import { EmbeddableInput } from '.';
import type { EmbeddableInput } from '@kbn/embeddable-plugin/common';

// list out the keys from the EmbeddableInput type to allow lodash to pick them later
const allGenericInputKeys: Readonly<Array<keyof EmbeddableInput>> = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { merge } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, skip } from 'rxjs';
import { RenderCompleteDispatcher } from '@kbn/kibana-utils-plugin/public';
import { Adapters } from '@kbn/inspector-plugin/public';
import { EmbeddableInput, ViewMode } from '@kbn/embeddable-plugin/common';
import { EmbeddableError, EmbeddableOutput, IEmbeddable } from './i_embeddable';
import { EmbeddableInput, ViewMode } from '../../../common/types';
import { genericEmbeddableInputIsEqual, omitGenericEmbeddableInput } from './diff_embeddable_input';

function getPanelTitle(input: EmbeddableInput, output: EmbeddableOutput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { ErrorLike } from '@kbn/expressions-plugin/common';
import { Adapters } from '@kbn/inspector-plugin/public';
import { Observable } from 'rxjs';
import { EmbeddableInput } from '../../../common/types';
import type { EmbeddableInput } from '@kbn/embeddable-plugin/common';

export type EmbeddableError = ErrorLike;
export type { EmbeddableInput };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type { DataView } from '@kbn/data-views-plugin/public';
import { Warnings } from '@kbn/charts-plugin/public';
import { hasUnsupportedDownsampledAggregationFailure } from '@kbn/search-response-warnings';
import { Adapters } from '@kbn/inspector-plugin/public';
import { Embeddable, EmbeddableInput, EmbeddableOutput } from '@kbn/embeddable-plugin/public';
import { EmbeddableInput } from '@kbn/embeddable-plugin/common';
import { SavedObjectEmbeddableInput } from '@kbn/embeddable-plugin/common';
import {
ExpressionAstExpression,
Expand All @@ -47,6 +47,8 @@ import { VisSavedObject } from '../../types';
import { toExpressionAst } from '../../embeddable/to_ast';
import { AttributeService } from './attribute_service';
import { VisualizationsStartDeps } from '../../plugin';
import { Embeddable } from './embeddable';
import { EmbeddableOutput } from './i_embeddable';

export interface VisualizeEmbeddableDeps {
start: StartServicesGetter<
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/visualizations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"@kbn/search-response-warnings",
"@kbn/embeddable-enhanced-plugin",
"@kbn/content-management-utils",
"@kbn/react-hooks"
"@kbn/react-hooks",
"@kbn/presentation-panel-plugin"
],
"exclude": ["target/**/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@
* 2.0.
*/

import { Embeddable } from '@kbn/embeddable-plugin/public';
import type { HasVisualizeConfig, VisualizeEmbeddable } from '@kbn/visualizations-plugin/public';

export function isLegacyMap(embeddable: Embeddable) {
return (
embeddable.type === 'visualization' &&
typeof (embeddable as VisualizeEmbeddable).getVis === 'function' &&
['region_map', 'tile_map'].includes((embeddable as VisualizeEmbeddable).getVis()?.type?.name)
);
}
import type { HasVisualizeConfig } from '@kbn/visualizations-plugin/public';

export function isLegacyMapApi(api: HasVisualizeConfig) {
return ['region_map', 'tile_map'].includes(api.getVis().type?.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import type { CoreStart } from '@kbn/core/public';
import type { RefreshInterval } from '@kbn/data-plugin/common';
import type { DefaultEmbeddableApi, EmbeddableInput } from '@kbn/embeddable-plugin/public';
import type { DefaultEmbeddableApi } from '@kbn/embeddable-plugin/public';
import type { EmbeddableInput } from '@kbn/embeddable-plugin/common';
import type { Filter, Query, TimeRange } from '@kbn/es-query';
import type { MlEntityField } from '@kbn/ml-anomaly-utils';
import type {
Expand Down
Loading

0 comments on commit 2ee9cbf

Please sign in to comment.