Skip to content

Commit

Permalink
Add index pattern info when loading embeddable (#2363) (#2370) (#2374)
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 <abigailhu2000@gmail.com>

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
(cherry picked from commit dc0d7d5)

Co-authored-by: Qingyang(Abby) Hu <abigailhu2000@gmail.com>
(cherry picked from commit 0720f14)

Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
  • Loading branch information
opensearch-trigger-bot[bot] committed Sep 16, 2022
1 parent 92dd0b5 commit 3cb584b
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 3cb584b

Please sign in to comment.