diff --git a/packages/presentation/presentation_containers/interfaces/presentation_container.ts b/packages/presentation/presentation_containers/interfaces/presentation_container.ts index 8854ec387e24d..4741201b5f5aa 100644 --- a/packages/presentation/presentation_containers/interfaces/presentation_container.ts +++ b/packages/presentation/presentation_containers/interfaces/presentation_container.ts @@ -11,7 +11,10 @@ import { apiHasParentApi, apiHasUniqueId, PublishingSubject } from '@kbn/present import { BehaviorSubject, combineLatest, isObservable, map, Observable, of, switchMap } from 'rxjs'; import { apiCanAddNewPanel, CanAddNewPanel } from './can_add_new_panel'; -export interface PanelPackage { +export interface PanelPackage< + SerializedState extends object = object, + RuntimeState extends object = object +> { panelType: string; serializedState?: SerializedState; runtimeState?: RuntimeState; diff --git a/src/plugins/links/public/get_links_panel_placement.ts b/src/plugins/links/public/get_links_panel_placement.ts index c6db894d1e64e..be8db9b1df186 100644 --- a/src/plugins/links/public/get_links_panel_placement.ts +++ b/src/plugins/links/public/get_links_panel_placement.ts @@ -7,20 +7,23 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { DASHBOARD_GRID_COLUMN_COUNT, PanelPlacementStrategy } from "@kbn/dashboard-plugin/public"; -import { LinksRuntimeState, LinksSerializedState } from "./types"; -import { deserializeLinksSavedObject } from "./lib/deserialize_from_library"; -import { linksClient } from "./content_management"; +import { DASHBOARD_GRID_COLUMN_COUNT, PanelPlacementStrategy } from '@kbn/dashboard-plugin/public'; +import { LinksRuntimeState, LinksSerializedState } from './types'; +import { deserializeLinksSavedObject } from './lib/deserialize_from_library'; +import { linksClient } from './content_management'; -export async function getLinksPanelPlacement(serializedState?: LinksSerializedState, runtimeState?: LinksRuntimeState) { +export async function getLinksPanelPlacement( + serializedState?: LinksSerializedState, + runtimeState?: LinksRuntimeState +) { if (serializedState && 'savedObjectId' in serializedState && serializedState.savedObjectId) { const linksSavedObject = await linksClient.get(serializedState.savedObjectId); - return getPanelPlacementFromRuntimeState(await deserializeLinksSavedObject(linksSavedObject.item)); + return getPanelPlacementFromRuntimeState( + await deserializeLinksSavedObject(linksSavedObject.item) + ); } - return runtimeState - ? getPanelPlacementFromRuntimeState(runtimeState) - : {}; + return runtimeState ? getPanelPlacementFromRuntimeState(runtimeState) : {}; } function getPanelPlacementFromRuntimeState(runtimeState: LinksRuntimeState) { @@ -28,4 +31,4 @@ function getPanelPlacementFromRuntimeState(runtimeState: LinksRuntimeState) { const width = isHorizontal ? DASHBOARD_GRID_COLUMN_COUNT : 8; const height = isHorizontal ? 4 : (runtimeState.links?.length ?? 1 * 3) + 4; return { width, height, strategy: PanelPlacementStrategy.placeAtTop }; -} \ No newline at end of file +} diff --git a/src/plugins/links/public/plugin.ts b/src/plugins/links/public/plugin.ts index d79e7a646278a..4587a76a19d91 100644 --- a/src/plugins/links/public/plugin.ts +++ b/src/plugins/links/public/plugin.ts @@ -12,9 +12,7 @@ import { ContentManagementPublicStart, } from '@kbn/content-management-plugin/public'; import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; -import { - DashboardStart, -} from '@kbn/dashboard-plugin/public'; +import { DashboardStart } from '@kbn/dashboard-plugin/public'; import { EmbeddableSetup, EmbeddableStart } from '@kbn/embeddable-plugin/public'; import { PresentationUtilPluginStart } from '@kbn/presentation-util-plugin/public'; import { UsageCollectionStart } from '@kbn/usage-collection-plugin/public'; @@ -63,7 +61,7 @@ export class LinksPlugin container.addNewPanel({ panelType: CONTENT_ID, serializedState: { - savedObjectId: savedObject.id + savedObjectId: savedObject.id, }, }); }, @@ -99,7 +97,11 @@ export class LinksPlugin title, editor: { onEdit: async (savedObjectId: string) => { - const [{ openEditorFlyout } , { deserializeLinksSavedObject }, linksSavedObject] = await Promise.all([ + const [ + { openEditorFlyout }, + { deserializeLinksSavedObject }, + linksSavedObject, + ] = await Promise.all([ import('./editor/open_editor_flyout'), import('./lib/deserialize_from_library'), getLinksClient().get(savedObjectId), @@ -127,7 +129,10 @@ export class LinksPlugin untilPluginStartServicesReady().then(() => { registerCreateLinksPanelAction(); - plugins.dashboard.registerDashboardPanelPlacementSetting( + plugins.dashboard.registerDashboardPanelPlacementSetting< + LinksSerializedState, + LinksRuntimeState + >( CONTENT_ID, async (serializedState?: LinksSerializedState, runtimeState?: LinksRuntimeState) => { const { getLinksPanelPlacement } = await import('./get_links_panel_placement');