mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Timelion, Vega, TSVB] Migrate to dataViews service (#128127)
* Timelion dataview service * TSVB dataview service * Fix TSVB tests * Vega DataViews service
This commit is contained in:
parent
395c65feca
commit
279d3e5efd
58 changed files with 227 additions and 199 deletions
|
@ -4,7 +4,7 @@
|
|||
"kibanaVersion": "kibana",
|
||||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["visualizations", "data", "expressions", "charts"],
|
||||
"requiredPlugins": ["visualizations", "data", "expressions", "charts", "dataViews"],
|
||||
"requiredBundles": ["kibanaUtils", "kibanaReact", "visDefaultEditor"],
|
||||
"owner": {
|
||||
"name": "Vis Editors",
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
import { SUGGESTION_TYPE, suggest } from './timelion_expression_input_helpers';
|
||||
import { getArgValueSuggestions } from '../helpers/arg_value_suggestions';
|
||||
import { setIndexPatterns } from '../helpers/plugin_services';
|
||||
import { IndexPatternsContract } from 'src/plugins/data/public';
|
||||
import { DataViewsContract } from 'src/plugins/data_views/public';
|
||||
import { ITimelionFunction } from '../../common/types';
|
||||
|
||||
describe('Timelion expression suggestions', () => {
|
||||
setIndexPatterns({} as IndexPatternsContract);
|
||||
setIndexPatterns({} as DataViewsContract);
|
||||
|
||||
const argValueSuggestions = getArgValueSuggestions();
|
||||
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
*/
|
||||
|
||||
import { get } from 'lodash';
|
||||
import { isNestedField } from '../../../..//data_views/common';
|
||||
import { getIndexPatterns } from './plugin_services';
|
||||
import { TimelionFunctionArgs } from '../../common/types';
|
||||
import { TimelionExpressionFunction, TimelionExpressionArgument } from '../../common/parser';
|
||||
import { indexPatterns as indexPatternsUtils, KBN_FIELD_TYPES } from '../../../../data/public';
|
||||
import { KBN_FIELD_TYPES } from '../../../../data/public';
|
||||
|
||||
export function getArgValueSuggestions() {
|
||||
const indexPatterns = getIndexPatterns();
|
||||
|
@ -71,9 +72,7 @@ export function getArgValueSuggestions() {
|
|||
.getByType(KBN_FIELD_TYPES.NUMBER)
|
||||
.filter(
|
||||
(field) =>
|
||||
field.aggregatable &&
|
||||
containsFieldName(valueSplit[1], field) &&
|
||||
!indexPatternsUtils.isNestedField(field)
|
||||
field.aggregatable && containsFieldName(valueSplit[1], field) && !isNestedField(field)
|
||||
)
|
||||
.map((field) => {
|
||||
const suggestionValue = field.name.replaceAll(':', '\\:');
|
||||
|
@ -103,7 +102,7 @@ export function getArgValueSuggestions() {
|
|||
KBN_FIELD_TYPES.STRING,
|
||||
].includes(field.type as KBN_FIELD_TYPES) &&
|
||||
containsFieldName(partial, field) &&
|
||||
!indexPatternsUtils.isNestedField(field)
|
||||
!isNestedField(field)
|
||||
)
|
||||
.map((field) => ({ name: field.name, help: field.type, insertText: field.name }));
|
||||
},
|
||||
|
@ -115,9 +114,7 @@ export function getArgValueSuggestions() {
|
|||
|
||||
return indexPattern.fields
|
||||
.getByType(KBN_FIELD_TYPES.DATE)
|
||||
.filter(
|
||||
(field) => containsFieldName(partial, field) && !indexPatternsUtils.isNestedField(field)
|
||||
)
|
||||
.filter((field) => containsFieldName(partial, field) && !isNestedField(field))
|
||||
.map((field) => ({ name: field.name, insertText: field.name }));
|
||||
},
|
||||
},
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { IndexPatternsContract, ISearchStart } from 'src/plugins/data/public';
|
||||
import type { ISearchStart } from 'src/plugins/data/public';
|
||||
import type { DataViewsContract } from 'src/plugins/data_views/public';
|
||||
import type { ChartsPluginStart } from 'src/plugins/charts/public';
|
||||
import { createGetterSetter } from '../../../../kibana_utils/public';
|
||||
|
||||
export const [getIndexPatterns, setIndexPatterns] =
|
||||
createGetterSetter<IndexPatternsContract>('IndexPatterns');
|
||||
createGetterSetter<DataViewsContract>('dataViews');
|
||||
|
||||
export const [getDataSearch, setDataSearch] = createGetterSetter<ISearchStart>('Search');
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import type {
|
|||
DataPublicPluginStart,
|
||||
TimefilterContract,
|
||||
} from 'src/plugins/data/public';
|
||||
import type { DataViewsPublicPluginStart } from 'src/plugins/data_views/public';
|
||||
import type { VisualizationsSetup } from 'src/plugins/visualizations/public';
|
||||
import type { ChartsPluginSetup, ChartsPluginStart } from 'src/plugins/charts/public';
|
||||
|
||||
|
@ -52,6 +53,7 @@ export interface TimelionVisSetupDependencies {
|
|||
/** @internal */
|
||||
export interface TimelionVisStartDependencies {
|
||||
data: DataPublicPluginStart;
|
||||
dataViews: DataViewsPublicPluginStart;
|
||||
charts: ChartsPluginStart;
|
||||
}
|
||||
|
||||
|
@ -88,8 +90,8 @@ export class TimelionVisPlugin
|
|||
visualizations.createBaseVisualization(getTimelionVisDefinition(dependencies));
|
||||
}
|
||||
|
||||
public start(core: CoreStart, { data, charts }: TimelionVisStartDependencies) {
|
||||
setIndexPatterns(data.indexPatterns);
|
||||
public start(core: CoreStart, { data, charts, dataViews }: TimelionVisStartDependencies) {
|
||||
setIndexPatterns(dataViews);
|
||||
setDataSearch(data.search);
|
||||
setCharts(charts);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import type {
|
|||
PluginStart,
|
||||
DataRequestHandlerContext,
|
||||
} from '../../../../../src/plugins/data/server';
|
||||
import type { PluginStart as DataViewPluginStart } from '../../../../../src/plugins/data_views/server';
|
||||
import { CoreSetup, PluginInitializerContext, Plugin } from '../../../../../src/core/server';
|
||||
import { configSchema } from '../config';
|
||||
import loadFunctions from './lib/load_functions';
|
||||
|
@ -23,6 +24,7 @@ import { getUiSettings } from './ui_settings';
|
|||
|
||||
export interface TimelionPluginStartDeps {
|
||||
data: PluginStart;
|
||||
dataViews: DataViewPluginStart;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,9 +76,9 @@ export function runRoute(
|
|||
},
|
||||
},
|
||||
router.handleLegacyErrors(async (context, request, response) => {
|
||||
const [, { data }] = await core.getStartServices();
|
||||
const [, { dataViews }] = await core.getStartServices();
|
||||
const uiSettings = await context.core.uiSettings.client.getAll();
|
||||
const indexPatternsService = await data.indexPatterns.indexPatternsServiceFactory(
|
||||
const indexPatternsService = await dataViews.dataViewsServiceFactory(
|
||||
context.core.savedObjects.client,
|
||||
context.core.elasticsearch.client.asCurrentUser
|
||||
);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
{ "path": "../../../core/tsconfig.json" },
|
||||
{ "path": "../../visualizations/tsconfig.json" },
|
||||
{ "path": "../../data/tsconfig.json" },
|
||||
{ "path": "../../data_views/tsconfig.json" },
|
||||
{ "path": "../../expressions/tsconfig.json" },
|
||||
{ "path": "../../kibana_utils/tsconfig.json" },
|
||||
{ "path": "../../kibana_react/tsconfig.json" },
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
fetchIndexPattern,
|
||||
} from './index_patterns_utils';
|
||||
import { Panel } from './types';
|
||||
import { IndexPattern, IndexPatternsService } from '../../../data/common';
|
||||
import type { DataView, DataViewsService } from '../../../data_views/public';
|
||||
|
||||
describe('isStringTypeIndexPattern', () => {
|
||||
test('should returns true on string-based index', () => {
|
||||
|
@ -54,8 +54,8 @@ describe('extractIndexPatterns', () => {
|
|||
});
|
||||
|
||||
describe('fetchIndexPattern', () => {
|
||||
let mockedIndices: IndexPattern[] | [];
|
||||
let indexPatternsService: IndexPatternsService;
|
||||
let mockedIndices: DataView[] | [];
|
||||
let indexPatternsService: DataViewsService;
|
||||
|
||||
beforeEach(() => {
|
||||
mockedIndices = [];
|
||||
|
@ -64,7 +64,7 @@ describe('fetchIndexPattern', () => {
|
|||
getDefault: jest.fn(() => Promise.resolve({ id: 'default', title: 'index' })),
|
||||
get: jest.fn(() => Promise.resolve(mockedIndices[0])),
|
||||
find: jest.fn(() => Promise.resolve(mockedIndices || [])),
|
||||
} as unknown as IndexPatternsService;
|
||||
} as unknown as DataViewsService;
|
||||
});
|
||||
|
||||
test('should return default index on no input value', async () => {
|
||||
|
@ -87,7 +87,7 @@ describe('fetchIndexPattern', () => {
|
|||
id: 'indexId',
|
||||
title: 'indexTitle',
|
||||
},
|
||||
] as IndexPattern[];
|
||||
] as DataView[];
|
||||
|
||||
const value = await fetchIndexPattern('indexTitle', indexPatternsService, {
|
||||
fetchKibanaIndexForStringIndexes: true,
|
||||
|
@ -125,7 +125,7 @@ describe('fetchIndexPattern', () => {
|
|||
id: 'indexId',
|
||||
title: 'indexTitle',
|
||||
},
|
||||
] as IndexPattern[];
|
||||
] as DataView[];
|
||||
|
||||
const value = await fetchIndexPattern({ id: 'indexId' }, indexPatternsService);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { uniq } from 'lodash';
|
||||
import type { Panel, IndexPatternValue, FetchedIndexPattern } from '../common/types';
|
||||
import { IndexPatternsService } from '../../../data/common';
|
||||
import { DataViewsService } from '../../../data_views/common';
|
||||
|
||||
export const isStringTypeIndexPattern = (
|
||||
indexPatternValue: IndexPatternValue
|
||||
|
@ -45,7 +45,7 @@ export const extractIndexPatternValues = (panel: Panel, defaultIndexId?: string)
|
|||
|
||||
export const fetchIndexPattern = async (
|
||||
indexPatternValue: IndexPatternValue | undefined,
|
||||
indexPatternsService: Pick<IndexPatternsService, 'getDefault' | 'get' | 'find'>,
|
||||
indexPatternsService: Pick<DataViewsService, 'getDefault' | 'get' | 'find'>,
|
||||
options: {
|
||||
fetchKibanaIndexForStringIndexes: boolean;
|
||||
} = {
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
*/
|
||||
|
||||
import { Filter } from '@kbn/es-query';
|
||||
import { IndexPattern, KBN_FIELD_TYPES, Query } from '../../../../data/common';
|
||||
import { KBN_FIELD_TYPES, Query } from '../../../../data/common';
|
||||
import type { DataView } from '../../../../data_views/public';
|
||||
import { Panel } from './panel_model';
|
||||
|
||||
export type { Metric, Series, Panel, MetricType } from './panel_model';
|
||||
|
@ -22,7 +23,7 @@ export type {
|
|||
} from './vis_data';
|
||||
|
||||
export interface FetchedIndexPattern {
|
||||
indexPattern: IndexPattern | undefined | null;
|
||||
indexPattern: DataView | undefined | null;
|
||||
indexPatternString: string | undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"kibanaVersion": "kibana",
|
||||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["charts", "data", "expressions", "visualizations", "inspector"],
|
||||
"requiredPlugins": ["charts", "data", "expressions", "visualizations", "inspector", "dataViews"],
|
||||
"optionalPlugins": ["home","usageCollection"],
|
||||
"requiredBundles": ["kibanaUtils", "kibanaReact", "fieldFormats"],
|
||||
"owner": {
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
|
||||
import { getDataStart } from '../../services';
|
||||
import { getDataViewsStart } from '../../services';
|
||||
import { KBN_FIELD_TYPES, Query } from '../../../../../../plugins/data/public';
|
||||
|
||||
import { AddDeleteButtons } from './add_delete_buttons';
|
||||
|
@ -72,7 +72,7 @@ export const AnnotationRow = ({
|
|||
|
||||
useEffect(() => {
|
||||
const updateFetchedIndex = async (index: IndexPatternValue) => {
|
||||
const { indexPatterns } = getDataStart();
|
||||
const dataViews = getDataViewsStart();
|
||||
let fetchedIndexPattern: IndexPatternSelectProps['fetchedIndex'] = {
|
||||
indexPattern: undefined,
|
||||
indexPatternString: undefined,
|
||||
|
@ -80,12 +80,12 @@ export const AnnotationRow = ({
|
|||
|
||||
try {
|
||||
fetchedIndexPattern = index
|
||||
? await fetchIndexPattern(index, indexPatterns, {
|
||||
? await fetchIndexPattern(index, dataViews, {
|
||||
fetchKibanaIndexForStringIndexes: true,
|
||||
})
|
||||
: {
|
||||
...fetchedIndexPattern,
|
||||
defaultIndex: await indexPatterns.getDefault(),
|
||||
defaultIndex: await dataViews.getDefault(),
|
||||
};
|
||||
} catch {
|
||||
// nothing to be here
|
||||
|
|
|
@ -10,7 +10,7 @@ import React, { useCallback } from 'react';
|
|||
import uuid from 'uuid';
|
||||
import { EuiSpacer, EuiTitle, EuiButton, EuiText } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { IndexPattern } from 'src/plugins/data/public';
|
||||
import type { DataView } from 'src/plugins/data_views/public';
|
||||
|
||||
import { AnnotationRow } from './annotation_row';
|
||||
import { collectionActions, CollectionActionsProps } from './lib/collection_actions';
|
||||
|
@ -22,10 +22,10 @@ interface AnnotationsEditorProps {
|
|||
fields: VisFields;
|
||||
model: Panel;
|
||||
onChange: (partialModel: Partial<Panel>) => void;
|
||||
defaultIndexPattern?: IndexPattern;
|
||||
defaultIndexPattern?: DataView;
|
||||
}
|
||||
|
||||
export const newAnnotation = (defaultIndexPattern?: IndexPattern) => () => ({
|
||||
export const newAnnotation = (defaultIndexPattern?: DataView) => () => ({
|
||||
id: uuid.v1(),
|
||||
color: '#F00',
|
||||
index_pattern:
|
||||
|
|
|
@ -36,7 +36,7 @@ import { isTimerangeModeEnabled } from '../../../common/check_ui_restrictions';
|
|||
import { VisDataContext } from '../contexts/vis_data_context';
|
||||
import { PanelModelContext } from '../contexts/panel_model_context';
|
||||
import { FormValidationContext } from '../contexts/form_validation_context';
|
||||
import { getDataStart, getUISettings } from '../../services';
|
||||
import { getUISettings, getDataViewsStart } from '../../services';
|
||||
import { UI_SETTINGS } from '../../../../../data/common';
|
||||
import { fetchIndexPattern } from '../../../common/index_patterns_utils';
|
||||
|
||||
|
@ -143,7 +143,7 @@ export const IndexPattern = ({
|
|||
|
||||
useEffect(() => {
|
||||
async function fetchIndex() {
|
||||
const { indexPatterns } = getDataStart();
|
||||
const dataViews = getDataViewsStart();
|
||||
let fetchedIndexPattern = {
|
||||
indexPattern: undefined,
|
||||
indexPatternString: undefined,
|
||||
|
@ -153,12 +153,12 @@ export const IndexPattern = ({
|
|||
|
||||
try {
|
||||
fetchedIndexPattern = indexPatternToFetch
|
||||
? await fetchIndexPattern(indexPatternToFetch, indexPatterns, {
|
||||
? await fetchIndexPattern(indexPatternToFetch, dataViews, {
|
||||
fetchKibanaIndexForStringIndexes: true,
|
||||
})
|
||||
: {
|
||||
...fetchedIndexPattern,
|
||||
defaultIndex: await indexPatterns.getDefault(),
|
||||
defaultIndex: await dataViews.getDefault(),
|
||||
};
|
||||
} catch {
|
||||
// nothing to be here
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
import { IndexPattern, IndexPatternField } from 'src/plugins/data/public';
|
||||
import { DataView, DataViewField } from 'src/plugins/data_views/public';
|
||||
import { PanelData } from '../../../../common/types';
|
||||
import { TimeseriesVisParams } from '../../../types';
|
||||
import { convertSeriesToDataTable, addMetaToColumns } from './convert_series_to_datatable';
|
||||
|
@ -14,7 +14,6 @@ jest.mock('../../../services', () => {
|
|||
return {
|
||||
getDataStart: jest.fn(() => {
|
||||
return {
|
||||
indexPatterns: jest.fn(),
|
||||
query: {
|
||||
timefilter: {
|
||||
timefilter: {
|
||||
|
@ -29,29 +28,30 @@ jest.mock('../../../services', () => {
|
|||
},
|
||||
};
|
||||
}),
|
||||
getDataViewsStart: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe('convert series to datatables', () => {
|
||||
let indexPattern: IndexPattern;
|
||||
let indexPattern: DataView;
|
||||
|
||||
beforeEach(() => {
|
||||
const fieldMap: Record<string, IndexPatternField> = {
|
||||
test1: { name: 'test1', spec: { type: 'date', name: 'test1' } } as IndexPatternField,
|
||||
const fieldMap: Record<string, DataViewField> = {
|
||||
test1: { name: 'test1', spec: { type: 'date', name: 'test1' } } as DataViewField,
|
||||
test2: {
|
||||
name: 'test2',
|
||||
spec: { type: 'number', name: 'Average of test2' },
|
||||
} as IndexPatternField,
|
||||
test3: { name: 'test3', spec: { type: 'boolean', name: 'test3' } } as IndexPatternField,
|
||||
} as DataViewField,
|
||||
test3: { name: 'test3', spec: { type: 'boolean', name: 'test3' } } as DataViewField,
|
||||
};
|
||||
|
||||
const getFieldByName = (name: string): IndexPatternField | undefined => fieldMap[name];
|
||||
const getFieldByName = (name: string): DataViewField | undefined => fieldMap[name];
|
||||
indexPattern = {
|
||||
id: 'index1',
|
||||
title: 'index1',
|
||||
timeFieldName: 'timestamp',
|
||||
getFieldByName,
|
||||
} as IndexPattern;
|
||||
} as DataView;
|
||||
});
|
||||
|
||||
describe('addMetaColumns()', () => {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
import { IndexPattern } from 'src/plugins/data/public';
|
||||
import { DataView } from 'src/plugins/data_views/public';
|
||||
import { DatatableRow, DatatableColumn, DatatableColumnType } from 'src/plugins/expressions/public';
|
||||
import { Query } from 'src/plugins/data/common';
|
||||
import { TimeseriesVisParams } from '../../../types';
|
||||
|
@ -13,7 +13,7 @@ import type { PanelData, Metric } from '../../../../common/types';
|
|||
import { getMultiFieldLabel, getFieldsForTerms } from '../../../../common/fields_utils';
|
||||
import { BUCKET_TYPES, TSVB_METRIC_TYPES } from '../../../../common/enums';
|
||||
import { fetchIndexPattern } from '../../../../common/index_patterns_utils';
|
||||
import { getDataStart } from '../../../services';
|
||||
import { getDataStart, getDataViewsStart } from '../../../services';
|
||||
import { X_ACCESSOR_INDEX } from '../../visualizations/constants';
|
||||
import type { TSVBTables } from './types';
|
||||
|
||||
|
@ -33,7 +33,7 @@ interface TSVBColumns {
|
|||
|
||||
export const addMetaToColumns = (
|
||||
columns: TSVBColumns[],
|
||||
indexPattern: IndexPattern
|
||||
indexPattern: DataView
|
||||
): DatatableColumn[] => {
|
||||
return columns.map((column) => {
|
||||
const field = indexPattern.getFieldByName(column.name);
|
||||
|
@ -86,17 +86,17 @@ const hasSeriesAgg = (metrics: Metric[]) => {
|
|||
export const convertSeriesToDataTable = async (
|
||||
model: TimeseriesVisParams,
|
||||
series: PanelData[],
|
||||
initialIndexPattern: IndexPattern
|
||||
initialIndexPattern: DataView
|
||||
) => {
|
||||
const tables: TSVBTables = {};
|
||||
const { indexPatterns } = getDataStart();
|
||||
const dataViews = getDataViewsStart();
|
||||
for (let layerIdx = 0; layerIdx < model.series.length; layerIdx++) {
|
||||
const layer = model.series[layerIdx];
|
||||
let usedIndexPattern = initialIndexPattern;
|
||||
// The user can overwrite the index pattern of a layer.
|
||||
// In that case, the index pattern should be fetched again.
|
||||
if (layer.override_index_pattern) {
|
||||
const { indexPattern } = await fetchIndexPattern(layer.series_index_pattern, indexPatterns);
|
||||
const { indexPattern } = await fetchIndexPattern(layer.series_index_pattern, dataViews);
|
||||
if (indexPattern) {
|
||||
usedIndexPattern = indexPattern;
|
||||
}
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
|
||||
import React, { useCallback, useState, useEffect } from 'react';
|
||||
import { EuiComboBox, EuiComboBoxProps } from '@elastic/eui';
|
||||
import { getDataStart } from '../../../../services';
|
||||
import { getDataViewsStart } from '../../../../services';
|
||||
|
||||
import { SwitchModePopover } from './switch_mode_popover';
|
||||
|
||||
import type { SelectIndexComponentProps } from './types';
|
||||
import type { IndexPatternValue } from '../../../../../common/types';
|
||||
import type { IndexPatternsService } from '../../../../../../../data/public';
|
||||
import type { DataViewsService } from '../../../../../../../data_views/public';
|
||||
|
||||
/** @internal **/
|
||||
type IdsWithTitle = Awaited<ReturnType<IndexPatternsService['getIdsWithTitle']>>;
|
||||
type IdsWithTitle = Awaited<ReturnType<DataViewsService['getIdsWithTitle']>>;
|
||||
|
||||
/** @internal **/
|
||||
type SelectedOptions = EuiComboBoxProps<string>['selectedOptions'];
|
||||
|
@ -65,7 +65,7 @@ export const ComboBoxSelect = ({
|
|||
|
||||
useEffect(() => {
|
||||
async function fetchIndexes() {
|
||||
setAvailableIndexes(await getDataStart().indexPatterns.getIdsWithTitle());
|
||||
setAvailableIndexes(await getDataViewsStart().getIdsWithTitle());
|
||||
}
|
||||
|
||||
fetchIndexes();
|
||||
|
|
|
@ -19,7 +19,7 @@ import { ComboBoxSelect } from './combo_box_select';
|
|||
|
||||
import type { IndexPatternValue, FetchedIndexPattern } from '../../../../../common/types';
|
||||
import { USE_KIBANA_INDEXES_KEY } from '../../../../../common/constants';
|
||||
import { IndexPattern } from '../../../../../../../data/common';
|
||||
import type { DataView } from '../../../../../../../data_views/public';
|
||||
|
||||
export interface IndexPatternSelectProps {
|
||||
indexPatternName: string;
|
||||
|
@ -28,7 +28,7 @@ export interface IndexPatternSelectProps {
|
|||
allowIndexSwitchingMode?: boolean;
|
||||
fetchedIndex:
|
||||
| (FetchedIndexPattern & {
|
||||
defaultIndex?: IndexPattern | null;
|
||||
defaultIndex?: DataView | null;
|
||||
})
|
||||
| null;
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
*/
|
||||
import type { Assign } from '@kbn/utility-types';
|
||||
import type { FetchedIndexPattern, IndexPatternValue } from '../../../../../common/types';
|
||||
import type { IndexPattern } from '../../../../../../../data/common';
|
||||
import type { DataView } from '../../../../../../../data_views/public';
|
||||
|
||||
/** @internal **/
|
||||
export interface SelectIndexComponentProps {
|
||||
fetchedIndex: FetchedIndexPattern & {
|
||||
defaultIndex?: IndexPattern | null;
|
||||
defaultIndex?: DataView | null;
|
||||
};
|
||||
onIndexChange: (value: IndexPatternValue) => void;
|
||||
onModeChange: (useKibanaIndexes: boolean, index?: FetchedIndexPattern) => void;
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CodeEditor, MarkdownLang } from '../../../../../kibana_react/public';
|
|||
import { EuiText, EuiCodeBlock, EuiSpacer, EuiTitle } from '@elastic/eui';
|
||||
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { getDataStart } from '../../services';
|
||||
import { getDataViewsStart } from '../../services';
|
||||
import { fetchIndexPattern } from '../../../common/index_patterns_utils';
|
||||
|
||||
export class MarkdownEditor extends Component {
|
||||
|
@ -46,8 +46,8 @@ export class MarkdownEditor extends Component {
|
|||
};
|
||||
|
||||
async componentDidMount() {
|
||||
const { indexPatterns } = getDataStart();
|
||||
const { indexPattern } = await fetchIndexPattern(this.props.model.index_pattern, indexPatterns);
|
||||
const dataViews = getDataViewsStart();
|
||||
const { indexPattern } = await fetchIndexPattern(this.props.model.index_pattern, dataViews);
|
||||
this.setState({ fieldFormatMap: indexPattern?.fieldFormatMap });
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { Observable } from 'rxjs';
|
||||
import { IUiSettingsClient } from 'kibana/public';
|
||||
import type { IndexPattern } from 'src/plugins/data/public';
|
||||
import type { DataView } from 'src/plugins/data_views/public';
|
||||
import type { TimeseriesVisData } from '../../../../common/types';
|
||||
import { TimeseriesVisParams } from '../../../types';
|
||||
import { VisFields } from '../../lib/fetch_fields';
|
||||
|
@ -19,7 +19,7 @@ export interface PanelConfigProps {
|
|||
visData$: Observable<TimeseriesVisData | undefined>;
|
||||
getConfig: IUiSettingsClient['get'];
|
||||
onChange: (partialModel: Partial<TimeseriesVisParams>) => void;
|
||||
defaultIndexPattern?: IndexPattern;
|
||||
defaultIndexPattern?: DataView;
|
||||
}
|
||||
|
||||
export enum PANEL_CONFIG_TABS {
|
||||
|
|
|
@ -12,7 +12,7 @@ import { CoreStartContext } from '../contexts/query_input_bar_context';
|
|||
import type { IndexPatternValue } from '../../../common/types';
|
||||
|
||||
import { QueryStringInput, QueryStringInputProps } from '../../../../../../plugins/data/public';
|
||||
import { getDataStart } from '../../services';
|
||||
import { getDataViewsStart } from '../../services';
|
||||
import { fetchIndexPattern, isStringTypeIndexPattern } from '../../../common/index_patterns_utils';
|
||||
|
||||
type QueryBarWrapperProps = Pick<QueryStringInputProps, 'query' | 'onChange' | 'isInvalid'> & {
|
||||
|
@ -27,7 +27,7 @@ export function QueryBarWrapper({
|
|||
indexPatterns,
|
||||
'data-test-subj': dataTestSubj,
|
||||
}: QueryBarWrapperProps) {
|
||||
const { indexPatterns: indexPatternsService } = getDataStart();
|
||||
const dataViews = getDataViewsStart();
|
||||
const [indexes, setIndexes] = useState<QueryStringInputProps['indexPatterns']>([]);
|
||||
|
||||
const coreStartContext = useContext(CoreStartContext);
|
||||
|
@ -41,14 +41,14 @@ export function QueryBarWrapper({
|
|||
if (isStringTypeIndexPattern(index)) {
|
||||
i.push(index);
|
||||
} else if (index?.id) {
|
||||
const { indexPattern } = await fetchIndexPattern(index, indexPatternsService);
|
||||
const { indexPattern } = await fetchIndexPattern(index, dataViews);
|
||||
|
||||
if (indexPattern) {
|
||||
i.push(indexPattern);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const defaultIndex = await indexPatternsService.getDefault();
|
||||
const defaultIndex = await dataViews.getDefault();
|
||||
|
||||
if (defaultIndex) {
|
||||
i.push(defaultIndex);
|
||||
|
@ -59,7 +59,7 @@ export function QueryBarWrapper({
|
|||
}
|
||||
|
||||
fetchIndexes();
|
||||
}, [indexPatterns, indexPatternsService]);
|
||||
}, [indexPatterns, dataViews]);
|
||||
|
||||
return (
|
||||
<QueryStringInput
|
||||
|
|
|
@ -29,7 +29,7 @@ import { getInterval } from './lib/get_interval';
|
|||
import { AUTO_INTERVAL } from '../../../common/constants';
|
||||
import { TIME_RANGE_DATA_MODES, PANEL_TYPES } from '../../../common/enums';
|
||||
import { fetchIndexPattern } from '../../../common/index_patterns_utils';
|
||||
import { getCharts, getDataStart } from '../../services';
|
||||
import { getCharts, getDataViewsStart } from '../../services';
|
||||
|
||||
interface TimeseriesVisualizationProps {
|
||||
getConfig: IUiSettingsClient['get'];
|
||||
|
@ -58,8 +58,8 @@ function TimeseriesVisualization({
|
|||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
fetchIndexPattern(model.index_pattern, getDataStart().indexPatterns).then(
|
||||
(fetchedIndexPattern) => setIndexPattern(fetchedIndexPattern.indexPattern)
|
||||
fetchIndexPattern(model.index_pattern, getDataViewsStart()).then((fetchedIndexPattern) =>
|
||||
setIndexPattern(fetchedIndexPattern.indexPattern)
|
||||
);
|
||||
}, [model.index_pattern]);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { share } from 'rxjs/operators';
|
|||
import { isEqual, isEmpty, debounce } from 'lodash';
|
||||
import { EventEmitter } from 'events';
|
||||
import type { IUiSettingsClient } from 'kibana/public';
|
||||
import type { IndexPattern } from 'src/plugins/data/public';
|
||||
import type { DataView } from 'src/plugins/data_views/public';
|
||||
import type {
|
||||
Vis,
|
||||
VisualizeEmbeddableContract,
|
||||
|
@ -47,7 +47,7 @@ export interface TimeseriesEditorProps {
|
|||
query: EditorRenderProps['query'];
|
||||
uiState: EditorRenderProps['uiState'];
|
||||
vis: Vis<TimeseriesVisParams>;
|
||||
defaultIndexPattern?: IndexPattern;
|
||||
defaultIndexPattern?: DataView;
|
||||
}
|
||||
|
||||
interface TimeseriesEditorState {
|
||||
|
|
|
@ -15,7 +15,7 @@ import type {
|
|||
IEditorController,
|
||||
EditorRenderProps,
|
||||
} from 'src/plugins/visualizations/public';
|
||||
import { getUISettings, getI18n, getCoreStart, getDataStart } from '../services';
|
||||
import { getUISettings, getI18n, getCoreStart, getDataViewsStart } from '../services';
|
||||
import { VisEditor } from './components/vis_editor_lazy';
|
||||
import type { TimeseriesVisParams } from '../types';
|
||||
import { KibanaThemeProvider } from '../../../../../../src/plugins/kibana_react/public';
|
||||
|
@ -32,7 +32,7 @@ export class EditorController implements IEditorController {
|
|||
|
||||
async render({ timeRange, uiState, filters, query }: EditorRenderProps) {
|
||||
const I18nContext = getI18n().Context;
|
||||
const defaultIndexPattern = (await getDataStart().dataViews.getDefault()) || undefined;
|
||||
const defaultIndexPattern = (await getDataViewsStart().getDefault()) || undefined;
|
||||
|
||||
render(
|
||||
<I18nContext>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { getCoreStart, getDataStart } from '../../services';
|
||||
import { getCoreStart, getDataViewsStart } from '../../services';
|
||||
import { ROUTES } from '../../../common/constants';
|
||||
import type { SanitizedFieldType, IndexPatternValue } from '../../../common/types';
|
||||
import { getIndexPatternKey } from '../../../common/index_patterns_utils';
|
||||
|
@ -21,7 +21,6 @@ export async function fetchFields(
|
|||
): Promise<VisFields> {
|
||||
const patterns = Array.isArray(indexes) ? indexes : [indexes];
|
||||
const coreStart = getCoreStart();
|
||||
const dataStart = getDataStart();
|
||||
const defaultIndex = coreStart.uiSettings.get('defaultIndex');
|
||||
|
||||
try {
|
||||
|
@ -29,7 +28,7 @@ export async function fetchFields(
|
|||
patterns.map(async (pattern) => {
|
||||
if (typeof pattern !== 'string' && pattern?.id) {
|
||||
return toSanitizedFieldType(
|
||||
(await dataStart.indexPatterns.get(pattern.id)).getNonScriptedFields()
|
||||
(await getDataViewsStart().get(pattern.id)).getNonScriptedFields()
|
||||
);
|
||||
} else {
|
||||
return coreStart.http.get(ROUTES.FIELDS, {
|
||||
|
|
|
@ -7,36 +7,34 @@
|
|||
*/
|
||||
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { DataViewsContract, IndexPattern } from 'src/plugins/data_views/public';
|
||||
import { setDataStart } from './services';
|
||||
import { DataView } from 'src/plugins/data_views/public';
|
||||
import { setDataViewsStart } from './services';
|
||||
import type { TimeseriesVisParams } from './types';
|
||||
import type { Vis } from 'src/plugins/visualizations/public';
|
||||
import { metricsVisDefinition } from './metrics_type';
|
||||
import { DataPublicPluginStart } from 'src/plugins/data/public';
|
||||
import { DataViewsPublicPluginStart } from 'src/plugins/data_views/public';
|
||||
describe('metricsVisDefinition', () => {
|
||||
describe('getUsedIndexPattern', () => {
|
||||
const indexPattern1 = { id: '1', title: 'pattern1' } as unknown as IndexPattern;
|
||||
const indexPattern2 = { id: '2', title: 'pattern2' } as unknown as IndexPattern;
|
||||
const indexPattern1 = { id: '1', title: 'pattern1' } as unknown as DataView;
|
||||
const indexPattern2 = { id: '2', title: 'pattern2' } as unknown as DataView;
|
||||
let defaultParams: TimeseriesVisParams;
|
||||
|
||||
beforeEach(async () => {
|
||||
setDataStart({
|
||||
indexPatterns: {
|
||||
async getDefault() {
|
||||
return indexPattern1;
|
||||
},
|
||||
async find(title: string) {
|
||||
if (title === 'pattern1') return [indexPattern1];
|
||||
if (title === 'pattern2') return [indexPattern2];
|
||||
return [];
|
||||
},
|
||||
async get(id: string) {
|
||||
if (id === '1') return indexPattern1;
|
||||
if (id === '2') return indexPattern2;
|
||||
throw new Error();
|
||||
},
|
||||
} as unknown as DataViewsContract,
|
||||
} as DataPublicPluginStart);
|
||||
setDataViewsStart({
|
||||
async getDefault() {
|
||||
return indexPattern1;
|
||||
},
|
||||
async find(title: string) {
|
||||
if (title === 'pattern1') return [indexPattern1];
|
||||
if (title === 'pattern2') return [indexPattern2];
|
||||
return [];
|
||||
},
|
||||
async get(id: string) {
|
||||
if (id === '1') return indexPattern1;
|
||||
if (id === '2') return indexPattern2;
|
||||
throw new Error();
|
||||
},
|
||||
} as DataViewsPublicPluginStart);
|
||||
defaultParams = (
|
||||
await metricsVisDefinition.setup!({
|
||||
params: cloneDeep(metricsVisDefinition.visConfig.defaults),
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uuid from 'uuid/v4';
|
||||
import { DataViewsContract, IndexPattern } from 'src/plugins/data_views/public';
|
||||
import type { DataViewsContract, DataView } from 'src/plugins/data_views/public';
|
||||
import { TSVB_EDITOR_NAME } from './application/editor_controller';
|
||||
import { PANEL_TYPES, TOOLTIP_MODES } from '../common/enums';
|
||||
import {
|
||||
|
@ -24,7 +24,7 @@ import {
|
|||
VisParams,
|
||||
VisTypeDefinition,
|
||||
} from '../../../visualizations/public';
|
||||
import { getDataStart } from './services';
|
||||
import { getDataViewsStart } from './services';
|
||||
import type { TimeseriesVisDefaultParams, TimeseriesVisParams } from './types';
|
||||
import type { IndexPatternValue, Panel } from '../common/types';
|
||||
import { RequestAdapter } from '../../../inspector/public';
|
||||
|
@ -55,9 +55,9 @@ export const withReplacedIds = (
|
|||
async function withDefaultIndexPattern(
|
||||
vis: Vis<TimeseriesVisParams | TimeseriesVisDefaultParams>
|
||||
): Promise<Vis<TimeseriesVisParams>> {
|
||||
const { indexPatterns } = getDataStart();
|
||||
const dataViews = getDataViewsStart();
|
||||
|
||||
const defaultIndex = await indexPatterns.getDefault();
|
||||
const defaultIndex = await dataViews.getDefault();
|
||||
if (!defaultIndex || !defaultIndex.id || vis.params.index_pattern) return vis;
|
||||
vis.params.index_pattern = {
|
||||
id: defaultIndex.id,
|
||||
|
@ -79,16 +79,16 @@ async function resolveIndexPattern(
|
|||
}
|
||||
}
|
||||
|
||||
async function getUsedIndexPatterns(params: VisParams): Promise<IndexPattern[]> {
|
||||
const { indexPatterns } = getDataStart();
|
||||
async function getUsedIndexPatterns(params: VisParams): Promise<DataView[]> {
|
||||
const dataViews = getDataViewsStart();
|
||||
|
||||
const defaultIndex = await indexPatterns.getDefault();
|
||||
const resolvedIndexPatterns: IndexPattern[] = [];
|
||||
const defaultIndex = await dataViews.getDefault();
|
||||
const resolvedIndexPatterns: DataView[] = [];
|
||||
const indexPatternValues = extractIndexPatternValues(params as Panel, defaultIndex?.id);
|
||||
(
|
||||
await Promise.all(
|
||||
indexPatternValues.map((indexPatternValue) =>
|
||||
resolveIndexPattern(indexPatternValue, indexPatterns)
|
||||
resolveIndexPattern(indexPatternValue, dataViews)
|
||||
)
|
||||
)
|
||||
).forEach((patterns) => patterns && resolvedIndexPatterns.push(...patterns));
|
||||
|
|
|
@ -19,9 +19,11 @@ import {
|
|||
setFieldFormats,
|
||||
setCoreStart,
|
||||
setDataStart,
|
||||
setDataViewsStart,
|
||||
setCharts,
|
||||
} from './services';
|
||||
import { DataPublicPluginStart } from '../../../data/public';
|
||||
import { DataViewsPublicPluginStart } from '../../../data_views/public';
|
||||
import { ChartsPluginStart } from '../../../charts/public';
|
||||
import { getTimeseriesVisRenderer } from './timeseries_vis_renderer';
|
||||
|
||||
|
@ -34,6 +36,7 @@ export interface MetricsPluginSetupDependencies {
|
|||
/** @internal */
|
||||
export interface MetricsPluginStartDependencies {
|
||||
data: DataPublicPluginStart;
|
||||
dataViews: DataViewsPublicPluginStart;
|
||||
charts: ChartsPluginStart;
|
||||
}
|
||||
|
||||
|
@ -58,11 +61,12 @@ export class MetricsPlugin implements Plugin<void, void> {
|
|||
visualizations.createBaseVisualization(metricsVisDefinition);
|
||||
}
|
||||
|
||||
public start(core: CoreStart, { data, charts }: MetricsPluginStartDependencies) {
|
||||
public start(core: CoreStart, { data, charts, dataViews }: MetricsPluginStartDependencies) {
|
||||
setCharts(charts);
|
||||
setI18n(core.i18n);
|
||||
setFieldFormats(data.fieldFormats);
|
||||
setDataStart(data);
|
||||
setDataViewsStart(dataViews);
|
||||
setCoreStart(core);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import { I18nStart, IUiSettingsClient, CoreStart } from 'src/core/public';
|
|||
import { createGetterSetter } from '../../../kibana_utils/public';
|
||||
import { ChartsPluginStart } from '../../../charts/public';
|
||||
import { DataPublicPluginStart } from '../../../data/public';
|
||||
import { DataViewsPublicPluginStart } from '../../../data_views/public';
|
||||
|
||||
export const [getUISettings, setUISettings] = createGetterSetter<IUiSettingsClient>('UISettings');
|
||||
|
||||
|
@ -20,6 +21,9 @@ export const [getCoreStart, setCoreStart] = createGetterSetter<CoreStart>('CoreS
|
|||
|
||||
export const [getDataStart, setDataStart] = createGetterSetter<DataPublicPluginStart>('DataStart');
|
||||
|
||||
export const [getDataViewsStart, setDataViewsStart] =
|
||||
createGetterSetter<DataViewsPublicPluginStart>('dataViews');
|
||||
|
||||
export const [getI18n, setI18n] = createGetterSetter<I18nStart>('I18n');
|
||||
|
||||
export const [getCharts, setCharts] = createGetterSetter<ChartsPluginStart>('ChartsPluginStart');
|
||||
|
|
|
@ -20,14 +20,12 @@ const dataViewsMap: Record<string, DataView> = {
|
|||
const getDataview = (id: string): DataView | undefined => dataViewsMap[id];
|
||||
jest.mock('../services', () => {
|
||||
return {
|
||||
getDataStart: jest.fn(() => {
|
||||
getDataViewsStart: jest.fn(() => {
|
||||
return {
|
||||
dataViews: {
|
||||
getDefault: jest.fn(() => {
|
||||
return { id: '12345', title: 'default', timeFieldName: '@timestamp' };
|
||||
}),
|
||||
get: getDataview,
|
||||
},
|
||||
getDefault: jest.fn(() => {
|
||||
return { id: '12345', title: 'default', timeFieldName: '@timestamp' };
|
||||
}),
|
||||
get: getDataview,
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
import { fetchIndexPattern, isStringTypeIndexPattern } from '../../common/index_patterns_utils';
|
||||
import type { IndexPatternValue } from '../../common/types';
|
||||
import { getDataStart } from '../services';
|
||||
import { getDataViewsStart } from '../services';
|
||||
|
||||
export const getDataSourceInfo = async (
|
||||
modelIndexPattern: IndexPatternValue,
|
||||
|
@ -15,7 +15,7 @@ export const getDataSourceInfo = async (
|
|||
isOverwritten: boolean,
|
||||
overwrittenIndexPattern: IndexPatternValue | undefined
|
||||
) => {
|
||||
const { dataViews } = getDataStart();
|
||||
const dataViews = getDataViewsStart();
|
||||
let indexPatternId =
|
||||
modelIndexPattern && !isStringTypeIndexPattern(modelIndexPattern) ? modelIndexPattern.id : '';
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
import { getDataStart } from '../services';
|
||||
import { getDataViewsStart } from '../services';
|
||||
|
||||
export const getFieldType = async (indexPatternId: string, fieldName: string) => {
|
||||
const { dataViews } = getDataStart();
|
||||
const dataViews = getDataViewsStart();
|
||||
const dataView = await dataViews.get(indexPatternId);
|
||||
const field = await dataView.getFieldByName(fieldName);
|
||||
return field?.type;
|
||||
|
|
|
@ -22,14 +22,12 @@ const dataViewsMap: Record<string, DataView> = {
|
|||
const getDataview = (id: string): DataView | undefined => dataViewsMap[id];
|
||||
jest.mock('../services', () => {
|
||||
return {
|
||||
getDataStart: jest.fn(() => {
|
||||
getDataViewsStart: jest.fn(() => {
|
||||
return {
|
||||
dataViews: {
|
||||
getDefault: jest.fn(() => {
|
||||
return { id: '12345', title: 'default', timeFieldName: '@timestamp' };
|
||||
}),
|
||||
get: getDataview,
|
||||
},
|
||||
getDefault: jest.fn(() => {
|
||||
return { id: '12345', title: 'default', timeFieldName: '@timestamp' };
|
||||
}),
|
||||
get: getDataview,
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPattern, IndexPatternsService } from 'src/plugins/data/server';
|
||||
import { DataView, DataViewsService } from 'src/plugins/data_views/common';
|
||||
import { fetchIndexPattern } from '../../../../common/index_patterns_utils';
|
||||
import {
|
||||
getCachedIndexPatternFetcher,
|
||||
|
@ -16,7 +16,7 @@ import {
|
|||
jest.mock('../../../../common/index_patterns_utils');
|
||||
|
||||
describe('CachedIndexPatternFetcher', () => {
|
||||
let mockedIndices: IndexPattern[] | [];
|
||||
let mockedIndices: DataView[] | [];
|
||||
let cachedIndexPatternFetcher: CachedIndexPatternFetcher;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -26,7 +26,7 @@ describe('CachedIndexPatternFetcher', () => {
|
|||
getDefault: jest.fn(() => Promise.resolve({ id: 'default', title: 'index' })),
|
||||
get: jest.fn(() => Promise.resolve(mockedIndices[0])),
|
||||
find: jest.fn(() => Promise.resolve(mockedIndices || [])),
|
||||
} as unknown as IndexPatternsService;
|
||||
} as unknown as DataViewsService;
|
||||
|
||||
(fetchIndexPattern as jest.Mock).mockClear();
|
||||
|
||||
|
@ -74,7 +74,7 @@ describe('CachedIndexPatternFetcher', () => {
|
|||
id: 'indexId',
|
||||
title: 'indexTitle',
|
||||
},
|
||||
] as IndexPattern[];
|
||||
] as DataView[];
|
||||
|
||||
const value = await cachedIndexPatternFetcher({ id: 'indexId' });
|
||||
|
||||
|
@ -106,7 +106,7 @@ describe('CachedIndexPatternFetcher', () => {
|
|||
id: 'indexId',
|
||||
title: 'indexTitle',
|
||||
},
|
||||
] as IndexPattern[];
|
||||
] as DataView[];
|
||||
|
||||
await cachedIndexPatternFetcher({ id: 'indexId' });
|
||||
await cachedIndexPatternFetcher({ id: 'indexId' });
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
import { getIndexPatternKey, fetchIndexPattern } from '../../../../common/index_patterns_utils';
|
||||
|
||||
import type { IndexPatternsService } from '../../../../../../data/server';
|
||||
import type { DataViewsService } from '../../../../../../data_views/common';
|
||||
import type { IndexPatternValue, FetchedIndexPattern } from '../../../../common/types';
|
||||
|
||||
export const getCachedIndexPatternFetcher = (
|
||||
indexPatternsService: IndexPatternsService,
|
||||
indexPatternsService: DataViewsService,
|
||||
globalOptions: {
|
||||
fetchKibanaIndexForStringIndexes: boolean;
|
||||
} = {
|
||||
|
|
|
@ -10,12 +10,12 @@ import { getIndexPatternKey } from '../../../../common/index_patterns_utils';
|
|||
|
||||
import type { VisTypeTimeseriesVisDataRequest } from '../../../types';
|
||||
import type { SearchStrategy, SearchCapabilities } from '../index';
|
||||
import type { IndexPatternsService } from '../../../../../../data/common';
|
||||
import type { DataViewsService } from '../../../../../../data_views/common';
|
||||
import type { CachedIndexPatternFetcher } from './cached_index_pattern_fetcher';
|
||||
import type { IndexPatternValue } from '../../../../common/types';
|
||||
|
||||
export interface FieldsFetcherServices {
|
||||
indexPatternsService: IndexPatternsService;
|
||||
indexPatternsService: DataViewsService;
|
||||
cachedIndexPatternFetcher: CachedIndexPatternFetcher;
|
||||
searchStrategy: SearchStrategy;
|
||||
capabilities: SearchCapabilities;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IndexPatternsService } from '../../../../../../data/common';
|
||||
import { DataViewsService } from '../../../../../../data_views/common';
|
||||
import { from } from 'rxjs';
|
||||
|
||||
import { AbstractSearchStrategy, EsSearchRequest } from './abstract_search_strategy';
|
||||
|
@ -56,7 +56,7 @@ describe('AbstractSearchStrategy', () => {
|
|||
{
|
||||
getDefault: jest.fn(),
|
||||
getFieldsForWildcard: jest.fn(() => Promise.resolve(mockedFields)),
|
||||
} as unknown as IndexPatternsService,
|
||||
} as unknown as DataViewsService,
|
||||
(() => Promise.resolve({}) as unknown) as CachedIndexPatternFetcher
|
||||
);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { tap } from 'rxjs/operators';
|
||||
import { omit } from 'lodash';
|
||||
import type { Observable } from 'rxjs';
|
||||
import { IndexPatternsService } from '../../../../../../data/server';
|
||||
import { DataViewsService } from '../../../../../../data_views/common';
|
||||
import { toSanitizedFieldType } from '../../../../common/fields_utils';
|
||||
|
||||
import type { FetchedIndexPattern, TrackedEsSearches } from '../../../../common/types';
|
||||
|
@ -90,7 +90,7 @@ export abstract class AbstractSearchStrategy {
|
|||
|
||||
async getFieldsForWildcard(
|
||||
fetchedIndexPattern: FetchedIndexPattern,
|
||||
indexPatternsService: IndexPatternsService,
|
||||
indexPatternsService: DataViewsService,
|
||||
capabilities?: unknown,
|
||||
options?: Partial<{
|
||||
type: string;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import { AbstractSearchStrategy } from './abstract_search_strategy';
|
||||
import { DefaultSearchCapabilities } from '../capabilities/default_search_capabilities';
|
||||
|
||||
import type { IndexPatternsService } from '../../../../../../data/server';
|
||||
import type { DataViewsService } from '../../../../../../data_views/common';
|
||||
import type { FetchedIndexPattern } from '../../../../common/types';
|
||||
import type {
|
||||
VisTypeTimeseriesRequestHandlerContext,
|
||||
|
@ -36,7 +36,7 @@ export class DefaultSearchStrategy extends AbstractSearchStrategy {
|
|||
|
||||
async getFieldsForWildcard(
|
||||
fetchedIndexPattern: FetchedIndexPattern,
|
||||
indexPatternsService: IndexPatternsService,
|
||||
indexPatternsService: DataViewsService,
|
||||
capabilities?: unknown
|
||||
) {
|
||||
return super.getFieldsForWildcard(fetchedIndexPattern, indexPatternsService, capabilities);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { RollupSearchStrategy } from './rollup_search_strategy';
|
||||
|
||||
import type { IndexPatternsService } from '../../../../../../data/common';
|
||||
import type { DataViewsService } from '../../../../../../data_views/common';
|
||||
import type { CachedIndexPatternFetcher } from '../lib/cached_index_pattern_fetcher';
|
||||
import type {
|
||||
VisTypeTimeseriesRequestHandlerContext,
|
||||
|
@ -156,7 +156,7 @@ describe('Rollup Search Strategy', () => {
|
|||
test('should return fields for wildcard', async () => {
|
||||
const fields = await rollupSearchStrategy.getFieldsForWildcard(
|
||||
{ indexPatternString: 'indexPattern', indexPattern: undefined },
|
||||
{} as IndexPatternsService,
|
||||
{} as DataViewsService,
|
||||
(() => Promise.resolve({}) as unknown) as CachedIndexPatternFetcher,
|
||||
{
|
||||
fieldsCapabilities,
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import {
|
||||
getCapabilitiesForRollupIndices,
|
||||
IndexPatternsService,
|
||||
} from '../../../../../../data/server';
|
||||
import { getCapabilitiesForRollupIndices } from '../../../../../../data/server';
|
||||
import type { DataViewsService } from '../../../../../../data_views/common';
|
||||
import { AbstractSearchStrategy, EsSearchRequest } from './abstract_search_strategy';
|
||||
import { RollupSearchCapabilities } from '../capabilities/rollup_search_capabilities';
|
||||
|
||||
|
@ -93,7 +91,7 @@ export class RollupSearchStrategy extends AbstractSearchStrategy {
|
|||
|
||||
async getFieldsForWildcard(
|
||||
fetchedIndexPattern: FetchedIndexPattern,
|
||||
indexPatternsService: IndexPatternsService,
|
||||
indexPatternsService: DataViewsService,
|
||||
getCachedIndexPatternFetcher: CachedIndexPatternFetcher,
|
||||
capabilities?: unknown
|
||||
) {
|
||||
|
|
|
@ -23,7 +23,8 @@ import { getVisData } from './lib/get_vis_data';
|
|||
import { UsageCollectionSetup } from '../../../usage_collection/server';
|
||||
import { HomeServerPluginSetup } from '../../../home/server';
|
||||
import { PluginStart } from '../../../data/server';
|
||||
import { IndexPatternsService } from '../../../data/common';
|
||||
import type { DataViewsService } from '../../../data_views/common';
|
||||
import type { PluginStart as DataViewsPublicPluginStart } from '../../../data_views/server';
|
||||
import { visDataRoutes } from './routes/vis';
|
||||
import { fieldsRoutes } from './routes/fields';
|
||||
import { getUiSettings } from './ui_settings';
|
||||
|
@ -53,6 +54,7 @@ interface VisTypeTimeseriesPluginSetupDependencies {
|
|||
|
||||
interface VisTypeTimeseriesPluginStartDependencies {
|
||||
data: PluginStart;
|
||||
dataViews: DataViewsPublicPluginStart;
|
||||
}
|
||||
|
||||
export interface VisTypeTimeseriesSetup {
|
||||
|
@ -73,7 +75,7 @@ export interface Framework {
|
|||
searchStrategyRegistry: SearchStrategyRegistry;
|
||||
getIndexPatternsService: (
|
||||
requestContext: VisTypeTimeseriesRequestHandlerContext
|
||||
) => Promise<IndexPatternsService>;
|
||||
) => Promise<DataViewsService>;
|
||||
getFieldFormatsService: (uiSettings: IUiSettingsClient) => Promise<FieldFormatsRegistry>;
|
||||
getEsShardTimeout: () => Promise<number>;
|
||||
}
|
||||
|
@ -109,9 +111,9 @@ export class VisTypeTimeseriesPlugin implements Plugin<VisTypeTimeseriesSetup> {
|
|||
)
|
||||
.toPromise(),
|
||||
getIndexPatternsService: async (requestContext) => {
|
||||
const [, { data }] = await core.getStartServices();
|
||||
const [, { dataViews }] = await core.getStartServices();
|
||||
|
||||
return await data.indexPatterns.indexPatternsServiceFactory(
|
||||
return await dataViews.dataViewsServiceFactory(
|
||||
requestContext.core.savedObjects.client,
|
||||
requestContext.core.elasticsearch.client.asCurrentUser
|
||||
);
|
||||
|
|
|
@ -10,7 +10,8 @@ import { Observable } from 'rxjs';
|
|||
import { EsQueryConfig } from '@kbn/es-query';
|
||||
import { SharedGlobalConfig } from 'kibana/server';
|
||||
import type { IRouter, IUiSettingsClient, KibanaRequest } from 'src/core/server';
|
||||
import type { DataRequestHandlerContext, IndexPatternsService } from '../../../data/server';
|
||||
import type { DataViewsService } from '../../../data_views/common';
|
||||
import type { DataRequestHandlerContext } from '../../../data/server';
|
||||
import type { FieldFormatsRegistry } from '../../../field_formats/common';
|
||||
import type { Series, VisPayload } from '../common/types';
|
||||
import type { SearchStrategyRegistry } from './lib/search_strategies';
|
||||
|
@ -31,7 +32,7 @@ export interface VisTypeTimeseriesRequestServices {
|
|||
esShardTimeout: number;
|
||||
esQueryConfig: EsQueryConfig;
|
||||
uiSettings: IUiSettingsClient;
|
||||
indexPatternsService: IndexPatternsService;
|
||||
indexPatternsService: DataViewsService;
|
||||
searchStrategyRegistry: SearchStrategyRegistry;
|
||||
cachedIndexPatternFetcher: CachedIndexPatternFetcher;
|
||||
fieldFormatService: FieldFormatsRegistry;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
{ "path": "../../../core/tsconfig.json" },
|
||||
{ "path": "../../charts/tsconfig.json" },
|
||||
{ "path": "../../data/tsconfig.json" },
|
||||
{ "path": "../../data_views/tsconfig.json" },
|
||||
{ "path": "../../expressions/tsconfig.json" },
|
||||
{ "path": "../../visualizations/tsconfig.json" },
|
||||
{ "path": "../../dashboard/tsconfig.json" },
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"version": "kibana",
|
||||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["data", "visualizations", "mapsEms", "expressions", "inspector"],
|
||||
"requiredPlugins": ["data", "visualizations", "mapsEms", "expressions", "inspector", "dataViews"],
|
||||
"optionalPlugins": ["home","usageCollection"],
|
||||
"requiredBundles": ["kibanaUtils", "kibanaReact", "visDefaultEditor"],
|
||||
"owner": {
|
||||
|
|
|
@ -7,16 +7,17 @@
|
|||
*/
|
||||
|
||||
import { extendSearchParamsWithRuntimeFields } from './search_api';
|
||||
import { dataPluginMock } from '../../../../data/public/mocks';
|
||||
import { dataViewPluginMocks } from '../../../../data_views/public/mocks';
|
||||
|
||||
import { getSearchParamsFromRequest, DataPublicPluginStart } from '../../../../data/public';
|
||||
import { getSearchParamsFromRequest } from '../../../../data/public';
|
||||
import type { DataViewsPublicPluginStart } from '../../../../data_views/public';
|
||||
|
||||
const mockComputedFields = (
|
||||
dataStart: DataPublicPluginStart,
|
||||
dataViewsStart: DataViewsPublicPluginStart,
|
||||
index: string,
|
||||
runtimeFields: Record<string, unknown>
|
||||
) => {
|
||||
dataStart.indexPatterns.find = jest.fn().mockReturnValue([
|
||||
dataViewsStart.find = jest.fn().mockReturnValue([
|
||||
{
|
||||
title: index,
|
||||
getComputedFields: () => ({
|
||||
|
@ -28,21 +29,20 @@ const mockComputedFields = (
|
|||
};
|
||||
|
||||
describe('extendSearchParamsWithRuntimeFields', () => {
|
||||
let dataStart: DataPublicPluginStart;
|
||||
let dataViewsStart: DataViewsPublicPluginStart;
|
||||
|
||||
beforeEach(() => {
|
||||
dataStart = dataPluginMock.createStartContract();
|
||||
dataViewsStart = dataViewPluginMocks.createStartContract();
|
||||
});
|
||||
|
||||
test('should inject default runtime_mappings for known indexes', async () => {
|
||||
const requestParams = {};
|
||||
const runtimeFields = { foo: {} };
|
||||
|
||||
mockComputedFields(dataStart, 'index', runtimeFields);
|
||||
mockComputedFields(dataViewsStart, 'index', runtimeFields);
|
||||
|
||||
expect(
|
||||
await extendSearchParamsWithRuntimeFields(dataStart.indexPatterns, requestParams, 'index')
|
||||
).toMatchInlineSnapshot(`
|
||||
expect(await extendSearchParamsWithRuntimeFields(dataViewsStart, requestParams, 'index'))
|
||||
.toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"body": Object {
|
||||
"runtime_mappings": Object {
|
||||
|
@ -63,11 +63,10 @@ describe('extendSearchParamsWithRuntimeFields', () => {
|
|||
} as unknown as ReturnType<typeof getSearchParamsFromRequest>;
|
||||
const runtimeFields = { foo: {} };
|
||||
|
||||
mockComputedFields(dataStart, 'index', runtimeFields);
|
||||
mockComputedFields(dataViewsStart, 'index', runtimeFields);
|
||||
|
||||
expect(
|
||||
await extendSearchParamsWithRuntimeFields(dataStart.indexPatterns, requestParams, 'index')
|
||||
).toMatchInlineSnapshot(`
|
||||
expect(await extendSearchParamsWithRuntimeFields(dataViewsStart, requestParams, 'index'))
|
||||
.toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"body": Object {
|
||||
"runtime_mappings": Object {
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
DataPublicPluginStart,
|
||||
IEsSearchResponse,
|
||||
} from '../../../../data/public';
|
||||
import type { DataViewsPublicPluginStart } from '../../../../data_views/public';
|
||||
import { search as dataPluginSearch } from '../../../../data/public';
|
||||
import type { VegaInspectorAdapters } from '../vega_inspector';
|
||||
import type { RequestResponder } from '../../../../inspector/public';
|
||||
|
@ -48,7 +49,7 @@ export interface SearchAPIDependencies {
|
|||
uiSettings: IUiSettingsClient;
|
||||
injectedMetadata: CoreStart['injectedMetadata'];
|
||||
search: DataPublicPluginStart['search'];
|
||||
indexPatterns: DataPublicPluginStart['indexPatterns'];
|
||||
indexPatterns: DataViewsPublicPluginStart;
|
||||
}
|
||||
|
||||
export class SearchAPI {
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { dataPluginMock } from '../../../../data/public/mocks';
|
||||
import { dataViewPluginMocks } from '../../../../data_views/public/mocks';
|
||||
import { extractIndexPatternsFromSpec } from './extract_index_pattern';
|
||||
import { setData } from '../services';
|
||||
import { setDataViews } from '../services';
|
||||
|
||||
import type { VegaSpec } from '../data_model/types';
|
||||
|
||||
const getMockedSpec = (mockedObj: any) => mockedObj as unknown as VegaSpec;
|
||||
|
||||
describe('extractIndexPatternsFromSpec', () => {
|
||||
const dataStart = dataPluginMock.createStartContract();
|
||||
const dataViewsStart = dataViewPluginMocks.createStartContract();
|
||||
|
||||
beforeAll(() => {
|
||||
setData(dataStart);
|
||||
setDataViews(dataViewsStart);
|
||||
});
|
||||
|
||||
test('should not throw errors if no index is specified', async () => {
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
*/
|
||||
|
||||
import { flatten } from 'lodash';
|
||||
import { getData } from '../services';
|
||||
import { getDataViews } from '../services';
|
||||
|
||||
import type { Data, VegaSpec } from '../data_model/types';
|
||||
import type { IndexPattern } from '../../../../data/public';
|
||||
import type { DataView } from '../../../../data_views/public';
|
||||
|
||||
export const extractIndexPatternsFromSpec = async (spec: VegaSpec) => {
|
||||
const { indexPatterns } = getData();
|
||||
const dataViews = getDataViews();
|
||||
let data: Data[] = [];
|
||||
|
||||
if (Array.isArray(spec.data)) {
|
||||
|
@ -22,11 +22,11 @@ export const extractIndexPatternsFromSpec = async (spec: VegaSpec) => {
|
|||
data = [spec.data];
|
||||
}
|
||||
|
||||
return flatten<IndexPattern>(
|
||||
return flatten<DataView>(
|
||||
await Promise.all(
|
||||
data.reduce<Array<Promise<IndexPattern[]>>>((accumulator, currentValue) => {
|
||||
data.reduce<Array<Promise<DataView[]>>>((accumulator, currentValue) => {
|
||||
if (currentValue.url?.index) {
|
||||
accumulator.push(indexPatterns.find(currentValue.url.index));
|
||||
accumulator.push(dataViews.find(currentValue.url.index));
|
||||
}
|
||||
|
||||
return accumulator;
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../../core/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../expressions/public';
|
||||
import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../data/public';
|
||||
import type { DataViewsPublicPluginStart } from '../../../data_views/public';
|
||||
import { VisualizationsSetup } from '../../../visualizations/public';
|
||||
import { Setup as InspectorSetup } from '../../../inspector/public';
|
||||
|
||||
import {
|
||||
setNotifications,
|
||||
setData,
|
||||
setDataViews,
|
||||
setInjectedVars,
|
||||
setUISettings,
|
||||
setInjectedMetadata,
|
||||
|
@ -54,6 +56,7 @@ export interface VegaPluginSetupDependencies {
|
|||
export interface VegaPluginStartDependencies {
|
||||
data: DataPublicPluginStart;
|
||||
mapsEms: MapsEmsPluginPublicStart;
|
||||
dataViews: DataViewsPublicPluginStart;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
@ -91,9 +94,10 @@ export class VegaPlugin implements Plugin<void, void> {
|
|||
visualizations.createBaseVisualization(createVegaTypeDefinition());
|
||||
}
|
||||
|
||||
public start(core: CoreStart, { data, mapsEms }: VegaPluginStartDependencies) {
|
||||
public start(core: CoreStart, { data, mapsEms, dataViews }: VegaPluginStartDependencies) {
|
||||
setNotifications(core.notifications);
|
||||
setData(data);
|
||||
setDataViews(dataViews);
|
||||
setInjectedMetadata(core.injectedMetadata);
|
||||
setDocLinks(core.docLinks);
|
||||
setMapsEms(mapsEms);
|
||||
|
|
|
@ -9,11 +9,15 @@
|
|||
import { CoreStart, NotificationsStart, IUiSettingsClient, DocLinksStart } from 'src/core/public';
|
||||
|
||||
import { DataPublicPluginStart } from '../../../data/public';
|
||||
import { DataViewsPublicPluginStart } from '../../../data_views/public';
|
||||
import { createGetterSetter } from '../../../kibana_utils/public';
|
||||
import type { MapsEmsPluginPublicStart } from '../../../maps_ems/public';
|
||||
|
||||
export const [getData, setData] = createGetterSetter<DataPublicPluginStart>('Data');
|
||||
|
||||
export const [getDataViews, setDataViews] =
|
||||
createGetterSetter<DataViewsPublicPluginStart>('DataViews');
|
||||
|
||||
export const [getNotifications, setNotifications] =
|
||||
createGetterSetter<NotificationsStart>('Notifications');
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
import type { KibanaExecutionContext } from 'src/core/public';
|
||||
import { DataView } from 'src/plugins/data/common';
|
||||
import type { DataView } from 'src/plugins/data_views/common';
|
||||
import { Filter, buildEsQuery } from '@kbn/es-query';
|
||||
import { getEsQueryConfig, TimeRange, Query } from '../../../data/public';
|
||||
|
||||
|
@ -15,7 +15,7 @@ import { TimeCache } from './data_model/time_cache';
|
|||
|
||||
import { VegaVisualizationDependencies } from './plugin';
|
||||
import { VisParams } from './vega_fn';
|
||||
import { getData, getInjectedMetadata } from './services';
|
||||
import { getData, getInjectedMetadata, getDataViews } from './services';
|
||||
import { VegaInspectorAdapters } from './vega_inspector';
|
||||
|
||||
interface VegaRequestHandlerParams {
|
||||
|
@ -48,7 +48,8 @@ export function createVegaRequestHandler(
|
|||
searchSessionId,
|
||||
executionContext,
|
||||
}: VegaRequestHandlerParams) {
|
||||
const { dataViews, search } = getData();
|
||||
const { search } = getData();
|
||||
const dataViews = getDataViews();
|
||||
|
||||
if (!searchAPI) {
|
||||
searchAPI = new SearchAPI(
|
||||
|
|
|
@ -18,7 +18,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { buildQueryFilter, compareFilters } from '@kbn/es-query';
|
||||
import { TooltipHandler } from './vega_tooltip';
|
||||
|
||||
import { getEnableExternalUrls, getData } from '../services';
|
||||
import { getEnableExternalUrls, getDataViews } from '../services';
|
||||
import { extractIndexPatternsFromSpec } from '../lib/extract_index_pattern';
|
||||
|
||||
scheme('elastic', euiPaletteColorBlind());
|
||||
|
@ -156,11 +156,11 @@ export class VegaBaseView {
|
|||
* @returns {Promise<string>} index id
|
||||
*/
|
||||
async findIndex(index) {
|
||||
const { indexPatterns } = getData();
|
||||
const dataViews = getDataViews();
|
||||
let idxObj;
|
||||
|
||||
if (index) {
|
||||
[idxObj] = await indexPatterns.find(index);
|
||||
[idxObj] = await dataViews.find(index);
|
||||
if (!idxObj) {
|
||||
throw new Error(
|
||||
i18n.translate('visTypeVega.vegaParser.baseView.indexNotFoundErrorMessage', {
|
||||
|
@ -175,7 +175,7 @@ export class VegaBaseView {
|
|||
);
|
||||
|
||||
if (!idxObj) {
|
||||
const defaultIdx = await indexPatterns.getDefault();
|
||||
const defaultIdx = await dataViews.getDefault();
|
||||
|
||||
if (defaultIdx) {
|
||||
idxObj = defaultIdx;
|
||||
|
|
|
@ -16,9 +16,17 @@ import { SearchAPI } from '../../data_model/search_api';
|
|||
import vegaMap from '../../test_utils/vega_map_test.json';
|
||||
import { coreMock } from '../../../../../../core/public/mocks';
|
||||
import { dataPluginMock } from '../../../../../data/public/mocks';
|
||||
import { dataViewPluginMocks } from '../../../../../data_views/public/mocks';
|
||||
|
||||
import type { IServiceSettings } from '../vega_map_view/service_settings/service_settings_types';
|
||||
|
||||
import { setInjectedVars, setData, setNotifications, setUISettings } from '../../services';
|
||||
import {
|
||||
setInjectedVars,
|
||||
setData,
|
||||
setNotifications,
|
||||
setUISettings,
|
||||
setDataViews,
|
||||
} from '../../services';
|
||||
import { initVegaLayer, initTmsRasterLayer } from './layers';
|
||||
|
||||
import { mapboxgl } from '@kbn/mapbox-gl';
|
||||
|
@ -59,6 +67,7 @@ describe('vega_map_view/view', () => {
|
|||
|
||||
const coreStart = coreMock.createStart();
|
||||
const dataPluginStart = dataPluginMock.createStartContract();
|
||||
const dataViewsStart = dataViewPluginMocks.createStartContract();
|
||||
const mockGetServiceSettings = async () => {
|
||||
return {
|
||||
getAttributionsFromTMSServce() {
|
||||
|
@ -98,6 +107,7 @@ describe('vega_map_view/view', () => {
|
|||
enableExternalUrls: true,
|
||||
});
|
||||
setData(dataPluginStart);
|
||||
setDataViews(dataViewsStart);
|
||||
setNotifications(coreStart.notifications);
|
||||
setUISettings(coreStart.uiSettings);
|
||||
|
||||
|
@ -125,7 +135,7 @@ describe('vega_map_view/view', () => {
|
|||
JSON.stringify(vegaMap),
|
||||
new SearchAPI({
|
||||
search: dataPluginStart.search,
|
||||
indexPatterns: dataPluginStart.indexPatterns,
|
||||
indexPatterns: dataViewsStart,
|
||||
uiSettings: coreStart.uiSettings,
|
||||
injectedMetadata: coreStart.injectedMetadata,
|
||||
}),
|
||||
|
|
|
@ -21,12 +21,12 @@ import { SearchAPI } from './data_model/search_api';
|
|||
import { setInjectedVars, setData, setNotifications } from './services';
|
||||
import { coreMock } from '../../../../core/public/mocks';
|
||||
import { dataPluginMock } from '../../../data/public/mocks';
|
||||
import { dataViewPluginMocks } from '../../../data_views/public/mocks';
|
||||
|
||||
jest.mock('./default_spec', () => ({
|
||||
getDefaultSpec: () => jest.requireActual('./test_utils/default.spec.json'),
|
||||
}));
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/71713
|
||||
describe('VegaVisualizations', () => {
|
||||
let domNode;
|
||||
let VegaVisualization;
|
||||
|
@ -39,6 +39,7 @@ describe('VegaVisualizations', () => {
|
|||
|
||||
const coreStart = coreMock.createStart();
|
||||
const dataPluginStart = dataPluginMock.createStartContract();
|
||||
const dataViewsPluginStart = dataViewPluginMocks.createStartContract();
|
||||
|
||||
const setupDOM = (width = 512, height = 512) => {
|
||||
mockedWidthValue = width;
|
||||
|
@ -94,7 +95,7 @@ describe('VegaVisualizations', () => {
|
|||
JSON.stringify(vegaliteGraph),
|
||||
new SearchAPI({
|
||||
search: dataPluginStart.search,
|
||||
indexPatterns: dataPluginStart.indexPatterns,
|
||||
indexPatterns: dataViewsPluginStart,
|
||||
uiSettings: coreStart.uiSettings,
|
||||
injectedMetadata: coreStart.injectedMetadata,
|
||||
}),
|
||||
|
@ -127,7 +128,7 @@ describe('VegaVisualizations', () => {
|
|||
JSON.stringify(vegaGraph),
|
||||
new SearchAPI({
|
||||
search: dataPluginStart.search,
|
||||
indexPatterns: dataPluginStart.indexPatterns,
|
||||
indexPatterns: dataViewsPluginStart,
|
||||
uiSettings: coreStart.uiSettings,
|
||||
injectedMetadata: coreStart.injectedMetadata,
|
||||
}),
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
"references": [
|
||||
{ "path": "../../../core/tsconfig.json" },
|
||||
{ "path": "../../data/tsconfig.json" },
|
||||
{ "path": "../../data_views/tsconfig.json" },
|
||||
{ "path": "../../visualizations/tsconfig.json" },
|
||||
{ "path": "../../maps_ems/tsconfig.json" },
|
||||
{ "path": "../../expressions/tsconfig.json" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue