diff --git a/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx b/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx index 2678b5a0368fb..50d70bb58ae75 100644 --- a/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx +++ b/x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx @@ -37,7 +37,7 @@ import { import { combineQueryAndFilters, getLayerMetaInfo } from './show_underlying_data'; import { changeIndexPattern } from '../state_management/lens_slice'; import { LensByReferenceInput } from '../embeddable'; -import { getShareURL } from './share_action'; +import { DEFAULT_LENS_LAYOUT_DIMENSIONS, getShareURL } from './share_action'; function getSaveButtonMeta({ contextFromEmbeddable, @@ -578,6 +578,10 @@ export const LensTopNavMenu = ({ return; } + if (visualization.activeId == null || !visualizationMap[visualization.activeId]) { + return; + } + const { shareableUrl, savedObjectURL, @@ -608,6 +612,12 @@ export const LensTopNavMenu = ({ id: LENS_APP_LOCATOR, params: locatorParams, }, + layout: { + dimensions: + visualizationMap[visualization.activeId].getReportingLayout?.( + visualization.state + ) ?? DEFAULT_LENS_LAYOUT_DIMENSIONS, + }, }; share.toggleShareContextMenu({ diff --git a/x-pack/plugins/lens/public/app_plugin/share_action.ts b/x-pack/plugins/lens/public/app_plugin/share_action.ts index 55e4b978f015d..c9ec3a11ef5e7 100644 --- a/x-pack/plugins/lens/public/app_plugin/share_action.ts +++ b/x-pack/plugins/lens/public/app_plugin/share_action.ts @@ -27,6 +27,14 @@ interface ShareableConfiguration adHocDataViews?: DataViewSpec[]; } +// This approximate Lens workspace dimensions ratio on a typical widescreen +export const DEFAULT_LENS_LAYOUT_DIMENSIONS = { + width: 1793, + // this is a magic number from the reporting tool implementation + // see: x-pack/plugins/screenshotting/server/browsers/chromium/driver_factory/index.ts#L146 + height: 1086, +}; + function getShareURLForSavedObject( { application, data }: Pick, currentDoc: Document | undefined diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts index 786d75816cafa..786fc50450a94 100644 --- a/x-pack/plugins/lens/public/types.ts +++ b/x-pack/plugins/lens/public/types.ts @@ -1292,6 +1292,10 @@ export interface Visualization { ) => Suggestion | undefined; getVisualizationInfo?: (state: T) => VisualizationInfo; + /** + * A visualization can return custom dimensions for the reporting tool + */ + getReportingLayout?: (state: T) => { height: number; width: number }; } // Use same technique as TriggerContext