diff --git a/src/plugins/vis_type_timeseries/public/application/components/index_pattern_select/combo_box_select.tsx b/src/plugins/vis_type_timeseries/public/application/components/index_pattern_select/combo_box_select.tsx index 1a047ac946e7..4371ab6ad90b 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/index_pattern_select/combo_box_select.tsx +++ b/src/plugins/vis_type_timeseries/public/application/components/index_pattern_select/combo_box_select.tsx @@ -36,6 +36,9 @@ const toSelectedOptions = ( return []; }; +const toComboBoxOptions = (options: IdsWithTitle) => + options.map(({ title, id }) => ({ label: title, id })); + export const ComboBoxSelect = ({ onIndexChange, onModeChange, @@ -53,9 +56,6 @@ export const ComboBoxSelect = ({ [onIndexChange] ); - const toComboBoxOptions = (options: IdsWithTitle) => - options.map(({ title, id }) => ({ label: title, id })); - useEffect(() => { async function fetchIndexes() { setAvailableIndexes(await getDataStart().indexPatterns.getIdsWithTitle()); diff --git a/src/plugins/vis_type_timeseries/public/application/components/index_pattern_select/legacy_mode_popover.tsx b/src/plugins/vis_type_timeseries/public/application/components/index_pattern_select/legacy_mode_popover.tsx index fd09cde7ec11..f3948ba4374b 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/index_pattern_select/legacy_mode_popover.tsx +++ b/src/plugins/vis_type_timeseries/public/application/components/index_pattern_select/legacy_mode_popover.tsx @@ -98,14 +98,16 @@ export const LegacyModePopover = ({ index }: LegacyModePopoverProps) => { useEffect(() => { async function retrieveIndex() { + const shouldShowExtraCallOuts = Boolean(index); let hasIndex = false; - if (index) { + + if (shouldShowExtraCallOuts) { const { indexPatterns } = getDataStart(); hasIndex = Boolean((await indexPatterns.find(index)).find((i) => i.title === index)); } - setShowReadyToMigrateCallOut(Boolean(index) && hasIndex); - setNoMatchedIndicesCallOut(Boolean(index) && !hasIndex); + setShowReadyToMigrateCallOut(shouldShowExtraCallOuts && hasIndex); + setNoMatchedIndicesCallOut(shouldShowExtraCallOuts && !hasIndex); } retrieveIndex(); diff --git a/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts b/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts index 89df7aec8d8e..d2c16f527b1c 100644 --- a/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts +++ b/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts @@ -748,6 +748,35 @@ const removeTSVBSearchSource: SavedObjectMigrationFn = (doc) => { return doc; }; +const addSupportOfDualIndexSelectionModeInTSVB: SavedObjectMigrationFn = (doc) => { + const visStateJSON = get(doc, 'attributes.visState'); + let visState; + + if (visStateJSON) { + try { + visState = JSON.parse(visStateJSON); + } catch (e) { + // Let it go, the data is invalid and we'll leave it as is + } + if (visState && visState.type === 'metrics') { + const { params } = visState; + + if (typeof params?.index_pattern === 'string') { + params.use_kibana_indexes = false; + } + + return { + ...doc, + attributes: { + ...doc.attributes, + visState: JSON.stringify(visState), + }, + }; + } + } + return doc; +}; + // [Data table visualization] Enable toolbar by default const enableDataTableVisToolbar: SavedObjectMigrationFn = (doc) => { let visState; @@ -884,4 +913,5 @@ export const visualizationSavedObjectTypeMigrations = { '7.10.0': flow(migrateFilterRatioQuery, removeTSVBSearchSource), '7.11.0': flow(enableDataTableVisToolbar), '7.12.0': flow(migrateVislibAreaLineBarTypes), + '7.13.0': flow(addSupportOfDualIndexSelectionModeInTSVB), };