Skip to content

Commit

Permalink
Add index pattern info when loading embeddable (#2363)
Browse files Browse the repository at this point in the history
Since index pattern is not included in the visualization state anymore,
need to add the index pattern information so the embeddable can be loaded correctly.

Signed-off-by: abbyhu2000 <[email protected]>

Signed-off-by: abbyhu2000 <[email protected]>
(cherry picked from commit dc0d7d5)
  • Loading branch information
abbyhu2000 authored and github-actions[bot] committed Sep 15, 2022
1 parent 3e0d117 commit 059f16b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/plugins/wizard/common/wizard_saved_object_attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ export interface WizardSavedObjectAttributes extends SavedObjectAttributes {
visualizationState?: string;
styleState?: string;
version: number;
searchSourceFields?: {
index?: string;
};
}
9 changes: 8 additions & 1 deletion src/plugins/wizard/public/embeddable/wizard_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,15 @@ export class WizardEmbeddable extends Embeddable<SavedObjectEmbeddableInput, Wiz
return;
}
const { visualization, style } = this.serializedState;

const vizStateWithoutIndex = JSON.parse(visualization);
const visualizationState = {
searchField: vizStateWithoutIndex.searchField,
activeVisualization: vizStateWithoutIndex.activeVisualization,
indexPattern: this.savedWizard?.searchSourceFields?.index,
};
const rootState = {
visualization: JSON.parse(visualization),
visualization: visualizationState,
style: JSON.parse(style),
};
const visualizationName = rootState.visualization?.activeVisualization?.name ?? '';
Expand Down

0 comments on commit 059f16b

Please sign in to comment.