Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Nov 10, 2020
1 parent fbec631 commit 49623c9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/plugins/vis_type_timeseries/public/metrics_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { EditorController } from './application';
import { PANEL_TYPES } from '../common/panel_types';
import { VisEditor } from './application/components/vis_editor_lazy';
import { VIS_EVENT_TO_TRIGGER, VisGroups, VisParams } from '../../visualizations/public';
import { getSavedObjectsClient, getDataStart } from './services';
import { getDataStart } from './services';
import { INDEXES_SEPARATOR } from '../common/constants';

export const metricsVisDefinition = {
Expand Down Expand Up @@ -88,16 +88,18 @@ export const metricsVisDefinition = {
inspectorAdapters: {},
getUsedIndexPattern: async (params: VisParams) => {
const { indexPatterns } = getDataStart();
const indexes: string = params.index_pattern;

if (params.index_pattern) {
if (indexes) {
const cachedIndexes = await indexPatterns.getIdsWithTitle();
const ids = params.index_pattern
const ids = indexes
.split(INDEXES_SEPARATOR)
.map((title) => cachedIndexes.find((i) => i.title === title)?.id)
.filter((id) => id);

return Promise.all(ids.map((is) => indexPatterns.get(is)));
return Promise.all(ids.map((id) => indexPatterns.get(id!)));
}

return [];
},
responseHandler: 'none',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
import { VisualizeEmbeddableFactoryDeps } from './visualize_embeddable_factory';
import { VISUALIZE_ENABLE_LABS_SETTING } from '../../common/constants';
import { SavedVisualizationsLoader } from '../saved_visualizations';
import { IndexPattern } from '../../../data/public';

export const createVisEmbeddableFromObject = (deps: VisualizeEmbeddableFactoryDeps) => async (
vis: Vis,
Expand Down Expand Up @@ -69,12 +70,12 @@ export const createVisEmbeddableFromObject = (deps: VisualizeEmbeddableFactoryDe
return new DisabledLabEmbeddable(vis.title, input);
}

let indexPatterns = [];
let indexPatterns: IndexPattern[] = [];

if (vis.type.getUsedIndexPattern) {
indexPatterns = await vis.type.getUsedIndexPattern(vis.params);
} else if (vis.data.indexPattern) {
indexPatterns = [vis.data.indexPatter];
indexPatterns = [vis.data.indexPattern];
}

const editable = getCapabilities().visualize.save as boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface CommonBaseVisTypeOptions<TVisParams>
| 'editorConfig'
| 'hidden'
| 'stage'
| 'useCustomSearchSource'
| 'getUsedIndexPattern'
| 'useCustomNoDataScreen'
| 'visConfig'
| 'group'
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/visualizations/public/vis_types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { IconType } from '@elastic/eui';
import React from 'react';
import { Adapters } from 'src/plugins/inspector';
import { IIndexPattern } from 'src/plugins/data/public';
import { IndexPattern } from 'src/plugins/data/public';
import { VisEditorConstructor } from 'src/plugins/visualize/public';
import { ISchemas } from 'src/plugins/vis_default_editor/public';
import { TriggerContextMapping } from '../../../ui_actions/public';
Expand Down Expand Up @@ -70,7 +70,7 @@ export interface VisType<TVisParams = unknown> {
* Some visualizations are created without SearchSource and may change the used indexes during the visualization configuration.
* Using this method we can rewrite the standard mechanism for getting used indexes
*/
readonly getUsedIndexPattern?: (visParams: VisParams) => IIndexPattern[];
readonly getUsedIndexPattern?: (visParams: VisParams) => IndexPattern[] | Promise<IndexPattern[]>;

readonly isAccessible?: boolean;
readonly requestHandler?: string | unknown;
Expand Down

0 comments on commit 49623c9

Please sign in to comment.