diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_actions/copy_to_dashboard_modal.tsx b/src/platform/plugins/shared/dashboard/public/dashboard_actions/copy_to_dashboard_modal.tsx index ba2633a868b81..e81b95695a87e 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_actions/copy_to_dashboard_modal.tsx +++ b/src/platform/plugins/shared/dashboard/public/dashboard_actions/copy_to_dashboard_modal.tsx @@ -18,8 +18,7 @@ import { EuiRadio, EuiSpacer, } from '@elastic/eui'; -import { EmbeddablePackageState, PanelNotFoundError } from '@kbn/embeddable-plugin/public'; -import { apiHasSnapshottableState } from '@kbn/presentation-publishing'; +import { EmbeddablePackageState } from '@kbn/embeddable-plugin/public'; import { LazyDashboardPicker, withSuspense } from '@kbn/presentation-util-plugin/public'; import { omit } from 'lodash'; import React, { useCallback, useMemo, useState } from 'react'; @@ -28,6 +27,7 @@ import { embeddableService } from '../services/kibana_services'; import { getDashboardCapabilities } from '../utils/get_dashboard_capabilities'; import { dashboardCopyToDashboardActionStrings } from './_dashboard_actions_strings'; import { CopyToDashboardAPI } from './copy_to_dashboard_action'; +import { DashboardApi } from '../dashboard_api/types'; interface CopyToDashboardModalProps { api: CopyToDashboardAPI; @@ -51,18 +51,14 @@ export function CopyToDashboardModal({ api, closeModal }: CopyToDashboardModalPr const dashboardId = api.parentApi.savedObjectId$.value; const onSubmit = useCallback(() => { - const dashboard = api.parentApi; + const dashboard = api.parentApi as DashboardApi; const panelToCopy = dashboard.getDashboardPanelFromId(api.uuid); - const runtimeSnapshot = apiHasSnapshottableState(api) ? api.snapshotRuntimeState() : undefined; - - if (!panelToCopy && !runtimeSnapshot) { - throw new PanelNotFoundError(); - } const state: EmbeddablePackageState = { type: panelToCopy.type, - input: runtimeSnapshot ?? { - ...omit(panelToCopy.explicitInput, 'id'), + serializedState: { + rawState: { ...omit(panelToCopy.explicitInput, 'id') }, + references: panelToCopy.references ?? [], }, size: { width: panelToCopy.gridData.w, diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_api/get_dashboard_api.ts b/src/platform/plugins/shared/dashboard/public/dashboard_api/get_dashboard_api.ts index c5c1b4b8ea378..110a5fd20e486 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_api/get_dashboard_api.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_api/get_dashboard_api.ts @@ -87,7 +87,7 @@ export function getDashboardApi({ const panelsManager = initializePanelsManager( incomingEmbeddable, initialState.panels, - initialPanelsRuntimeState ?? {}, + incomingEmbeddable || !initialPanelsRuntimeState ? {} : initialPanelsRuntimeState, trackPanel, getPanelReferences, pushPanelReferences diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_api/panels_manager.ts b/src/platform/plugins/shared/dashboard/public/dashboard_api/panels_manager.ts index 80545b1a432b4..962f00a880342 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_api/panels_manager.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_api/panels_manager.ts @@ -67,52 +67,44 @@ export function initializePanelsManager( // Place the incoming embeddable if there is one // -------------------------------------------------------------------------------------- if (incomingEmbeddable) { - const incomingPanelId = incomingEmbeddable.embeddableId ?? v4(); - let incomingPanelState: DashboardPanelState; - if (incomingEmbeddable.embeddableId && Boolean(panels$.value[incomingPanelId])) { - // this embeddable already exists, just update the explicit input. - incomingPanelState = panels$.value[incomingPanelId]; - const sameType = incomingPanelState.type === incomingEmbeddable.type; - - incomingPanelState.type = incomingEmbeddable.type; - setRuntimeStateForChild(incomingPanelId, { - // if the incoming panel is the same type as what was there before we can safely spread the old panel's explicit input - ...(sameType ? incomingPanelState.explicitInput : {}), - - ...incomingEmbeddable.input, - - // maintain hide panel titles setting. - hidePanelTitles: (incomingPanelState.explicitInput as { hidePanelTitles?: boolean }) - .hidePanelTitles, - }); - incomingPanelState.explicitInput = {}; - } else { - // otherwise this incoming embeddable is brand new. - setRuntimeStateForChild(incomingPanelId, incomingEmbeddable.input); + const { serializedState, size, type } = incomingEmbeddable; + const newId = incomingEmbeddable.embeddableId ?? v4(); + const existingPanel: DashboardPanelState | undefined = panels$.value[newId]; + const sameType = existingPanel?.type === type; + + const placeIncomingPanel = () => { const { newPanelPlacement } = runPanelPlacementStrategy( PanelPlacementStrategy.findTopLeftMostOpenSpace, { - width: incomingEmbeddable.size?.width ?? DEFAULT_PANEL_WIDTH, - height: incomingEmbeddable.size?.height ?? DEFAULT_PANEL_HEIGHT, + width: size?.width ?? DEFAULT_PANEL_WIDTH, + height: size?.height ?? DEFAULT_PANEL_HEIGHT, currentPanels: panels$.value, } ); - incomingPanelState = { - explicitInput: {}, - type: incomingEmbeddable.type, - gridData: { - ...newPanelPlacement, - i: incomingPanelId, - }, - }; + return { ...newPanelPlacement, i: newId }; + }; + if (serializedState?.references && serializedState.references.length > 0) { + pushReferences(prefixReferencesFromPanel(newId, serializedState.references ?? [])); } + const gridData = existingPanel ? existingPanel.gridData : placeIncomingPanel(); + const explicitInput = { + ...(sameType ? existingPanel?.explicitInput : {}), + ...serializedState.rawState, + }; + + const incomingPanelState: DashboardPanelState = { + type, + explicitInput, + gridData, + }; + setPanels({ ...panels$.value, - [incomingPanelId]: incomingPanelState, + [newId]: incomingPanelState, }); - trackPanel.setScrollToPanelId(incomingPanelId); - trackPanel.setHighlightPanelId(incomingPanelId); + trackPanel.setScrollToPanelId(newId); + trackPanel.setHighlightPanelId(newId); } async function untilEmbeddableLoaded(id: string): Promise { diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_app/no_data/dashboard_app_no_data.tsx b/src/platform/plugins/shared/dashboard/public/dashboard_app/no_data/dashboard_app_no_data.tsx index 69279269b1714..000d54e784dfe 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_app/no_data/dashboard_app_no_data.tsx +++ b/src/platform/plugins/shared/dashboard/public/dashboard_app/no_data/dashboard_app_no_data.tsx @@ -10,7 +10,6 @@ import React, { useCallback, useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; import useAsync from 'react-use/lib/useAsync'; -import { v4 as uuidv4 } from 'uuid'; import { getESQLAdHocDataview, getESQLQueryColumns, @@ -18,9 +17,8 @@ import { getInitialESQLQuery, } from '@kbn/esql-utils'; import { withSuspense } from '@kbn/shared-ux-utility'; -import type { TypedLensByValueInput } from '@kbn/lens-plugin/public'; +import type { LensSerializedState } from '@kbn/lens-plugin/public'; import { getLensAttributesFromSuggestion } from '@kbn/visualization-utils'; - import { coreServices, dataService, @@ -33,10 +31,6 @@ import { import { getDashboardBackupService } from '../../services/dashboard_backup_service'; import { getDashboardContentManagementService } from '../../services/dashboard_content_management_service'; -function generateId() { - return uuidv4(); -} - export const DashboardAppNoDataPage = ({ onDataViewCreated, }: { @@ -100,27 +94,26 @@ export const DashboardAppNoDataPage = ({ if (chartSuggestions?.length) { const [suggestion] = chartSuggestions; - const attrs = getLensAttributesFromSuggestion({ - filters: [], - query: { - esql: esqlQuery, - }, - suggestion, - dataView, - }) as TypedLensByValueInput['attributes']; - - const lensEmbeddableInput = { - attributes: attrs, - id: generateId(), - }; - - await embeddableService.getStateTransfer().navigateToWithEmbeddablePackage('dashboards', { - state: { - type: 'lens', - input: lensEmbeddableInput, - }, - path: '#/create', - }); + await embeddableService + .getStateTransfer() + .navigateToWithEmbeddablePackage('dashboards', { + state: { + type: 'lens', + serializedState: { + rawState: { + attributes: getLensAttributesFromSuggestion({ + filters: [], + query: { + esql: esqlQuery, + }, + suggestion, + dataView, + }), + }, + }, + }, + path: '#/create', + }); } } catch (error) { if (error.name !== 'AbortError') { diff --git a/src/platform/plugins/shared/embeddable/public/state_transfer/embeddable_state_transfer.test.ts b/src/platform/plugins/shared/embeddable/public/state_transfer/embeddable_state_transfer.test.ts index 81b2a38a69f2f..b5cc8e6795b74 100644 --- a/src/platform/plugins/shared/embeddable/public/state_transfer/embeddable_state_transfer.test.ts +++ b/src/platform/plugins/shared/embeddable/public/state_transfer/embeddable_state_transfer.test.ts @@ -125,13 +125,13 @@ describe('embeddable state transfer', () => { it('can send an outgoing embeddable package state', async () => { await stateTransfer.navigateToWithEmbeddablePackage(destinationApp, { - state: { type: 'coolestType', input: { savedObjectId: '150' } }, + state: { type: 'coolestType', serializedState: { rawState: { savedObjectId: '150' } } }, }); expect(store.set).toHaveBeenCalledWith(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, { [EMBEDDABLE_PACKAGE_STATE_KEY]: { [destinationApp]: { type: 'coolestType', - input: { savedObjectId: '150' }, + serializedState: { rawState: { savedObjectId: '150' } }, }, }, }); @@ -145,14 +145,14 @@ describe('embeddable state transfer', () => { kibanaIsNowForSports: 'extremeSportsKibana', }); await stateTransfer.navigateToWithEmbeddablePackage(destinationApp, { - state: { type: 'coolestType', input: { savedObjectId: '150' } }, + state: { type: 'coolestType', serializedState: { rawState: { savedObjectId: '150' } } }, }); expect(store.set).toHaveBeenCalledWith(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, { kibanaIsNowForSports: 'extremeSportsKibana', [EMBEDDABLE_PACKAGE_STATE_KEY]: { [destinationApp]: { type: 'coolestType', - input: { savedObjectId: '150' }, + serializedState: { rawState: { savedObjectId: '150' } }, }, }, }); @@ -163,7 +163,7 @@ describe('embeddable state transfer', () => { it('sets isTransferInProgress to true when sending an outgoing embeddable package state', async () => { await stateTransfer.navigateToWithEmbeddablePackage(destinationApp, { - state: { type: 'coolestType', input: { savedObjectId: '150' } }, + state: { type: 'coolestType', serializedState: { rawState: { savedObjectId: '150' } } }, }); expect(stateTransfer.isTransferInProgress).toEqual(true); currentAppId$.next(destinationApp); @@ -220,12 +220,15 @@ describe('embeddable state transfer', () => { [EMBEDDABLE_PACKAGE_STATE_KEY]: { [testAppId]: { type: 'skisEmbeddable', - input: { savedObjectId: '123' }, + serializedState: { rawState: { savedObjectId: '123' } }, }, }, }); const fetchedState = stateTransfer.getIncomingEmbeddablePackage(testAppId); - expect(fetchedState).toEqual({ type: 'skisEmbeddable', input: { savedObjectId: '123' } }); + expect(fetchedState).toEqual({ + type: 'skisEmbeddable', + serializedState: { rawState: { savedObjectId: '123' } }, + }); }); it('can fetch an incoming embeddable package state and ignore state for other apps', async () => { @@ -233,21 +236,24 @@ describe('embeddable state transfer', () => { [EMBEDDABLE_PACKAGE_STATE_KEY]: { [testAppId]: { type: 'skisEmbeddable', - input: { savedObjectId: '123' }, + serializedState: { rawState: { savedObjectId: '123' } }, }, testApp2: { type: 'crossCountryEmbeddable', - input: { savedObjectId: '456' }, + serializedState: { rawState: { savedObjectId: '456' } }, }, }, }); const fetchedState = stateTransfer.getIncomingEmbeddablePackage(testAppId); - expect(fetchedState).toEqual({ type: 'skisEmbeddable', input: { savedObjectId: '123' } }); + expect(fetchedState).toEqual({ + type: 'skisEmbeddable', + serializedState: { rawState: { savedObjectId: '123' } }, + }); const fetchedState2 = stateTransfer.getIncomingEmbeddablePackage('testApp2'); expect(fetchedState2).toEqual({ type: 'crossCountryEmbeddable', - input: { savedObjectId: '456' }, + serializedState: { rawState: { savedObjectId: '456' } }, }); }); @@ -268,7 +274,7 @@ describe('embeddable state transfer', () => { [EMBEDDABLE_PACKAGE_STATE_KEY]: { [testAppId]: { type: 'coolestType', - input: { savedObjectId: '150' }, + serializedState: { rawState: { savedObjectId: '150' } }, }, }, iSHouldStillbeHere: 'doing the sports thing', diff --git a/src/platform/plugins/shared/embeddable/public/state_transfer/embeddable_state_transfer.ts b/src/platform/plugins/shared/embeddable/public/state_transfer/embeddable_state_transfer.ts index 877f53bb3c7f6..651044eca775d 100644 --- a/src/platform/plugins/shared/embeddable/public/state_transfer/embeddable_state_transfer.ts +++ b/src/platform/plugins/shared/embeddable/public/state_transfer/embeddable_state_transfer.ts @@ -133,14 +133,18 @@ export class EmbeddableStateTransfer { * A wrapper around the {@link ApplicationStart.navigateToApp} method which navigates to the specified appId * with {@link EmbeddablePackageState | embeddable package state} */ - public async navigateToWithEmbeddablePackage( + public async navigateToWithEmbeddablePackage( appId: string, - options?: { path?: string; state: EmbeddablePackageState } + options?: { path?: string; state: EmbeddablePackageState } ): Promise { this.isTransferInProgress = true; - await this.navigateToWithState(appId, EMBEDDABLE_PACKAGE_STATE_KEY, { - ...options, - }); + await this.navigateToWithState>( + appId, + EMBEDDABLE_PACKAGE_STATE_KEY, + { + ...options, + } + ); } private getIncomingState( diff --git a/src/platform/plugins/shared/embeddable/public/state_transfer/types.ts b/src/platform/plugins/shared/embeddable/public/state_transfer/types.ts index 5380b8aae3d6c..603420edebe9b 100644 --- a/src/platform/plugins/shared/embeddable/public/state_transfer/types.ts +++ b/src/platform/plugins/shared/embeddable/public/state_transfer/types.ts @@ -7,6 +7,8 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ +import { SerializedPanelState } from '@kbn/presentation-publishing'; + export const EMBEDDABLE_EDITOR_STATE_KEY = 'embeddable_editor_state'; /** @@ -36,12 +38,9 @@ export const EMBEDDABLE_PACKAGE_STATE_KEY = 'embeddable_package_state'; * A state package that contains all fields necessary to create or update an embeddable by reference or by value in a container. * @public */ -export interface EmbeddablePackageState { +export interface EmbeddablePackageState { type: string; - /** - * For react embeddables, this input must be runtime state. - */ - input: object; + serializedState: SerializedPanelState; embeddableId?: string; size?: { width?: number; @@ -57,7 +56,7 @@ export interface EmbeddablePackageState { export function isEmbeddablePackageState(state: unknown): state is EmbeddablePackageState { return ( ensureFieldOfTypeExists('type', state, 'string') && - ensureFieldOfTypeExists('input', state, 'object') + ensureFieldOfTypeExists('serializedState', state, 'object') ); } diff --git a/src/platform/plugins/shared/visualizations/public/visualize_app/utils/get_top_nav_config.tsx b/src/platform/plugins/shared/visualizations/public/visualize_app/utils/get_top_nav_config.tsx index 1d7e0951fa573..8ef84b478a8f0 100644 --- a/src/platform/plugins/shared/visualizations/public/visualize_app/utils/get_top_nav_config.tsx +++ b/src/platform/plugins/shared/visualizations/public/visualize_app/utils/get_top_nav_config.tsx @@ -44,6 +44,7 @@ import { VISUALIZE_EDITOR_TRIGGER, AGG_BASED_VISUALIZATION_TRIGGER } from '../.. import { getVizEditorOriginatingAppUrl } from './utils'; import './visualize_navigation.scss'; +import { serializeReferences } from '../../utils/saved_visualization_references'; interface VisualizeCapabilities { createShortUrl: boolean; @@ -183,12 +184,17 @@ export const getTopNavConfig = ( } if (stateTransfer) { + const serializedVis = vis.serialize(); + const { references } = serializeReferences(serializedVis); stateTransfer.navigateToWithEmbeddablePackage(app, { state: { type: VISUALIZE_EMBEDDABLE_TYPE, - input: { - serializedVis: vis.serialize(), - savedObjectId: id, + serializedState: { + rawState: { + serializedVis, + savedObjectId: id, + }, + references, }, embeddableId: saveOptions.copyOnSave ? undefined : embeddableId, searchSessionId: data.search.session.getSessionId(), @@ -246,16 +252,23 @@ export const getTopNavConfig = ( return; } - const state = { - input: { - serializedVis: vis.serialize(), - }, - embeddableId, - type: VISUALIZE_EMBEDDABLE_TYPE, - searchSessionId: data.search.session.getSessionId(), - }; + const serializedVis = vis.serialize(); + const { references } = serializeReferences(serializedVis); - stateTransfer.navigateToWithEmbeddablePackage(originatingApp, { state, path: originatingPath }); + stateTransfer.navigateToWithEmbeddablePackage(originatingApp, { + state: { + serializedState: { + rawState: { + serializedVis: vis.serialize(), + }, + references, + }, + embeddableId, + type: VISUALIZE_EMBEDDABLE_TYPE, + searchSessionId: data.search.session.getSessionId(), + }, + path: originatingPath, + }); }; const navigateToOriginatingApp = () => { @@ -519,24 +532,25 @@ export const getTopNavConfig = ( history.replace(appPath); setActiveUrl(appPath); - const state = { - input: { - serializedVis: { - ...vis.serialize(), - title: newTitle, - description: newDescription, + const serializedVis = vis.serialize(); + const { references } = serializeReferences(serializedVis); + stateTransfer.navigateToWithEmbeddablePackage('dashboards', { + state: { + serializedState: { + rawState: { + serializedVis: { + ...serializedVis, + title: newTitle, + description: newDescription, + }, + }, + references, }, + embeddableId, + type: VISUALIZE_EMBEDDABLE_TYPE, + searchSessionId: data.search.session.getSessionId(), }, - embeddableId, - type: VISUALIZE_EMBEDDABLE_TYPE, - searchSessionId: data.search.session.getSessionId(), - }; - - const path = dashboardId === 'new' ? '#/create' : `#/view/${dashboardId}`; - - stateTransfer.navigateToWithEmbeddablePackage('dashboards', { - state, - path, + path: dashboardId === 'new' ? '#/create' : `#/view/${dashboardId}`, }); // TODO: Saved Object Modal requires `id` to be defined so this is a workaround diff --git a/x-pack/platform/plugins/private/canvas/canvas_plugin_src/renderers/embeddable/embeddable_input_to_expression.ts b/x-pack/platform/plugins/private/canvas/canvas_plugin_src/renderers/embeddable/embeddable_input_to_expression.ts index f4e6075f64edc..7f3c35904343e 100644 --- a/x-pack/platform/plugins/private/canvas/canvas_plugin_src/renderers/embeddable/embeddable_input_to_expression.ts +++ b/x-pack/platform/plugins/private/canvas/canvas_plugin_src/renderers/embeddable/embeddable_input_to_expression.ts @@ -25,20 +25,20 @@ export function embeddableInputToExpression< UseGenericEmbeddable extends boolean, ConditionalReturnType = UseGenericEmbeddable extends true ? string : string | undefined >( - input: object, + state: object, embeddableType: string, palettes?: PaletteRegistry, useGenericEmbeddable?: UseGenericEmbeddable ): ConditionalReturnType { // if `useGenericEmbeddable` is `true`, it **always** returns a string if (useGenericEmbeddable) { - return genericToExpression(input, embeddableType) as ConditionalReturnType; + return genericToExpression(state, embeddableType) as ConditionalReturnType; } // otherwise, depending on if the embeddable type is defined, it might return undefined if (inputToExpressionTypeMap[embeddableType]) { return inputToExpressionTypeMap[embeddableType]( - input as any, + state as any, palettes ) as ConditionalReturnType; } diff --git a/x-pack/platform/plugins/private/canvas/public/components/hooks/workpad/use_incoming_embeddable.ts b/x-pack/platform/plugins/private/canvas/public/components/hooks/workpad/use_incoming_embeddable.ts index 50c3e527bbbae..cce463c43af81 100644 --- a/x-pack/platform/plugins/private/canvas/public/components/hooks/workpad/use_incoming_embeddable.ts +++ b/x-pack/platform/plugins/private/canvas/public/components/hooks/workpad/use_incoming_embeddable.ts @@ -40,7 +40,7 @@ export const useIncomingEmbeddable = (selectedPage: CanvasPage) => { useEffect(() => { if (isByValueEnabled && incomingEmbeddable) { - const { embeddableId, input: incomingInput, type } = incomingEmbeddable; + const { embeddableId, serializedState: incomingState, type } = incomingEmbeddable; // retrieve existing element const originalElement = selectedPage.elements.find( @@ -65,7 +65,7 @@ export const useIncomingEmbeddable = (selectedPage: CanvasPage) => { return; } - const originalInput = decode( + const originalState = decode( originalAst.chain[functionIndex].arguments.config[0] as string ); @@ -75,16 +75,15 @@ export const useIncomingEmbeddable = (selectedPage: CanvasPage) => { const argumentPath = [embeddableId, 'expressionRenderable']; dispatch(clearValue({ path: argumentPath })); - let updatedInput; + let updatedState; // if type was changed, we should not provide originalInput if (originalType !== type) { - updatedInput = incomingInput; + updatedState = incomingState; } else { - updatedInput = { ...originalInput, ...incomingInput }; + updatedState = { ...originalState, ...incomingState.rawState }; } - - const expression = embeddableInputToExpression(updatedInput, type, undefined, true); + const expression = embeddableInputToExpression(updatedState, type, undefined, true); dispatch( updateEmbeddableExpression({ @@ -99,7 +98,12 @@ export const useIncomingEmbeddable = (selectedPage: CanvasPage) => { // select new embeddable element dispatch(selectToplevelNodes([embeddableId])); } else { - const expression = embeddableInputToExpression(incomingInput, type, undefined, true); + const expression = embeddableInputToExpression( + incomingState.rawState, + type, + undefined, + true + ); dispatch(addElement(selectedPage.id, { expression })); } } diff --git a/x-pack/platform/plugins/shared/aiops/public/components/change_point_detection/fields_config.tsx b/x-pack/platform/plugins/shared/aiops/public/components/change_point_detection/fields_config.tsx index d548c8d10d747..962e4f369bf39 100644 --- a/x-pack/platform/plugins/shared/aiops/public/components/change_point_detection/fields_config.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/components/change_point_detection/fields_config.tsx @@ -34,6 +34,7 @@ import type { EuiContextMenuProps } from '@elastic/eui/src/components/context_me import { isDefined } from '@kbn/ml-is-defined'; import type { ChangePointDetectionViewType } from '@kbn/aiops-change-point-detection/constants'; import { + CHANGE_POINT_CHART_DATA_VIEW_REF_NAME, CHANGE_POINT_DETECTION_VIEW_TYPE, EMBEDDABLE_CHANGE_POINT_CHART_TYPE, } from '@kbn/aiops-change-point-detection/constants'; @@ -57,6 +58,7 @@ import { useChangePointResults } from './use_change_point_agg_request'; import { useSplitFieldCardinality } from './use_split_field_cardinality'; import { ViewTypeSelector } from './view_type_selector'; import { CASES_TOAST_MESSAGES_TITLES } from '../../cases/constants'; +import { getDataviewReferences } from '../../embeddables/get_dataview_references'; const selectControlCss = { width: '350px' }; @@ -493,7 +495,10 @@ const FieldPanel: FC = ({ }; const state = { - input: embeddableInput, + serializedState: { + rawState: embeddableInput, + references: getDataviewReferences(dataView.id, CHANGE_POINT_CHART_DATA_VIEW_REF_NAME), + }, type: EMBEDDABLE_CHANGE_POINT_CHART_TYPE, }; diff --git a/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/attachments_menu.tsx b/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/attachments_menu.tsx index cf68d19622f63..aa937e2588c0f 100644 --- a/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/attachments_menu.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/attachments_menu.tsx @@ -28,13 +28,17 @@ import { import React, { useCallback, useState } from 'react'; import { useMemo } from 'react'; import type { DataView } from '@kbn/data-views-plugin/common'; -import { EMBEDDABLE_PATTERN_ANALYSIS_TYPE } from '@kbn/aiops-log-pattern-analysis/constants'; +import { + EMBEDDABLE_PATTERN_ANALYSIS_TYPE, + PATTERN_ANALYSIS_DATA_VIEW_REF_NAME, +} from '@kbn/aiops-log-pattern-analysis/constants'; import { useTimeRangeUpdates } from '@kbn/ml-date-picker'; import type { PatternAnalysisEmbeddableState } from '../../embeddables/pattern_analysis/types'; import type { RandomSamplerOption, RandomSamplerProbability } from './sampling_menu/random_sampler'; import { useCasesModal } from '../../hooks/use_cases_modal'; import { useAiopsAppContext } from '../../hooks/use_aiops_app_context'; import { CASES_TOAST_MESSAGES_TITLES } from '../../cases/constants'; +import { getDataviewReferences } from '../../embeddables/get_dataview_references'; const SavedObjectSaveModalDashboard = withSuspense(LazySavedObjectSaveModalDashboard); @@ -92,7 +96,10 @@ export const AttachmentsMenu = ({ }; const state = { - input: embeddableInput, + serializedState: { + rawState: embeddableInput, + references: getDataviewReferences(dataView.id, PATTERN_ANALYSIS_DATA_VIEW_REF_NAME), + }, type: EMBEDDABLE_PATTERN_ANALYSIS_TYPE, }; diff --git a/x-pack/platform/plugins/shared/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_attachments_menu.tsx b/x-pack/platform/plugins/shared/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_attachments_menu.tsx index 9db40a6d7b4e4..155e121a1055b 100644 --- a/x-pack/platform/plugins/shared/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_attachments_menu.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/components/log_rate_analysis/log_rate_analysis_content/log_rate_analysis_attachments_menu.tsx @@ -10,7 +10,10 @@ import { LazySavedObjectSaveModalDashboard } from '@kbn/presentation-util-plugin import { withSuspense } from '@kbn/shared-ux-utility'; import React, { useState, useCallback, useMemo } from 'react'; import { useTimeRangeUpdates } from '@kbn/ml-date-picker'; -import { EMBEDDABLE_LOG_RATE_ANALYSIS_TYPE } from '@kbn/aiops-log-rate-analysis/constants'; +import { + EMBEDDABLE_LOG_RATE_ANALYSIS_TYPE, + LOG_RATE_ANALYSIS_DATA_VIEW_REF_NAME, +} from '@kbn/aiops-log-rate-analysis/constants'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import type { EuiContextMenuProps } from '@elastic/eui'; @@ -33,6 +36,7 @@ import { useCasesModal } from '../../../hooks/use_cases_modal'; import { useDataSource } from '../../../hooks/use_data_source'; import type { LogRateAnalysisEmbeddableState } from '../../../embeddables/log_rate_analysis/types'; import { useAiopsAppContext } from '../../../hooks/use_aiops_app_context'; +import { getDataviewReferences } from '../../../embeddables/get_dataview_references'; const SavedObjectSaveModalDashboard = withSuspense(LazySavedObjectSaveModalDashboard); @@ -88,7 +92,10 @@ export const LogRateAnalysisAttachmentsMenu = ({ }; const state = { - input: embeddableInput, + serializedState: { + rawState: embeddableInput, + references: getDataviewReferences(dataView.id, LOG_RATE_ANALYSIS_DATA_VIEW_REF_NAME), + }, type: EMBEDDABLE_LOG_RATE_ANALYSIS_TYPE, }; diff --git a/x-pack/platform/plugins/shared/aiops/public/embeddables/change_point_chart/embeddable_change_point_chart_factory.tsx b/x-pack/platform/plugins/shared/aiops/public/embeddables/change_point_chart/embeddable_change_point_chart_factory.tsx index 645e6f992f27e..39aaba11e39ac 100644 --- a/x-pack/platform/plugins/shared/aiops/public/embeddables/change_point_chart/embeddable_change_point_chart_factory.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/embeddables/change_point_chart/embeddable_change_point_chart_factory.tsx @@ -9,10 +9,8 @@ import { CHANGE_POINT_CHART_DATA_VIEW_REF_NAME, EMBEDDABLE_CHANGE_POINT_CHART_TYPE, } from '@kbn/aiops-change-point-detection/constants'; -import type { Reference } from '@kbn/content-management-utils'; import type { StartServicesAccessor } from '@kbn/core-lifecycle-browser'; import type { DataView } from '@kbn/data-views-plugin/common'; -import { DATA_VIEW_SAVED_OBJECT_TYPE } from '@kbn/data-views-plugin/common'; import type { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; import { i18n } from '@kbn/i18n'; import { @@ -37,6 +35,7 @@ import type { ChangePointEmbeddableRuntimeState, ChangePointEmbeddableState, } from './types'; +import { getDataviewReferences } from '../get_dataview_references'; export type EmbeddableChangePointChartType = typeof EMBEDDABLE_CHANGE_POINT_CHART_TYPE; @@ -116,15 +115,6 @@ export const getChangePointChartEmbeddableFactory = ( dataViews$, serializeState: () => { const dataViewId = changePointControlsApi.dataViewId.getValue(); - const references: Reference[] = dataViewId - ? [ - { - type: DATA_VIEW_SAVED_OBJECT_TYPE, - name: CHANGE_POINT_CHART_DATA_VIEW_REF_NAME, - id: dataViewId, - }, - ] - : []; return { rawState: { timeRange: undefined, @@ -132,7 +122,7 @@ export const getChangePointChartEmbeddableFactory = ( ...timeRangeManager.serialize(), ...serializeChangePointChartState(), }, - references, + references: getDataviewReferences(dataViewId, CHANGE_POINT_CHART_DATA_VIEW_REF_NAME), }; }, }, diff --git a/x-pack/platform/plugins/shared/aiops/public/embeddables/get_dataview_references.ts b/x-pack/platform/plugins/shared/aiops/public/embeddables/get_dataview_references.ts new file mode 100644 index 0000000000000..7720b7cc9f3e4 --- /dev/null +++ b/x-pack/platform/plugins/shared/aiops/public/embeddables/get_dataview_references.ts @@ -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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { Reference } from '@kbn/content-management-utils'; +import { DATA_VIEW_SAVED_OBJECT_TYPE } from '@kbn/data-views-plugin/common'; + +export const getDataviewReferences = (dataViewId: string | undefined, refName: string) => { + const references: Reference[] = dataViewId + ? [ + { + type: DATA_VIEW_SAVED_OBJECT_TYPE, + name: refName, + id: dataViewId, + }, + ] + : []; + return references; +}; diff --git a/x-pack/platform/plugins/shared/aiops/public/embeddables/log_rate_analysis/embeddable_log_rate_analysis_factory.tsx b/x-pack/platform/plugins/shared/aiops/public/embeddables/log_rate_analysis/embeddable_log_rate_analysis_factory.tsx index 51ad78f6c37a8..9fffa0a7fc658 100644 --- a/x-pack/platform/plugins/shared/aiops/public/embeddables/log_rate_analysis/embeddable_log_rate_analysis_factory.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/embeddables/log_rate_analysis/embeddable_log_rate_analysis_factory.tsx @@ -9,10 +9,8 @@ import { EMBEDDABLE_LOG_RATE_ANALYSIS_TYPE, LOG_RATE_ANALYSIS_DATA_VIEW_REF_NAME, } from '@kbn/aiops-log-rate-analysis/constants'; -import type { Reference } from '@kbn/content-management-utils'; import type { StartServicesAccessor } from '@kbn/core-lifecycle-browser'; import type { DataView } from '@kbn/data-views-plugin/common'; -import { DATA_VIEW_SAVED_OBJECT_TYPE } from '@kbn/data-views-plugin/common'; import type { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; import { i18n } from '@kbn/i18n'; import { @@ -37,6 +35,7 @@ import type { LogRateAnalysisEmbeddableRuntimeState, LogRateAnalysisEmbeddableState, } from './types'; +import { getDataviewReferences } from '../get_dataview_references'; export type EmbeddableLogRateAnalysisType = typeof EMBEDDABLE_LOG_RATE_ANALYSIS_TYPE; @@ -120,15 +119,6 @@ export const getLogRateAnalysisEmbeddableFactory = ( dataViews$, serializeState: () => { const dataViewId = logRateAnalysisControlsApi.dataViewId.getValue(); - const references: Reference[] = dataViewId - ? [ - { - type: DATA_VIEW_SAVED_OBJECT_TYPE, - name: LOG_RATE_ANALYSIS_DATA_VIEW_REF_NAME, - id: dataViewId, - }, - ] - : []; return { rawState: { timeRange: undefined, @@ -136,7 +126,7 @@ export const getLogRateAnalysisEmbeddableFactory = ( ...timeRangeManager.serialize(), ...serializeLogRateAnalysisChartState(), }, - references, + references: getDataviewReferences(dataViewId, LOG_RATE_ANALYSIS_DATA_VIEW_REF_NAME), }; }, }, diff --git a/x-pack/platform/plugins/shared/aiops/public/embeddables/pattern_analysis/embeddable_pattern_analysis_factory.tsx b/x-pack/platform/plugins/shared/aiops/public/embeddables/pattern_analysis/embeddable_pattern_analysis_factory.tsx index 5b44d02223ad4..2b576af3e88cb 100644 --- a/x-pack/platform/plugins/shared/aiops/public/embeddables/pattern_analysis/embeddable_pattern_analysis_factory.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/embeddables/pattern_analysis/embeddable_pattern_analysis_factory.tsx @@ -9,10 +9,8 @@ import { EMBEDDABLE_PATTERN_ANALYSIS_TYPE, PATTERN_ANALYSIS_DATA_VIEW_REF_NAME, } from '@kbn/aiops-log-pattern-analysis/constants'; -import type { Reference } from '@kbn/content-management-utils'; import type { StartServicesAccessor } from '@kbn/core-lifecycle-browser'; import type { DataView } from '@kbn/data-views-plugin/common'; -import { DATA_VIEW_SAVED_OBJECT_TYPE } from '@kbn/data-views-plugin/common'; import type { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; import { i18n } from '@kbn/i18n'; import { @@ -36,6 +34,7 @@ import type { PatternAnalysisEmbeddableRuntimeState, PatternAnalysisEmbeddableState, } from './types'; +import { getDataviewReferences } from '../get_dataview_references'; export type EmbeddablePatternAnalysisType = typeof EMBEDDABLE_PATTERN_ANALYSIS_TYPE; @@ -119,15 +118,6 @@ export const getPatternAnalysisEmbeddableFactory = ( dataViews$, serializeState: () => { const dataViewId = patternAnalysisControlsApi.dataViewId.getValue(); - const references: Reference[] = dataViewId - ? [ - { - type: DATA_VIEW_SAVED_OBJECT_TYPE, - name: PATTERN_ANALYSIS_DATA_VIEW_REF_NAME, - id: dataViewId, - }, - ] - : []; return { rawState: { timeRange: undefined, @@ -135,7 +125,7 @@ export const getPatternAnalysisEmbeddableFactory = ( ...timeRangeManager.serialize(), ...serializePatternAnalysisChartState(), }, - references, + references: getDataviewReferences(dataViewId, PATTERN_ANALYSIS_DATA_VIEW_REF_NAME), }; }, }, diff --git a/x-pack/platform/plugins/shared/cases/public/components/markdown_editor/plugins/lens/plugin.tsx b/x-pack/platform/plugins/shared/cases/public/components/markdown_editor/plugins/lens/plugin.tsx index 512761e1de17c..59c652b07bfd0 100644 --- a/x-pack/platform/plugins/shared/cases/public/components/markdown_editor/plugins/lens/plugin.tsx +++ b/x-pack/platform/plugins/shared/cases/public/components/markdown_editor/plugins/lens/plugin.tsx @@ -45,9 +45,7 @@ const DEFAULT_TIMERANGE: TimeRange = { mode: 'relative', }; -type LensIncomingEmbeddablePackage = Omit & { - input: TypedLensByValueInput; -}; +type LensIncomingEmbeddablePackage = EmbeddablePackageState; type LensEuiMarkdownEditorUiPlugin = EuiMarkdownEditorUiPlugin<{ timeRange: TypedLensByValueInput['timeRange']; @@ -253,7 +251,7 @@ const LensEditorComponent: LensEuiMarkdownEditorUiPlugin['editor'] = ({ if ( incomingEmbeddablePackage?.type === 'lens' && - incomingEmbeddablePackage?.input?.attributes + incomingEmbeddablePackage?.serializedState?.rawState?.attributes ) { const lensTime = timefilter.getTime(); const newTimeRange = @@ -269,7 +267,7 @@ const LensEditorComponent: LensEuiMarkdownEditorUiPlugin['editor'] = ({ if (draftComment?.position) { handleUpdate( - incomingEmbeddablePackage?.input.attributes, + incomingEmbeddablePackage.serializedState.rawState.attributes, newTimeRange, draftComment.position ); @@ -277,7 +275,7 @@ const LensEditorComponent: LensEuiMarkdownEditorUiPlugin['editor'] = ({ } if (draftComment) { - handleAdd(incomingEmbeddablePackage?.input.attributes, newTimeRange); + handleAdd(incomingEmbeddablePackage.serializedState.rawState.attributes, newTimeRange); } } }, [embeddable, storage, timefilter, currentAppId, handleAdd, handleUpdate, draftComment]); diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/mounter.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/mounter.tsx index 7042117098395..31fcadc41378c 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/mounter.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/mounter.tsx @@ -19,7 +19,7 @@ import { Storage, withNotifyOnErrors, } from '@kbn/kibana-utils-plugin/public'; - +import { EmbeddableStateWithType } from '@kbn/embeddable-plugin/common'; import { ACTION_VISUALIZE_LENS_FIELD, VisualizeFieldContext } from '@kbn/ui-actions-plugin/public'; import { ACTION_CONVERT_TO_LENS } from '@kbn/visualizations-plugin/public'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; @@ -32,6 +32,7 @@ import { App } from './app'; import { EditorFrameStart, LensTopNavMenuEntryGenerator, VisualizeEditorContext } from '../types'; import { addHelpMenuToAppChrome } from '../help_menu_util'; import { LensPluginStartDependencies } from '../plugin'; +import { extract } from '../../common/embeddable_factory'; import { LENS_EMBEDDABLE_TYPE, LENS_EDIT_BY_VALUE, APP_ID } from '../../common/constants'; import { LensAttributesService } from '../lens_attribute_service'; import { LensAppServices, RedirectToOriginProps, HistoryLocationState } from './types'; @@ -217,13 +218,17 @@ export async function mountApp( embeddableId = initialContext.embeddableId; } if (stateTransfer && props?.state) { - const { state, isCopied } = props; - stateTransfer.navigateToWithEmbeddablePackage(mergedOriginatingApp, { + const { state: rawState, isCopied } = props; + const { references } = extract(rawState as unknown as EmbeddableStateWithType); + stateTransfer.navigateToWithEmbeddablePackage(mergedOriginatingApp, { path: embeddableEditorIncomingState?.originatingPath, state: { embeddableId: isCopied ? undefined : embeddableId, type: LENS_EMBEDDABLE_TYPE, - input: { ...state, savedObject: state.savedObjectId }, + serializedState: { + references, + rawState, + }, searchSessionId: data.search.session.getSessionId(), }, }); diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container.test.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container.test.tsx index 5d9c833174ed5..eb80dcf64c3fd 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container.test.tsx @@ -261,7 +261,12 @@ describe('runSaveLensVisualization', () => { // make sure the new savedObject id is removed from the new input expect.objectContaining({ state: expect.objectContaining({ - input: expect.objectContaining({ savedObjectId: undefined }), + serializedState: expect.objectContaining({ + rawState: expect.objectContaining({ savedObjectId: undefined }), + references: expect.arrayContaining([ + expect.objectContaining({ type: 'index-pattern' }), + ]), + }), }), }) ); @@ -288,7 +293,12 @@ describe('runSaveLensVisualization', () => { // make sure the new savedObject id is passed with the new input expect.objectContaining({ state: expect.objectContaining({ - input: expect.objectContaining({ savedObjectId: '1234' }), + serializedState: expect.objectContaining({ + rawState: expect.objectContaining({ savedObjectId: '1234' }), + references: expect.arrayContaining([ + expect.objectContaining({ type: 'index-pattern' }), + ]), + }), }), }) ); diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container_helpers.test.ts b/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container_helpers.test.ts index 9415ab2e323cd..f3a691cfeaf36 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container_helpers.test.ts +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container_helpers.test.ts @@ -30,7 +30,7 @@ describe('redirectToDashboard', () => { }); expect(navigateToWithEmbeddablePackageSpy).toHaveBeenCalledWith('security', { path: '#/view/id', - state: { input: { test: 'test' }, type: 'lens' }, + state: { serializedState: { rawState: { test: 'test' }, references: [] }, type: 'lens' }, }); }); @@ -49,7 +49,7 @@ describe('redirectToDashboard', () => { }); expect(navigateToWithEmbeddablePackageSpy).toHaveBeenCalledWith('dashboards', { path: '#/view/id', - state: { input: { test: 'test' }, type: 'lens' }, + state: { serializedState: { rawState: { test: 'test' }, references: [] }, type: 'lens' }, }); }); }); diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container_helpers.ts b/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container_helpers.ts index 44b879c7f27cb..63d3ff84c50e4 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container_helpers.ts +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/save_modal_container_helpers.ts @@ -5,12 +5,14 @@ * 2.0. */ +import { EmbeddableStateWithType } from '@kbn/embeddable-plugin/common'; import type { LensAppServices } from './types'; import { LENS_EMBEDDABLE_TYPE } from '../../common/constants'; +import { extract } from '../../common/embeddable_factory'; import { LensSerializedState } from '../react_embeddable/types'; export const redirectToDashboard = ({ - embeddableInput, + embeddableInput: rawState, dashboardId, originatingApp, getOriginatingPath, @@ -22,17 +24,19 @@ export const redirectToDashboard = ({ getOriginatingPath?: (dashboardId: string) => string | undefined; stateTransfer: LensAppServices['stateTransfer']; }) => { - const state = { - input: embeddableInput, - type: LENS_EMBEDDABLE_TYPE, - }; + const { references } = extract(rawState as unknown as EmbeddableStateWithType); - const path = - getOriginatingPath?.(dashboardId) ?? - (dashboardId === 'new' ? '#/create' : `#/view/${dashboardId}`); const appId = originatingApp || 'dashboards'; - stateTransfer.navigateToWithEmbeddablePackage(appId, { - state, - path, + stateTransfer.navigateToWithEmbeddablePackage(appId, { + state: { + type: LENS_EMBEDDABLE_TYPE, + serializedState: { + rawState, + references, + }, + }, + path: + getOriginatingPath?.(dashboardId) ?? + (dashboardId === 'new' ? '#/create' : `#/view/${dashboardId}`), }); }; diff --git a/x-pack/platform/plugins/shared/maps/public/routes/map_page/saved_map/saved_map.ts b/x-pack/platform/plugins/shared/maps/public/routes/map_page/saved_map/saved_map.ts index 9e5a537de7bac..b024d3d22a0ae 100644 --- a/x-pack/platform/plugins/shared/maps/public/routes/map_page/saved_map/saved_map.ts +++ b/x-pack/platform/plugins/shared/maps/public/routes/map_page/saved_map/saved_map.ts @@ -469,11 +469,11 @@ export class SavedMap { await this._syncAttributesWithStore(); let mapSerializedState: MapSerializedState | undefined; + const { attributes, references } = extractReferences({ + attributes: this._attributes, + }); if (saveByReference) { try { - const { attributes, references } = extractReferences({ - attributes: this._attributes, - }); const savedObjectsTagging = getSavedObjectsTagging(); const tagReferences = savedObjectsTagging && tags ? savedObjectsTagging.ui.updateTagsReferences([], tags) : []; @@ -521,7 +521,7 @@ export class SavedMap { state: { embeddableId: newCopyOnSave ? undefined : this._embeddableId, type: MAP_SAVED_OBJECT_TYPE, - input: mapSerializedState, + serializedState: { rawState: mapSerializedState, references }, }, path: this._originatingPath, }); @@ -530,7 +530,7 @@ export class SavedMap { await this._getStateTransfer().navigateToWithEmbeddablePackage('dashboards', { state: { type: MAP_SAVED_OBJECT_TYPE, - input: mapSerializedState, + serializedState: { rawState: mapSerializedState, references }, }, path: dashboardId === 'new' ? '#/create' : `#/view/${dashboardId}`, }); diff --git a/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_context_menu.tsx b/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_context_menu.tsx index 9fc699b588000..9a25224463695 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_context_menu.tsx +++ b/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_context_menu.tsx @@ -194,7 +194,7 @@ export const AnomalyContextMenu: FC = ({ }; const state = { - input: embeddableInput, + serializedState: { rawState: embeddableInput, references: [] }, type: ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE, }; diff --git a/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_timeline.tsx b/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_timeline.tsx index 944e2aa881195..02af284f233d7 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_timeline.tsx +++ b/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_timeline.tsx @@ -381,7 +381,7 @@ export const AnomalyTimeline: FC = React.memo( }; const state = { - input: embeddableInput, + serializedState: { rawState: embeddableInput, references: [] }, type: ANOMALY_SWIMLANE_EMBEDDABLE_TYPE, }; diff --git a/x-pack/platform/plugins/shared/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_controls/timeseriesexplorer_controls.tsx b/x-pack/platform/plugins/shared/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_controls/timeseriesexplorer_controls.tsx index 36e7b63094a29..59835d032d6aa 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_controls/timeseriesexplorer_controls.tsx +++ b/x-pack/platform/plugins/shared/ml/public/application/timeseriesexplorer/components/timeseriesexplorer_controls/timeseriesexplorer_controls.tsx @@ -193,7 +193,7 @@ export const TimeSeriesExplorerControls: FC = ({ }; const state = { - input: embeddableInput, + serializedState: { rawState: embeddableInput, references: [] }, type: ANOMALY_SINGLE_METRIC_VIEWER_EMBEDDABLE_TYPE, }; diff --git a/x-pack/solutions/observability/plugins/slo/public/pages/slo_details/components/error_budget_chart_panel.tsx b/x-pack/solutions/observability/plugins/slo/public/pages/slo_details/components/error_budget_chart_panel.tsx index 72c6cf30c9de6..242b210a3c336 100644 --- a/x-pack/solutions/observability/plugins/slo/public/pages/slo_details/components/error_budget_chart_panel.tsx +++ b/x-pack/solutions/observability/plugins/slo/public/pages/slo_details/components/error_budget_chart_panel.tsx @@ -47,7 +47,7 @@ export function ErrorBudgetChartPanel({ data, isLoading, slo, selectedTabId, onB }; const state = { - input: embeddableInput, + serializedState: { rawState: embeddableInput }, type: SLO_ERROR_BUDGET_ID, }; diff --git a/x-pack/solutions/observability/plugins/slo/public/pages/slos/hooks/use_slo_list_actions.ts b/x-pack/solutions/observability/plugins/slo/public/pages/slos/hooks/use_slo_list_actions.ts index d339c1e66bf00..e8646e7b5b8ed 100644 --- a/x-pack/solutions/observability/plugins/slo/public/pages/slos/hooks/use_slo_list_actions.ts +++ b/x-pack/solutions/observability/plugins/slo/public/pages/slos/hooks/use_slo_list_actions.ts @@ -39,7 +39,7 @@ export function useSloListActions({ }; const state = { - input: embeddableInput, + serializedState: { rawState: embeddableInput }, type: SLO_OVERVIEW_EMBEDDABLE_ID, }; diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/common/components/add_to_dashboard.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/common/components/add_to_dashboard.tsx index d8b2d624c51ba..4d5e7824643a0 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/common/components/add_to_dashboard.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/common/components/add_to_dashboard.tsx @@ -49,7 +49,7 @@ export const AddToDashboard = ({ const embeddableInput = {}; const state = { - input: embeddableInput, + serializedState: { rawState: embeddableInput }, type, };