Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Embeddable] Always send value input from edit panel action #155283

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { EditPanelAction } from './edit_panel_action';
import { Embeddable, EmbeddableInput, SavedObjectEmbeddableInput } from '../embeddables';
import { Embeddable, EmbeddableInput } from '../embeddables';
import { ViewMode } from '../types';
import { ContactCardEmbeddable } from '../test_samples';
import { embeddablePluginMock } from '../../mocks';
Expand Down Expand Up @@ -42,7 +42,7 @@ test('is compatible when edit url is available, in edit mode and editable', asyn
).toBe(true);
});

test('redirects to app using state transfer with by value mode', async () => {
test('redirects to app using state transfer', async () => {
applicationMock.currentAppId$ = of('superCoolCurrentApp');
const testPath = '/test-path';
const action = new EditPanelAction(
Expand Down Expand Up @@ -78,32 +78,6 @@ test('redirects to app using state transfer with by value mode', async () => {
});
});

test('redirects to app using state transfer without by value mode', async () => {
applicationMock.currentAppId$ = of('superCoolCurrentApp');
const testPath = '/test-path';
const action = new EditPanelAction(
getFactory,
applicationMock,
stateTransferMock,
() => testPath
);
const embeddable = new EditableEmbeddable(
{ id: '123', viewMode: ViewMode.EDIT, savedObjectId: '1234' } as SavedObjectEmbeddableInput,
true
);
embeddable.getOutput = jest.fn(() => ({ editApp: 'ultraVisualize', editPath: '/123' }));
await action.execute({ embeddable });
expect(stateTransferMock.navigateToEditor).toHaveBeenCalledWith('ultraVisualize', {
path: '/123',
state: {
originatingApp: 'superCoolCurrentApp',
embeddableId: '123',
valueInput: undefined,
originatingPath: testPath,
},
});
});

test('getHref returns the edit urls', async () => {
const action = new EditPanelAction(getFactory, applicationMock, stateTransferMock);
expect(action.getHref).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
IEmbeddable,
EmbeddableEditorState,
EmbeddableStateTransfer,
SavedObjectEmbeddableInput,
EmbeddableInput,
Container,
} from '../..';
Expand Down Expand Up @@ -124,13 +123,11 @@ export class EditPanelAction implements Action<ActionContext> {

if (app && path) {
if (this.currentAppId) {
const byValueMode = !(embeddable.getInput() as SavedObjectEmbeddableInput).savedObjectId;

const originatingPath = this.getOriginatingPath?.();

const state: EmbeddableEditorState = {
originatingApp: this.currentAppId,
valueInput: byValueMode ? this.getExplicitInput({ embeddable }) : undefined,
valueInput: this.getExplicitInput({ embeddable }),
embeddableId: embeddable.id,
searchSessionId: embeddable.getInput().searchSessionId,
originatingPath,
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/maps/public/render_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ export async function renderApp(
mapEmbeddableInput = {
savedObjectId: routeProps.match.params.savedMapId,
} as MapByReferenceInput;
}
if (valueInput) {
} else if (valueInput) {
mapEmbeddableInput = valueInput as MapByValueInput;
}

Expand Down