Skip to content

Commit

Permalink
Add index pattern info when loading embeddable (#2363) (#2370)
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)

Co-authored-by: Qingyang(Abby) Hu <[email protected]>
(cherry picked from commit 0720f14)
  • Loading branch information
opensearch-trigger-bot[bot] authored and github-actions[bot] committed Sep 15, 2022
1 parent 01223bf commit 1c94092
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 1c94092

Please sign in to comment.