Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import classNames from 'classnames';
import React, { Component } from 'react';
import chrome from 'ui/chrome';
import { IndexPattern } from 'ui/index_patterns';
import { IndexPattern } from '../../index_patterns';
import { FilterEditor } from './filter_editor';
import { FilterItem } from './filter_item';
import { FilterOptions } from './filter_options';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { FieldFilter, Filter } from '@kbn/es-query';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import { get } from 'lodash';
import React, { Component } from 'react';
import { Field, IndexPattern } from 'ui/index_patterns';
import { Field, IndexPattern } from '../../../index_patterns';
import { GenericComboBox, GenericComboBoxProps } from './generic_combo_box';
import {
buildCustomFilter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/

import { FilterStateStore, toggleFilterNegated } from '@kbn/es-query';
import { mockFields, mockIndexPattern } from 'ui/index_patterns/fixtures';

import { fixtures } from '../../../../index_patterns';
import {
buildFilter,
getFieldFromFilter,
Expand All @@ -42,6 +43,22 @@ import { phraseFilter } from './fixtures/phrase_filter';
import { phrasesFilter } from './fixtures/phrases_filter';
import { rangeFilter } from './fixtures/range_filter';

jest.mock('ui/kfetch', () => ({
kfetch: () => {},
}));

jest.mock(
'ui/notify',
() => ({
toastNotifications: {
addWarning: () => {},
},
}),
{ virtual: true }
);

const { mockFields, mockIndexPattern } = fixtures;

describe('Filter editor utils', () => {
describe('getQueryDslFromFilter', () => {
it('should return query DSL without meta and $state', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ import {
RangeFilter,
} from '@kbn/es-query';
import { omit } from 'lodash';
import { Field, IndexPattern } from 'ui/index_patterns';
import { isFilterable } from 'ui/index_patterns/static_utils';
import Ipv4Address from 'ui/utils/ipv4_address';
import { Field, IndexPattern, utils as indexPatternUtils } from '../../../../index_patterns';
import { FILTER_OPERATORS, Operator } from './filter_operators';

export function getIndexPatternFromFilter(
Expand All @@ -59,7 +58,7 @@ export function getQueryDslFromFilter(filter: Filter) {
}

export function getFilterableFields(indexPattern: IndexPattern) {
return indexPattern.fields.filter(isFilterable);
return indexPattern.fields.filter(indexPatternUtils.isFilterable);
}

export function getOperatorOptions(field: Field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import { Component } from 'react';
import chrome from 'ui/chrome';
import { Field, IndexPattern } from 'ui/index_patterns';
import { getSuggestions } from 'ui/value_suggestions';
import { Field, IndexPattern } from '../../../index_patterns';
const config = chrome.getUiSettingsClient();

export interface PhraseSuggestorProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { get } from 'lodash';
import { Component } from 'react';
import React from 'react';
import { getDocLink } from 'ui/documentation_links';
import { Field } from 'ui/index_patterns';
import { Field } from '../../../index_patterns';
import { ValueInputType } from './value_input_type';

interface RangeParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import classNames from 'classnames';
import React, { Component } from 'react';
import { IndexPattern } from 'ui/index_patterns';
import { IndexPattern } from '../../index_patterns';
import { FilterEditor } from './filter_editor';
import { FilterView } from './filter_view';

Expand Down
2 changes: 2 additions & 0 deletions src/legacy/core_plugins/data/public/index_patterns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ export {
StaticIndexPattern,
StaticIndexPatternField,
Field,
fixtures,
utils,
} from './index_patterns_service';
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { IndexPatterns } from 'ui/index_patterns/index';
// @ts-ignore
import { validateIndexPattern } from 'ui/index_patterns/index';

import { isFilterable, getFromSavedObject } from 'ui/index_patterns/static_utils';

// IndexPattern, StaticIndexPattern, StaticIndexPatternField, Field
import * as types from 'ui/index_patterns';

Expand Down Expand Up @@ -75,7 +77,12 @@ const ui = {
IndexPatternSelect,
};

export { validateIndexPattern, constants, fixtures, ui, IndexPatterns };
const utils = {
getFromSavedObject,
isFilterable,
};

export { validateIndexPattern, constants, fixtures, ui, IndexPatterns, utils };

/** @public */
export type IndexPatternsSetup = ReturnType<IndexPatternsService['setup']>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import {
getAutocompleteProvider,
} from 'ui/autocomplete_providers';
import { debounce, compact, isEqual, omit } from 'lodash';
import { IndexPattern, StaticIndexPattern } from 'ui/index_patterns';
import { PersistedLog } from 'ui/persisted_log';
import chrome from 'ui/chrome';
import { kfetch } from 'ui/kfetch';
import { Storage } from 'ui/storage';
import { localStorage } from 'ui/storage/storage_service';
import { IndexPattern, StaticIndexPattern } from '../../../index_patterns';
import { Query } from '../index';
import { fromUser, matchPairs, toUser } from '../lib';
import { QueryLanguageSwitcher } from './language_switcher';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

import chrome from 'ui/chrome';
import { getFromSavedObject } from 'ui/index_patterns/static_utils';
import { isEmpty } from 'lodash';
import { utils as indexPatternUtils } from '../../../index_patterns';

const config = chrome.getUiSettingsClient();

Expand All @@ -45,7 +45,7 @@ export async function fetchIndexPatterns(indexPatternStrings: string[]) {
? exactMatches
: [...exactMatches, await fetchDefaultIndexPattern()];

return allMatches.map(getFromSavedObject);
return allMatches.map(indexPatternUtils.getFromSavedObject);
}

const fetchDefaultIndexPattern = async () => {
Expand Down