Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lens] use IndexPattern instead of IIndexPattern #107225

Merged
merged 2 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions x-pack/plugins/lens/public/app_plugin/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
esFilters,
FilterManager,
IFieldType,
IIndexPattern,
IndexPattern,
Query,
} from '../../../../../src/plugins/data/public';
import { TopNavMenuData } from '../../../../../src/plugins/navigation/public';
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('Lens App', () => {

it('updates global filters with store state', async () => {
const services = makeDefaultServices(sessionIdSubject);
const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern;
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
const pinnedField = ({ name: 'pinnedField' } as unknown) as IFieldType;
const pinnedFilter = esFilters.buildExistsFilter(pinnedField, indexPattern);
services.data.query.filterManager.getFilters = jest.fn().mockImplementation(() => {
Expand Down Expand Up @@ -634,7 +634,7 @@ describe('Lens App', () => {
});

it('saves app filters and does not save pinned filters', async () => {
const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern;
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
const field = ({ name: 'myfield' } as unknown) as IFieldType;
const pinnedField = ({ name: 'pinnedField' } as unknown) as IFieldType;
const unpinned = esFilters.buildExistsFilter(field, indexPattern);
Expand Down Expand Up @@ -816,7 +816,7 @@ describe('Lens App', () => {

it('updates the filters when the user changes them', async () => {
const { instance, services, lensStore } = await mountWith({});
const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern;
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
const field = ({ name: 'myfield' } as unknown) as IFieldType;
expect(lensStore.getState()).toEqual({
lens: expect.objectContaining({
Expand Down Expand Up @@ -871,7 +871,7 @@ describe('Lens App', () => {
searchSessionId: `sessionId-3`,
}),
});
const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern;
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
const field = ({ name: 'myfield' } as unknown) as IFieldType;
act(() =>
services.data.query.filterManager.setFilters([
Expand Down Expand Up @@ -1006,7 +1006,7 @@ describe('Lens App', () => {
query: { query: 'new', language: 'lucene' },
})
);
const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern;
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
const field = ({ name: 'myfield' } as unknown) as IFieldType;
const pinnedField = ({ name: 'pinnedField' } as unknown) as IFieldType;
const unpinned = esFilters.buildExistsFilter(field, indexPattern);
Expand Down Expand Up @@ -1063,7 +1063,7 @@ describe('Lens App', () => {
query: { query: 'new', language: 'lucene' },
})
);
const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern;
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
const field = ({ name: 'myfield' } as unknown) as IFieldType;
const pinnedField = ({ name: 'pinnedField' } as unknown) as IFieldType;
const unpinned = esFilters.buildExistsFilter(field, indexPattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '../../mocks';
import { act } from 'react-dom/test-utils';
import { ReactExpressionRendererType } from '../../../../../../src/plugins/expressions/public';
import { esFilters, IFieldType, IIndexPattern } from '../../../../../../src/plugins/data/public';
import { esFilters, IFieldType, IndexPattern } from '../../../../../../src/plugins/data/public';
import { SuggestionPanel, SuggestionPanelProps } from './suggestion_panel';
import { getSuggestions, Suggestion } from './suggestion_helpers';
import { EuiIcon, EuiPanel, EuiToolTip } from '@elastic/eui';
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('suggestion_panel', () => {
(mockVisualization.toPreviewExpression as jest.Mock).mockReturnValueOnce('test | expression');
mockDatasource.toExpression.mockReturnValue('datasource_expression');

const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern;
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
const field = ({ name: 'myfield' } as unknown) as IFieldType;

mountWithProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ReactWrapper } from 'enzyme';
import { DragDrop, ChildDragDropProvider } from '../../../drag_drop';
import { fromExpression } from '@kbn/interpreter/common';
import { coreMock } from 'src/core/public/mocks';
import { esFilters, IFieldType, IIndexPattern } from '../../../../../../../src/plugins/data/public';
import { esFilters, IFieldType, IndexPattern } from '../../../../../../../src/plugins/data/public';
import { UiActionsStart } from '../../../../../../../src/plugins/ui_actions/public';
import { uiActionsPluginMock } from '../../../../../../../src/plugins/ui_actions/public/mocks';
import { TriggerContract } from '../../../../../../../src/plugins/ui_actions/public/triggers';
Expand Down Expand Up @@ -443,7 +443,7 @@ describe('workspace_panel', () => {

expect(expressionRendererMock).toHaveBeenCalledTimes(1);

const indexPattern = ({ id: 'index1' } as unknown) as IIndexPattern;
const indexPattern = ({ id: 'index1' } as unknown) as IndexPattern;
const field = ({ name: 'myfield' } as unknown) as IFieldType;

await act(async () => {
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/lens/public/embeddable/embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { ExecutionContextServiceStart } from 'src/core/public';
import {
ExecutionContextSearch,
Filter,
IIndexPattern,
Query,
TimefilterContract,
TimeRange,
Expand Down Expand Up @@ -83,7 +82,7 @@ export type LensByReferenceInput = SavedObjectEmbeddableInput & LensBaseEmbeddab
export type LensEmbeddableInput = LensByValueInput | LensByReferenceInput;

export interface LensEmbeddableOutput extends EmbeddableOutput {
indexPatterns?: IIndexPattern[];
indexPatterns?: IndexPattern[];
}

export interface LensEmbeddableDeps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { trackUiEvent } from '../lens_ui_telemetry';
import { loadIndexPatterns, syncExistingFields } from './loader';
import { fieldExists } from './pure_helpers';
import { Loader } from '../loader';
import { esQuery, IIndexPattern } from '../../../../../src/plugins/data/public';
import { esQuery } from '../../../../../src/plugins/data/public';
import { IndexPatternFieldEditorStart } from '../../../../../src/plugins/index_pattern_field_editor/public';
import { VISUALIZE_GEO_FIELD_TRIGGER } from '../../../../../src/plugins/ui_actions/public';

Expand Down Expand Up @@ -94,7 +94,7 @@ const fieldTypeNames: Record<DataType, string> = {
// Wrapper around esQuery.buildEsQuery, handling errors (e.g. because a query can't be parsed) by
// returning a query dsl object not matching anything
function buildSafeEsQuery(
indexPattern: IIndexPattern,
indexPattern: IndexPattern,
query: Query,
filters: Filter[],
queryConfig: EsQueryConfig
Expand Down Expand Up @@ -164,7 +164,7 @@ export function IndexPatternDataPanel({
}));

const dslQuery = buildSafeEsQuery(
indexPatterns[currentIndexPatternId] as IIndexPattern,
indexPatterns[currentIndexPatternId],
query,
filters,
esQuery.getEsQueryConfig(core.uiSettings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
ES_FIELD_TYPES,
Filter,
esQuery,
IIndexPattern,
} from '../../../../../src/plugins/data/public';
import { FieldButton } from '../../../../../src/plugins/kibana_react/public';
import { ChartsPluginSetup } from '../../../../../src/plugins/charts/public';
Expand Down Expand Up @@ -169,7 +168,7 @@ export const InnerFieldItem = function InnerFieldItem(props: FieldItemProps) {
.post(`/api/lens/index_stats/${indexPattern.id}/field`, {
body: JSON.stringify({
dslQuery: esQuery.buildEsQuery(
indexPattern as IIndexPattern,
indexPattern,
query,
filters,
esQuery.getEsQueryConfig(core.uiSettings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ import {
import { uniq } from 'lodash';
import { CoreStart } from 'kibana/public';
import { FieldStatsResponse } from '../../../../../common';
import {
AggFunctionsMapping,
esQuery,
IIndexPattern,
} from '../../../../../../../../src/plugins/data/public';
import { AggFunctionsMapping, esQuery } from '../../../../../../../../src/plugins/data/public';
import { buildExpressionFunction } from '../../../../../../../../src/plugins/expressions/public';
import { updateColumnParam, isReferenced } from '../../layer_helpers';
import { DataType, FramePublicAPI } from '../../../../types';
Expand Down Expand Up @@ -99,7 +95,7 @@ function getDisallowedTermsMessage(
body: JSON.stringify({
fieldName,
dslQuery: esQuery.buildEsQuery(
indexPattern as IIndexPattern,
indexPattern,
frame.query,
frame.filters,
esQuery.getEsQueryConfig(core.uiSettings)
Expand Down