Skip to content

Commit

Permalink
Fix adding new visualization from dashboard when session storage is e…
Browse files Browse the repository at this point in the history
…nabled. (#73517)

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
ThomThomson and elasticmachine authored Jul 28, 2020
1 parent e72d17c commit 0f89789
Showing 1 changed file with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ export class DashboardAppController {
chrome.docTitle.change(dash.title);
}

const incomingEmbeddable = embeddable
.getStateTransfer(scopedHistory())
.getIncomingEmbeddablePackage();

const dashboardStateManager = new DashboardStateManager({
savedDashboard: dash,
hideWriteControls: dashboardConfig.getHideWriteControls(),
Expand Down Expand Up @@ -444,21 +448,24 @@ export class DashboardAppController {
refreshDashboardContainer();
});

const incomingState = embeddable
.getStateTransfer(scopedHistory())
.getIncomingEmbeddablePackage();
if (incomingState) {
if ('id' in incomingState) {
container.addOrUpdateEmbeddable<SavedObjectEmbeddableInput>(incomingState.type, {
savedObjectId: incomingState.id,
});
} else if ('input' in incomingState) {
const input = incomingState.input;
if (incomingEmbeddable) {
if ('id' in incomingEmbeddable) {
container.addOrUpdateEmbeddable<SavedObjectEmbeddableInput>(
incomingEmbeddable.type,
{
savedObjectId: incomingEmbeddable.id,
}
);
} else if ('input' in incomingEmbeddable) {
const input = incomingEmbeddable.input;
delete input.id;
const explicitInput = {
savedVis: input,
};
container.addOrUpdateEmbeddable<EmbeddableInput>(incomingState.type, explicitInput);
container.addOrUpdateEmbeddable<EmbeddableInput>(
incomingEmbeddable.type,
explicitInput
);
}
}
}
Expand Down

0 comments on commit 0f89789

Please sign in to comment.