diff --git a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.cleareditorstate.md b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.cleareditorstate.md
index 5c1a6a0393c2e..034f9c70e389f 100644
--- a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.cleareditorstate.md
+++ b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.cleareditorstate.md
@@ -4,11 +4,20 @@
## EmbeddableStateTransfer.clearEditorState() method
+Clears the [editor state](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.md) from the sessionStorage for the provided app id
+
Signature:
```typescript
-clearEditorState(): void;
+clearEditorState(appId: string): void;
```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| appId | string
| The app to fetch incomingEditorState for |
+
Returns:
`void`
diff --git a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingeditorstate.md b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingeditorstate.md
index 1434de2c9870e..cd261bff5905b 100644
--- a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingeditorstate.md
+++ b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingeditorstate.md
@@ -4,18 +4,19 @@
## EmbeddableStateTransfer.getIncomingEditorState() method
-Fetches an [originating app](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.md) argument from the sessionStorage
+Fetches an [editor state](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.md) from the sessionStorage for the provided app id
Signature:
```typescript
-getIncomingEditorState(removeAfterFetch?: boolean): EmbeddableEditorState | undefined;
+getIncomingEditorState(appId: string, removeAfterFetch?: boolean): EmbeddableEditorState | undefined;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
+| appId | string
| The app to fetch incomingEditorState for |
| removeAfterFetch | boolean
| Whether to remove the package state after fetch to prevent duplicates. |
Returns:
diff --git a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingembeddablepackage.md b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingembeddablepackage.md
index 9ead71f0bb22c..47873c8e91e41 100644
--- a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingembeddablepackage.md
+++ b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingembeddablepackage.md
@@ -4,18 +4,19 @@
## EmbeddableStateTransfer.getIncomingEmbeddablePackage() method
-Fetches an [embeddable package](./kibana-plugin-plugins-embeddable-public.embeddablepackagestate.md) argument from the sessionStorage
+Fetches an [embeddable package](./kibana-plugin-plugins-embeddable-public.embeddablepackagestate.md) from the sessionStorage for the given AppId
Signature:
```typescript
-getIncomingEmbeddablePackage(removeAfterFetch?: boolean): EmbeddablePackageState | undefined;
+getIncomingEmbeddablePackage(appId: string, removeAfterFetch?: boolean): EmbeddablePackageState | undefined;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
+| appId | string
| The app to fetch EmbeddablePackageState for |
| removeAfterFetch | boolean
| Whether to remove the package state after fetch to prevent duplicates. |
Returns:
diff --git a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.md b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.md
index 76b6708b93bd1..13c6c8c0325f1 100644
--- a/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.md
+++ b/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.md
@@ -29,9 +29,9 @@ export declare class EmbeddableStateTransfer
| Method | Modifiers | Description |
| --- | --- | --- |
-| [clearEditorState()](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.cleareditorstate.md) | | |
-| [getIncomingEditorState(removeAfterFetch)](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingeditorstate.md) | | Fetches an [originating app](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.md) argument from the sessionStorage |
-| [getIncomingEmbeddablePackage(removeAfterFetch)](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingembeddablepackage.md) | | Fetches an [embeddable package](./kibana-plugin-plugins-embeddable-public.embeddablepackagestate.md) argument from the sessionStorage |
+| [clearEditorState(appId)](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.cleareditorstate.md) | | Clears the [editor state](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.md) from the sessionStorage for the provided app id |
+| [getIncomingEditorState(appId, removeAfterFetch)](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingeditorstate.md) | | Fetches an [editor state](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.md) from the sessionStorage for the provided app id |
+| [getIncomingEmbeddablePackage(appId, removeAfterFetch)](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.getincomingembeddablepackage.md) | | Fetches an [embeddable package](./kibana-plugin-plugins-embeddable-public.embeddablepackagestate.md) from the sessionStorage for the given AppId |
| [navigateToEditor(appId, options)](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.navigatetoeditor.md) | | A wrapper around the method which navigates to the specified appId with [embeddable editor state](./kibana-plugin-plugins-embeddable-public.embeddableeditorstate.md) |
| [navigateToWithEmbeddablePackage(appId, options)](./kibana-plugin-plugins-embeddable-public.embeddablestatetransfer.navigatetowithembeddablepackage.md) | | A wrapper around the method which navigates to the specified appId with [embeddable package state](./kibana-plugin-plugins-embeddable-public.embeddablepackagestate.md) |
diff --git a/src/plugins/dashboard/public/application/hooks/use_dashboard_container.ts b/src/plugins/dashboard/public/application/hooks/use_dashboard_container.ts
index b27322b6bec53..d12fea07bdd41 100644
--- a/src/plugins/dashboard/public/application/hooks/use_dashboard_container.ts
+++ b/src/plugins/dashboard/public/application/hooks/use_dashboard_container.ts
@@ -21,7 +21,7 @@ import {
import { DashboardStateManager } from '../dashboard_state_manager';
import { getDashboardContainerInput, getSearchSessionIdFromURL } from '../dashboard_app_functions';
-import { DashboardContainer, DashboardContainerInput } from '../..';
+import { DashboardConstants, DashboardContainer, DashboardContainerInput } from '../..';
import { DashboardAppServices } from '../types';
import { DASHBOARD_CONTAINER_TYPE } from '..';
@@ -68,7 +68,9 @@ export const useDashboardContainer = (
searchSession.restore(searchSessionIdFromURL);
}
- const incomingEmbeddable = embeddable.getStateTransfer().getIncomingEmbeddablePackage(true);
+ const incomingEmbeddable = embeddable
+ .getStateTransfer()
+ .getIncomingEmbeddablePackage(DashboardConstants.DASHBOARDS_ID, true);
let canceled = false;
let pendingContainer: DashboardContainer | ErrorEmbeddable | null | undefined;
diff --git a/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.test.ts b/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.test.ts
index 763186fc17c0c..a8ecb384f782b 100644
--- a/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.test.ts
+++ b/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.test.ts
@@ -42,6 +42,10 @@ describe('embeddable state transfer', () => {
const destinationApp = 'superUltraVisualize';
const originatingApp = 'superUltraTestDashboard';
+ const testAppId = 'testApp';
+
+ const buildKey = (appId: string, key: string) => `${appId}-${key}`;
+
beforeEach(() => {
currentAppId$ = new Subject();
currentAppId$.next(originatingApp);
@@ -82,7 +86,9 @@ describe('embeddable state transfer', () => {
it('can send an outgoing editor state', async () => {
await stateTransfer.navigateToEditor(destinationApp, { state: { originatingApp } });
expect(store.set).toHaveBeenCalledWith(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
- [EMBEDDABLE_EDITOR_STATE_KEY]: { originatingApp: 'superUltraTestDashboard' },
+ [buildKey(destinationApp, EMBEDDABLE_EDITOR_STATE_KEY)]: {
+ originatingApp: 'superUltraTestDashboard',
+ },
});
expect(application.navigateToApp).toHaveBeenCalledWith('superUltraVisualize', {
path: undefined,
@@ -98,7 +104,9 @@ describe('embeddable state transfer', () => {
});
expect(store.set).toHaveBeenCalledWith(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
kibanaIsNowForSports: 'extremeSportsKibana',
- [EMBEDDABLE_EDITOR_STATE_KEY]: { originatingApp: 'superUltraTestDashboard' },
+ [buildKey(destinationApp, EMBEDDABLE_EDITOR_STATE_KEY)]: {
+ originatingApp: 'superUltraTestDashboard',
+ },
});
expect(application.navigateToApp).toHaveBeenCalledWith('superUltraVisualize', {
path: undefined,
@@ -117,7 +125,10 @@ describe('embeddable state transfer', () => {
state: { type: 'coolestType', input: { savedObjectId: '150' } },
});
expect(store.set).toHaveBeenCalledWith(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
- [EMBEDDABLE_PACKAGE_STATE_KEY]: { type: 'coolestType', input: { savedObjectId: '150' } },
+ [buildKey(destinationApp, EMBEDDABLE_PACKAGE_STATE_KEY)]: {
+ type: 'coolestType',
+ input: { savedObjectId: '150' },
+ },
});
expect(application.navigateToApp).toHaveBeenCalledWith('superUltraVisualize', {
path: undefined,
@@ -133,7 +144,10 @@ describe('embeddable state transfer', () => {
});
expect(store.set).toHaveBeenCalledWith(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
kibanaIsNowForSports: 'extremeSportsKibana',
- [EMBEDDABLE_PACKAGE_STATE_KEY]: { type: 'coolestType', input: { savedObjectId: '150' } },
+ [buildKey(destinationApp, EMBEDDABLE_PACKAGE_STATE_KEY)]: {
+ type: 'coolestType',
+ input: { savedObjectId: '150' },
+ },
});
expect(application.navigateToApp).toHaveBeenCalledWith('superUltraVisualize', {
path: undefined,
@@ -151,42 +165,92 @@ describe('embeddable state transfer', () => {
it('can fetch an incoming editor state', async () => {
store.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
- [EMBEDDABLE_EDITOR_STATE_KEY]: { originatingApp: 'superUltraTestDashboard' },
+ [buildKey(testAppId, EMBEDDABLE_EDITOR_STATE_KEY)]: {
+ originatingApp: 'superUltraTestDashboard',
+ },
+ });
+ const fetchedState = stateTransfer.getIncomingEditorState(testAppId);
+ expect(fetchedState).toEqual({ originatingApp: 'superUltraTestDashboard' });
+ });
+
+ it('can fetch an incoming editor state and ignore state for other apps', async () => {
+ store.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
+ [buildKey('otherApp1', EMBEDDABLE_EDITOR_STATE_KEY)]: {
+ originatingApp: 'whoops not me',
+ },
+ [buildKey('otherApp2', EMBEDDABLE_EDITOR_STATE_KEY)]: {
+ originatingApp: 'otherTestDashboard',
+ },
+ [buildKey(testAppId, EMBEDDABLE_EDITOR_STATE_KEY)]: {
+ originatingApp: 'superUltraTestDashboard',
+ },
});
- const fetchedState = stateTransfer.getIncomingEditorState();
+ const fetchedState = stateTransfer.getIncomingEditorState(testAppId);
expect(fetchedState).toEqual({ originatingApp: 'superUltraTestDashboard' });
+
+ const fetchedState2 = stateTransfer.getIncomingEditorState('otherApp2');
+ expect(fetchedState2).toEqual({ originatingApp: 'otherTestDashboard' });
});
it('incoming editor state returns undefined when state is not in the right shape', async () => {
store.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
- [EMBEDDABLE_EDITOR_STATE_KEY]: { helloSportsKibana: 'superUltraTestDashboard' },
+ [buildKey(testAppId, EMBEDDABLE_EDITOR_STATE_KEY)]: {
+ helloSportsKibana: 'superUltraTestDashboard',
+ },
});
- const fetchedState = stateTransfer.getIncomingEditorState();
+ const fetchedState = stateTransfer.getIncomingEditorState(testAppId);
expect(fetchedState).toBeUndefined();
});
it('can fetch an incoming embeddable package state', async () => {
store.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
- [EMBEDDABLE_PACKAGE_STATE_KEY]: { type: 'skisEmbeddable', input: { savedObjectId: '123' } },
+ [buildKey(testAppId, EMBEDDABLE_PACKAGE_STATE_KEY)]: {
+ type: 'skisEmbeddable',
+ input: { savedObjectId: '123' },
+ },
});
- const fetchedState = stateTransfer.getIncomingEmbeddablePackage();
+ const fetchedState = stateTransfer.getIncomingEmbeddablePackage(testAppId);
expect(fetchedState).toEqual({ type: 'skisEmbeddable', input: { savedObjectId: '123' } });
});
+ it('can fetch an incoming embeddable package state and ignore state for other apps', async () => {
+ store.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
+ [buildKey(testAppId, EMBEDDABLE_PACKAGE_STATE_KEY)]: {
+ type: 'skisEmbeddable',
+ input: { savedObjectId: '123' },
+ },
+ [buildKey('testApp2', EMBEDDABLE_PACKAGE_STATE_KEY)]: {
+ type: 'crossCountryEmbeddable',
+ input: { savedObjectId: '456' },
+ },
+ });
+ const fetchedState = stateTransfer.getIncomingEmbeddablePackage(testAppId);
+ expect(fetchedState).toEqual({ type: 'skisEmbeddable', input: { savedObjectId: '123' } });
+
+ const fetchedState2 = stateTransfer.getIncomingEmbeddablePackage('testApp2');
+ expect(fetchedState2).toEqual({
+ type: 'crossCountryEmbeddable',
+ input: { savedObjectId: '456' },
+ });
+ });
+
it('embeddable package state returns undefined when state is not in the right shape', async () => {
store.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
- [EMBEDDABLE_PACKAGE_STATE_KEY]: { kibanaIsFor: 'sports' },
+ [buildKey(testAppId, EMBEDDABLE_PACKAGE_STATE_KEY)]: { kibanaIsFor: 'sports' },
});
- const fetchedState = stateTransfer.getIncomingEmbeddablePackage();
+ const fetchedState = stateTransfer.getIncomingEmbeddablePackage(testAppId);
expect(fetchedState).toBeUndefined();
});
it('removes embeddable package key when removeAfterFetch is true', async () => {
store.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
- [EMBEDDABLE_PACKAGE_STATE_KEY]: { type: 'coolestType', input: { savedObjectId: '150' } },
+ [buildKey(testAppId, EMBEDDABLE_PACKAGE_STATE_KEY)]: {
+ type: 'coolestType',
+ input: { savedObjectId: '150' },
+ },
iSHouldStillbeHere: 'doing the sports thing',
});
- stateTransfer.getIncomingEmbeddablePackage(true);
+ stateTransfer.getIncomingEmbeddablePackage(testAppId, true);
expect(store.get(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY)).toEqual({
iSHouldStillbeHere: 'doing the sports thing',
});
@@ -194,10 +258,12 @@ describe('embeddable state transfer', () => {
it('removes editor state key when removeAfterFetch is true', async () => {
store.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, {
- [EMBEDDABLE_EDITOR_STATE_KEY]: { originatingApp: 'superCoolFootballDashboard' },
+ [buildKey(testAppId, EMBEDDABLE_EDITOR_STATE_KEY)]: {
+ originatingApp: 'superCoolFootballDashboard',
+ },
iSHouldStillbeHere: 'doing the sports thing',
});
- stateTransfer.getIncomingEditorState(true);
+ stateTransfer.getIncomingEditorState(testAppId, true);
expect(store.get(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY)).toEqual({
iSHouldStillbeHere: 'doing the sports thing',
});
diff --git a/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.ts b/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.ts
index d3b1c1c76aadf..8664a5aae7345 100644
--- a/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.ts
+++ b/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.ts
@@ -50,13 +50,18 @@ export class EmbeddableStateTransfer {
public getAppNameFromId = (appId: string): string | undefined => this.appList?.get(appId)?.title;
/**
- * Fetches an {@link EmbeddableEditorState | originating app} argument from the sessionStorage
+ * Fetches an {@link EmbeddableEditorState | editor state} from the sessionStorage for the provided app id
*
+ * @param appId - The app to fetch incomingEditorState for
* @param removeAfterFetch - Whether to remove the package state after fetch to prevent duplicates.
*/
- public getIncomingEditorState(removeAfterFetch?: boolean): EmbeddableEditorState | undefined {
+ public getIncomingEditorState(
+ appId: string,
+ removeAfterFetch?: boolean
+ ): EmbeddableEditorState | undefined {
return this.getIncomingState(
isEmbeddableEditorState,
+ appId,
EMBEDDABLE_EDITOR_STATE_KEY,
{
keysToRemoveAfterFetch: removeAfterFetch ? [EMBEDDABLE_EDITOR_STATE_KEY] : undefined,
@@ -64,24 +69,33 @@ export class EmbeddableStateTransfer {
);
}
- public clearEditorState() {
+ /**
+ * Clears the {@link EmbeddableEditorState | editor state} from the sessionStorage for the provided app id
+ *
+ * @param appId - The app to fetch incomingEditorState for
+ * @param removeAfterFetch - Whether to remove the package state after fetch to prevent duplicates.
+ */
+ public clearEditorState(appId: string) {
const currentState = this.storage.get(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY);
if (currentState) {
- delete currentState[EMBEDDABLE_EDITOR_STATE_KEY];
+ delete currentState[this.buildKey(appId, EMBEDDABLE_EDITOR_STATE_KEY)];
this.storage.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, currentState);
}
}
/**
- * Fetches an {@link EmbeddablePackageState | embeddable package} argument from the sessionStorage
+ * Fetches an {@link EmbeddablePackageState | embeddable package} from the sessionStorage for the given AppId
*
+ * @param appId - The app to fetch EmbeddablePackageState for
* @param removeAfterFetch - Whether to remove the package state after fetch to prevent duplicates.
*/
public getIncomingEmbeddablePackage(
+ appId: string,
removeAfterFetch?: boolean
): EmbeddablePackageState | undefined {
return this.getIncomingState(
isEmbeddablePackageState,
+ appId,
EMBEDDABLE_PACKAGE_STATE_KEY,
{
keysToRemoveAfterFetch: removeAfterFetch ? [EMBEDDABLE_PACKAGE_STATE_KEY] : undefined,
@@ -122,20 +136,27 @@ export class EmbeddableStateTransfer {
});
}
+ private buildKey(appId: string, key: string) {
+ return `${appId}-${key}`;
+ }
+
private getIncomingState(
guard: (state: unknown) => state is IncomingStateType,
+ appId: string,
key: string,
options?: {
keysToRemoveAfterFetch?: string[];
}
): IncomingStateType | undefined {
- const incomingState = this.storage.get(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY)?.[key];
+ const incomingState = this.storage.get(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY)?.[
+ this.buildKey(appId, key)
+ ];
const castState =
!guard || guard(incomingState) ? (cloneDeep(incomingState) as IncomingStateType) : undefined;
if (castState && options?.keysToRemoveAfterFetch) {
const stateReplace = { ...this.storage.get(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY) };
options.keysToRemoveAfterFetch.forEach((keyToRemove: string) => {
- delete stateReplace[keyToRemove];
+ delete stateReplace[this.buildKey(appId, keyToRemove)];
});
this.storage.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, stateReplace);
}
@@ -150,9 +171,9 @@ export class EmbeddableStateTransfer {
const stateObject = options?.appendToExistingState
? {
...this.storage.get(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY),
- [key]: options.state,
+ [this.buildKey(appId, key)]: options.state,
}
- : { [key]: options?.state };
+ : { [this.buildKey(appId, key)]: options?.state };
this.storage.set(EMBEDDABLE_STATE_TRANSFER_STORAGE_KEY, stateObject);
await this.navigateToApp(appId, { path: options?.path });
}
diff --git a/src/plugins/embeddable/public/public.api.md b/src/plugins/embeddable/public/public.api.md
index 2f9b43121b45a..3e7014d54958d 100644
--- a/src/plugins/embeddable/public/public.api.md
+++ b/src/plugins/embeddable/public/public.api.md
@@ -590,11 +590,10 @@ export class EmbeddableStateTransfer {
// Warning: (ae-forgotten-export) The symbol "ApplicationStart" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "PublicAppInfo" needs to be exported by the entry point index.d.ts
constructor(navigateToApp: ApplicationStart['navigateToApp'], currentAppId$: ApplicationStart['currentAppId$'], appList?: ReadonlyMap | undefined, customStorage?: Storage);
- // (undocumented)
- clearEditorState(): void;
+ clearEditorState(appId: string): void;
getAppNameFromId: (appId: string) => string | undefined;
- getIncomingEditorState(removeAfterFetch?: boolean): EmbeddableEditorState | undefined;
- getIncomingEmbeddablePackage(removeAfterFetch?: boolean): EmbeddablePackageState | undefined;
+ getIncomingEditorState(appId: string, removeAfterFetch?: boolean): EmbeddableEditorState | undefined;
+ getIncomingEmbeddablePackage(appId: string, removeAfterFetch?: boolean): EmbeddablePackageState | undefined;
// (undocumented)
isTransferInProgress: boolean;
// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "ApplicationStart"
diff --git a/src/plugins/visualize/public/application/components/visualize_byvalue_editor.tsx b/src/plugins/visualize/public/application/components/visualize_byvalue_editor.tsx
index 6ca6efaa89797..fa0e0bd5f48f0 100644
--- a/src/plugins/visualize/public/application/components/visualize_byvalue_editor.tsx
+++ b/src/plugins/visualize/public/application/components/visualize_byvalue_editor.tsx
@@ -34,7 +34,7 @@ export const VisualizeByValueEditor = ({ onAppLeave }: VisualizeAppProps) => {
useEffect(() => {
const { originatingApp: value, embeddableId: embeddableIdValue, valueInput: valueInputValue } =
- services.stateTransferService.getIncomingEditorState() || {};
+ services.stateTransferService.getIncomingEditorState(VisualizeConstants.APP_ID) || {};
setOriginatingApp(value);
setValueInput(valueInputValue);
setEmbeddableId(embeddableIdValue);
diff --git a/src/plugins/visualize/public/application/components/visualize_editor.tsx b/src/plugins/visualize/public/application/components/visualize_editor.tsx
index 7465e7eaa9044..c6333e978183f 100644
--- a/src/plugins/visualize/public/application/components/visualize_editor.tsx
+++ b/src/plugins/visualize/public/application/components/visualize_editor.tsx
@@ -22,6 +22,7 @@ import {
import { VisualizeServices } from '../types';
import { VisualizeEditorCommon } from './visualize_editor_common';
import { VisualizeAppProps } from '../app';
+import { VisualizeConstants } from '../..';
export const VisualizeEditor = ({ onAppLeave }: VisualizeAppProps) => {
const { id: visualizationIdFromUrl } = useParams<{ id: string }>();
@@ -54,7 +55,8 @@ export const VisualizeEditor = ({ onAppLeave }: VisualizeAppProps) => {
useLinkedSearchUpdates(services, eventEmitter, appState, savedVisInstance);
useEffect(() => {
- const { originatingApp: value } = services.stateTransferService.getIncomingEditorState() || {};
+ const { originatingApp: value } =
+ services.stateTransferService.getIncomingEditorState(VisualizeConstants.APP_ID) || {};
setOriginatingApp(value);
}, [services]);
diff --git a/src/plugins/visualize/public/application/components/visualize_listing.tsx b/src/plugins/visualize/public/application/components/visualize_listing.tsx
index c772554344cb2..bc766d63db5a7 100644
--- a/src/plugins/visualize/public/application/components/visualize_listing.tsx
+++ b/src/plugins/visualize/public/application/components/visualize_listing.tsx
@@ -65,7 +65,7 @@ export const VisualizeListing = () => {
useMount(() => {
// Reset editor state if the visualize listing page is loaded.
- stateTransferService.clearEditorState();
+ stateTransferService.clearEditorState(VisualizeConstants.APP_ID);
chrome.setBreadcrumbs([
{
text: i18n.translate('visualize.visualizeListingBreadcrumbsTitle', {
diff --git a/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx b/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx
index 9ea42e8b56559..e8c3289d4ce41 100644
--- a/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx
+++ b/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx
@@ -142,7 +142,7 @@ export const getTopNavConfig = (
if (setOriginatingApp && originatingApp && newlyCreated) {
setOriginatingApp(undefined);
// remove editor state so the connection is still broken after reload
- stateTransfer.clearEditorState();
+ stateTransfer.clearEditorState(VisualizeConstants.APP_ID);
}
chrome.docTitle.change(savedVis.lastSavedTitle);
chrome.setBreadcrumbs(getEditBreadcrumbs({}, savedVis.lastSavedTitle));
diff --git a/src/plugins/visualize/public/application/visualize_constants.ts b/src/plugins/visualize/public/application/visualize_constants.ts
index 7dbf5be77b74d..6e901882a9365 100644
--- a/src/plugins/visualize/public/application/visualize_constants.ts
+++ b/src/plugins/visualize/public/application/visualize_constants.ts
@@ -16,4 +16,5 @@ export const VisualizeConstants = {
CREATE_PATH: '/create',
EDIT_PATH: '/edit',
EDIT_BY_VALUE_PATH: '/edit_by_value',
+ APP_ID: 'visualize',
};
diff --git a/src/plugins/visualize/public/plugin.ts b/src/plugins/visualize/public/plugin.ts
index 3d82e6c60a1b6..4eb2d6fd2a731 100644
--- a/src/plugins/visualize/public/plugin.ts
+++ b/src/plugins/visualize/public/plugin.ts
@@ -132,7 +132,7 @@ export class VisualizePlugin
setUISettings(core.uiSettings);
core.application.register({
- id: 'visualize',
+ id: VisualizeConstants.APP_ID,
title: 'Visualize',
order: 8000,
euiIconType: 'logoKibana',
@@ -147,7 +147,9 @@ export class VisualizePlugin
// allows the urlTracker to only save URLs that are not linked to an originatingApp
this.isLinkedToOriginatingApp = () => {
return Boolean(
- pluginsStart.embeddable.getStateTransfer().getIncomingEditorState()?.originatingApp
+ pluginsStart.embeddable
+ .getStateTransfer()
+ .getIncomingEditorState(VisualizeConstants.APP_ID)?.originatingApp
);
};
diff --git a/x-pack/plugins/lens/common/constants.ts b/x-pack/plugins/lens/common/constants.ts
index 202b80d3d8406..c3e556b167889 100644
--- a/x-pack/plugins/lens/common/constants.ts
+++ b/x-pack/plugins/lens/common/constants.ts
@@ -6,6 +6,7 @@
*/
export const PLUGIN_ID = 'lens';
+export const APP_ID = 'lens';
export const LENS_EMBEDDABLE_TYPE = 'lens';
export const DOC_TYPE = 'lens';
export const NOT_INTERNATIONALIZED_PRODUCT_NAME = 'Lens Visualizations';
diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx
index 7e95479887dbd..0d72a366fa411 100644
--- a/x-pack/plugins/lens/public/app_plugin/app.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/app.tsx
@@ -38,7 +38,7 @@ import {
SavedQuery,
syncQueryStateWithUrl,
} from '../../../../../src/plugins/data/public';
-import { LENS_EMBEDDABLE_TYPE, getFullPath } from '../../common';
+import { LENS_EMBEDDABLE_TYPE, getFullPath, APP_ID } from '../../common';
import { LensAppProps, LensAppServices, LensAppState } from './types';
import { getLensTopNavConfig } from './lens_top_nav';
import { Document } from '../persistence';
@@ -498,7 +498,7 @@ export function App({
isLinkedToOriginatingApp: false,
}));
// remove editor state so the connection is still broken after reload
- stateTransfer.clearEditorState();
+ stateTransfer.clearEditorState(APP_ID);
redirectTo(newInput.savedObjectId);
return;
diff --git a/x-pack/plugins/lens/public/app_plugin/mounter.tsx b/x-pack/plugins/lens/public/app_plugin/mounter.tsx
index 1ff31e5d4bf6b..5869151485a52 100644
--- a/x-pack/plugins/lens/public/app_plugin/mounter.tsx
+++ b/x-pack/plugins/lens/public/app_plugin/mounter.tsx
@@ -23,7 +23,7 @@ import { App } from './app';
import { EditorFrameStart } from '../types';
import { addHelpMenuToAppChrome } from '../help_menu_util';
import { LensPluginStartDependencies } from '../plugin';
-import { LENS_EMBEDDABLE_TYPE, LENS_EDIT_BY_VALUE } from '../../common';
+import { LENS_EMBEDDABLE_TYPE, LENS_EDIT_BY_VALUE, APP_ID } from '../../common';
import {
LensEmbeddableInput,
LensByReferenceInput,
@@ -57,7 +57,7 @@ export async function mountApp(
const storage = new Storage(localStorage);
const stateTransfer = embeddable?.getStateTransfer();
const historyLocationState = params.history.location.state as HistoryLocationState;
- const embeddableEditorIncomingState = stateTransfer?.getIncomingEditorState();
+ const embeddableEditorIncomingState = stateTransfer?.getIncomingEditorState(APP_ID);
const lensServices: LensAppServices = {
data,
diff --git a/x-pack/plugins/lens/public/plugin.ts b/x-pack/plugins/lens/public/plugin.ts
index 05da76d9fd207..c667ddea06b33 100644
--- a/x-pack/plugins/lens/public/plugin.ts
+++ b/x-pack/plugins/lens/public/plugin.ts
@@ -40,7 +40,7 @@ import {
ACTION_VISUALIZE_FIELD,
VISUALIZE_FIELD_TRIGGER,
} from '../../../../src/plugins/ui_actions/public';
-import { getEditPath, NOT_INTERNATIONALIZED_PRODUCT_NAME } from '../common';
+import { APP_ID, getEditPath, NOT_INTERNATIONALIZED_PRODUCT_NAME } from '../common';
import { EditorFrameStart } from './types';
import { getLensAliasConfig } from './vis_type_alias';
import { visualizeFieldAction } from './trigger_actions/visualize_field_actions';
@@ -182,7 +182,7 @@ export class LensPlugin {
};
core.application.register({
- id: 'lens',
+ id: APP_ID,
title: NOT_INTERNATIONALIZED_PRODUCT_NAME,
navLinkStatus: AppNavLinkStatus.hidden,
mount: async (params: AppMountParameters) => {
diff --git a/x-pack/plugins/maps/public/render_app.tsx b/x-pack/plugins/maps/public/render_app.tsx
index ccd30126b67bd..4d1dff9303b0c 100644
--- a/x-pack/plugins/maps/public/render_app.tsx
+++ b/x-pack/plugins/maps/public/render_app.tsx
@@ -26,6 +26,7 @@ import {
} from '../../../../src/plugins/kibana_utils/public';
import { ListPage, MapPage } from './routes';
import { MapByValueInput, MapByReferenceInput } from './embeddable/types';
+import { APP_ID } from '../common/constants';
export let goToSpecifiedPath: (path: string) => void;
export let kbnUrlStateStorage: IKbnUrlStateStorage;
@@ -80,7 +81,7 @@ export async function renderApp({
function renderMapApp(routeProps: RouteComponentProps<{ savedMapId?: string }>) {
const { embeddableId, originatingApp, valueInput } =
- stateTransfer.getIncomingEditorState() || {};
+ stateTransfer.getIncomingEditorState(APP_ID) || {};
let mapEmbeddableInput;
if (routeProps.match.params.savedMapId) {
diff --git a/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx b/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx
index 66b65eb8d0a9d..feafb34f6a715 100644
--- a/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx
+++ b/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx
@@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n';
import { Redirect } from 'react-router-dom';
import { getSavedObjectsClient, getToasts } from '../../kibana_services';
import { MapsListView } from './maps_list_view';
-import { MAP_SAVED_OBJECT_TYPE } from '../../../common/constants';
+import { APP_ID, MAP_SAVED_OBJECT_TYPE } from '../../../common/constants';
import { EmbeddableStateTransfer } from '../../../../../../src/plugins/embeddable/public';
export class LoadListAndRender extends React.Component<{ stateTransfer: EmbeddableStateTransfer }> {
@@ -22,7 +22,7 @@ export class LoadListAndRender extends React.Component<{ stateTransfer: Embeddab
componentDidMount() {
this._isMounted = true;
- this.props.stateTransfer.clearEditorState();
+ this.props.stateTransfer.clearEditorState(APP_ID);
this._loadMapsList();
}
diff --git a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts
index d38ff8b3e4da6..b6ee5274f690d 100644
--- a/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts
+++ b/x-pack/plugins/maps/public/routes/map_page/saved_map/saved_map.ts
@@ -9,7 +9,7 @@ import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { EmbeddableStateTransfer } from 'src/plugins/embeddable/public';
import { MapSavedObjectAttributes } from '../../../../common/map_saved_object_type';
-import { MAP_PATH, MAP_SAVED_OBJECT_TYPE } from '../../../../common/constants';
+import { APP_ID, MAP_PATH, MAP_SAVED_OBJECT_TYPE } from '../../../../common/constants';
import { createMapStore, MapStore, MapStoreState } from '../../../reducers/store';
import {
getTimeFilters,
@@ -364,7 +364,7 @@ export class SavedMap {
this._originatingApp = undefined;
// remove editor state so the connection is still broken after reload
- this._getStateTransfer().clearEditorState();
+ this._getStateTransfer().clearEditorState(APP_ID);
getToasts().addSuccess({
title: i18n.translate('xpack.maps.topNav.saveSuccessMessage', {