mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
merge (#51616)
This commit is contained in:
parent
257ee130bf
commit
c73b5dad18
36 changed files with 75 additions and 75 deletions
|
@ -31,8 +31,12 @@ import {
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import React, { Component } from 'react';
|
||||
import { IndexPattern } from '../../index_patterns';
|
||||
import { FilterLabel } from '../filter_bar/filter_editor/lib/filter_label';
|
||||
import { mapAndFlattenFilters, esFilters, utils } from '../../../../../../plugins/data/public';
|
||||
import {
|
||||
mapAndFlattenFilters,
|
||||
esFilters,
|
||||
utils,
|
||||
FilterLabel,
|
||||
} from '../../../../../../plugins/data/public';
|
||||
|
||||
interface Props {
|
||||
filters: esFilters.Filter[];
|
||||
|
|
|
@ -17,6 +17,4 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export { FilterBar } from './filter_bar';
|
||||
|
||||
export { ApplyFiltersPopover } from './apply_filters';
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
@import './query/query_bar/index';
|
||||
|
||||
@import './filter/filter_bar/index';
|
||||
@import 'src/plugins/data/public/ui/filter_bar/index';
|
||||
|
||||
@import './search/search_bar/index';
|
||||
|
|
|
@ -29,7 +29,7 @@ export function plugin() {
|
|||
/** @public types */
|
||||
export { DataSetup, DataStart };
|
||||
|
||||
export { FilterBar, ApplyFiltersPopover } from './filter';
|
||||
export { ApplyFiltersPopover } from './filter';
|
||||
export {
|
||||
Field,
|
||||
FieldType,
|
||||
|
|
|
@ -35,9 +35,14 @@ const mockTimeHistory = {
|
|||
},
|
||||
};
|
||||
|
||||
jest.mock('../../../../../data/public', () => {
|
||||
jest.mock('../../../../../../../plugins/data/public', () => {
|
||||
return {
|
||||
FilterBar: () => <div className="filterBar" />,
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('../../../../../data/public', () => {
|
||||
return {
|
||||
QueryBarInput: () => <div className="queryBar" />,
|
||||
};
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ import React, { Component } from 'react';
|
|||
import ResizeObserver from 'resize-observer-polyfill';
|
||||
import { get, isEqual } from 'lodash';
|
||||
|
||||
import { IndexPattern, FilterBar } from '../../../../../data/public';
|
||||
import { IndexPattern } from '../../../../../data/public';
|
||||
import { QueryBarTopRow } from '../../../query';
|
||||
import { SavedQuery, SavedQueryAttributes } from '../index';
|
||||
import { SavedQueryMeta, SaveQueryForm } from './saved_query_management/save_query_form';
|
||||
|
@ -41,6 +41,7 @@ import {
|
|||
Query,
|
||||
esFilters,
|
||||
TimeHistoryContract,
|
||||
FilterBar,
|
||||
} from '../../../../../../../plugins/data/public';
|
||||
|
||||
interface SearchBarInjectedDeps {
|
||||
|
|
|
@ -36,3 +36,5 @@ export * from './types';
|
|||
export { IRequestTypesMap, IResponseTypesMap } from './search';
|
||||
export * from './search';
|
||||
export * from './query';
|
||||
|
||||
export * from './ui';
|
||||
|
|
|
@ -25,8 +25,8 @@ import React, { useState } from 'react';
|
|||
import { FilterEditor } from './filter_editor';
|
||||
import { FilterItem } from './filter_item';
|
||||
import { FilterOptions } from './filter_options';
|
||||
import { useKibana } from '../../../../../../plugins/kibana_react/public';
|
||||
import { IIndexPattern, esFilters } from '../../../../../../plugins/data/public';
|
||||
import { useKibana } from '../../../../kibana_react/public';
|
||||
import { IIndexPattern, esFilters } from '../..';
|
||||
|
||||
interface Props {
|
||||
filters: esFilters.Filter[];
|
|
@ -48,12 +48,7 @@ import { Operator } from './lib/filter_operators';
|
|||
import { PhraseValueInput } from './phrase_value_input';
|
||||
import { PhrasesValuesInput } from './phrases_values_input';
|
||||
import { RangeValueInput } from './range_value_input';
|
||||
import {
|
||||
esFilters,
|
||||
utils,
|
||||
IIndexPattern,
|
||||
IFieldType,
|
||||
} from '../../../../../../../plugins/data/public';
|
||||
import { esFilters, utils, IIndexPattern, IFieldType } from '../../..';
|
||||
|
||||
interface Props {
|
||||
filter: esFilters.Filter;
|
|
@ -17,7 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable @kbn/eslint/no-restricted-paths */
|
||||
import {
|
||||
existsFilter,
|
||||
phraseFilter,
|
||||
|
@ -25,8 +24,8 @@ import {
|
|||
rangeFilter,
|
||||
stubIndexPattern,
|
||||
stubFields,
|
||||
} from '../../../../../../../../plugins/data/public/stubs';
|
||||
import { IndexPattern, Field } from '../../../../index';
|
||||
} from '../../../../stubs';
|
||||
import { esFilters } from '../../../../index';
|
||||
import {
|
||||
getFieldFromFilter,
|
||||
getFilterableFields,
|
||||
|
@ -37,17 +36,12 @@ import {
|
|||
|
||||
import { existsOperator, isBetweenOperator, isOneOfOperator, isOperator } from './filter_operators';
|
||||
|
||||
import { esFilters } from '../../../../../../../../plugins/data/public';
|
||||
|
||||
jest.mock('ui/new_platform');
|
||||
|
||||
const mockedFields = stubFields as Field[];
|
||||
const mockedIndexPattern = stubIndexPattern as IndexPattern;
|
||||
|
||||
describe('Filter editor utils', () => {
|
||||
describe('getFieldFromFilter', () => {
|
||||
it('should return the field from the filter', () => {
|
||||
const field = getFieldFromFilter(phraseFilter, mockedIndexPattern);
|
||||
const field = getFieldFromFilter(phraseFilter, stubIndexPattern);
|
||||
expect(field).not.toBeUndefined();
|
||||
expect(field && field.name).toBe(phraseFilter.meta.key);
|
||||
});
|
||||
|
@ -117,12 +111,12 @@ describe('Filter editor utils', () => {
|
|||
|
||||
describe('getFilterableFields', () => {
|
||||
it('returns the list of fields from the given index pattern', () => {
|
||||
const fieldOptions = getFilterableFields(mockedIndexPattern);
|
||||
const fieldOptions = getFilterableFields(stubIndexPattern);
|
||||
expect(fieldOptions.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('limits the fields to the filterable fields', () => {
|
||||
const fieldOptions = getFilterableFields(mockedIndexPattern);
|
||||
const fieldOptions = getFilterableFields(stubIndexPattern);
|
||||
const nonFilterableFields = fieldOptions.filter(field => !field.filterable);
|
||||
expect(nonFilterableFields.length).toBe(0);
|
||||
});
|
||||
|
@ -131,14 +125,14 @@ describe('Filter editor utils', () => {
|
|||
describe('getOperatorOptions', () => {
|
||||
it('returns range for number fields', () => {
|
||||
const [field] = stubFields.filter(({ type }) => type === 'number');
|
||||
const operatorOptions = getOperatorOptions(field as Field);
|
||||
const operatorOptions = getOperatorOptions(field);
|
||||
const rangeOperator = operatorOptions.find(operator => operator.type === 'range');
|
||||
expect(rangeOperator).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it('does not return range for string fields', () => {
|
||||
const [field] = stubFields.filter(({ type }) => type === 'string');
|
||||
const operatorOptions = getOperatorOptions(field as Field);
|
||||
const operatorOptions = getOperatorOptions(field);
|
||||
const rangeOperator = operatorOptions.find(operator => operator.type === 'range');
|
||||
expect(rangeOperator).toBeUndefined();
|
||||
});
|
||||
|
@ -146,49 +140,44 @@ describe('Filter editor utils', () => {
|
|||
|
||||
describe('isFilterValid', () => {
|
||||
it('should return false if index pattern is not provided', () => {
|
||||
const isValid = isFilterValid(undefined, mockedFields[0], isOperator, 'foo');
|
||||
const isValid = isFilterValid(undefined, stubFields[0], isOperator, 'foo');
|
||||
expect(isValid).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if field is not provided', () => {
|
||||
const isValid = isFilterValid(mockedIndexPattern, undefined, isOperator, 'foo');
|
||||
const isValid = isFilterValid(stubIndexPattern, undefined, isOperator, 'foo');
|
||||
expect(isValid).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if operator is not provided', () => {
|
||||
const isValid = isFilterValid(mockedIndexPattern, mockedFields[0], undefined, 'foo');
|
||||
const isValid = isFilterValid(stubIndexPattern, stubFields[0], undefined, 'foo');
|
||||
expect(isValid).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false for phrases filter without phrases', () => {
|
||||
const isValid = isFilterValid(mockedIndexPattern, mockedFields[0], isOneOfOperator, []);
|
||||
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isOneOfOperator, []);
|
||||
expect(isValid).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true for phrases filter with phrases', () => {
|
||||
const isValid = isFilterValid(mockedIndexPattern, mockedFields[0], isOneOfOperator, ['foo']);
|
||||
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isOneOfOperator, ['foo']);
|
||||
expect(isValid).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for range filter without range', () => {
|
||||
const isValid = isFilterValid(
|
||||
mockedIndexPattern,
|
||||
mockedFields[0],
|
||||
isBetweenOperator,
|
||||
undefined
|
||||
);
|
||||
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isBetweenOperator, undefined);
|
||||
expect(isValid).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true for range filter with from', () => {
|
||||
const isValid = isFilterValid(mockedIndexPattern, mockedFields[0], isBetweenOperator, {
|
||||
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isBetweenOperator, {
|
||||
from: 'foo',
|
||||
});
|
||||
expect(isValid).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for range filter with from/to', () => {
|
||||
const isValid = isFilterValid(mockedIndexPattern, mockedFields[0], isBetweenOperator, {
|
||||
const isValid = isFilterValid(stubIndexPattern, stubFields[0], isBetweenOperator, {
|
||||
from: 'foo',
|
||||
too: 'goo',
|
||||
});
|
||||
|
@ -196,7 +185,7 @@ describe('Filter editor utils', () => {
|
|||
});
|
||||
|
||||
it('should return true for exists filter without params', () => {
|
||||
const isValid = isFilterValid(mockedIndexPattern, mockedFields[0], existsOperator);
|
||||
const isValid = isFilterValid(stubIndexPattern, stubFields[0], existsOperator);
|
||||
expect(isValid).toBe(true);
|
||||
});
|
||||
});
|
|
@ -18,14 +18,9 @@
|
|||
*/
|
||||
|
||||
import dateMath from '@elastic/datemath';
|
||||
import { Ipv4Address } from '../../../../../../../../plugins/kibana_utils/public';
|
||||
import { Ipv4Address } from '../../../../../../kibana_utils/public';
|
||||
import { FILTER_OPERATORS, Operator } from './filter_operators';
|
||||
import {
|
||||
esFilters,
|
||||
IIndexPattern,
|
||||
IFieldType,
|
||||
isFilterable,
|
||||
} from '../../../../../../../../plugins/data/public';
|
||||
import { esFilters, IIndexPattern, IFieldType, isFilterable } from '../../../..';
|
||||
|
||||
export function getFieldFromFilter(filter: esFilters.FieldFilter, indexPattern: IIndexPattern) {
|
||||
return indexPattern.fields.find(field => field.name === filter.meta.key);
|
|
@ -20,10 +20,7 @@
|
|||
import React from 'react';
|
||||
import { FilterLabel } from './filter_label';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
/* eslint-disable @kbn/eslint/no-restricted-paths */
|
||||
import { phraseFilter } from '../../../../../../../../plugins/data/public/stubs';
|
||||
/* eslint-enable @kbn/eslint/no-restricted-paths */
|
||||
import { phraseFilter } from '../../../../stubs';
|
||||
|
||||
test('alias', () => {
|
||||
const filter = {
|
|
@ -21,7 +21,7 @@ import React, { Fragment } from 'react';
|
|||
import { EuiTextColor } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { existsOperator, isOneOfOperator } from './filter_operators';
|
||||
import { esFilters } from '../../../../../../../../plugins/data/public';
|
||||
import { esFilters } from '../../../..';
|
||||
|
||||
interface Props {
|
||||
filter: esFilters.Filter;
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { esFilters } from '../../../../../../../../plugins/data/public';
|
||||
import { esFilters } from '../../../..';
|
||||
|
||||
export interface Operator {
|
||||
message: string;
|
|
@ -19,16 +19,9 @@
|
|||
|
||||
import { Component } from 'react';
|
||||
import { debounce } from 'lodash';
|
||||
import {
|
||||
withKibana,
|
||||
KibanaReactContextValue,
|
||||
} from '../../../../../../../plugins/kibana_react/public';
|
||||
|
||||
import {
|
||||
IDataPluginServices,
|
||||
IIndexPattern,
|
||||
IFieldType,
|
||||
} from '../../../../../../../plugins/data/public';
|
||||
import { withKibana, KibanaReactContextValue } from '../../../../../kibana_react/public';
|
||||
import { IDataPluginServices, IIndexPattern, IFieldType } from '../../..';
|
||||
|
||||
export interface PhraseSuggestorProps {
|
||||
kibana: KibanaReactContextValue<IDataPluginServices>;
|
|
@ -24,7 +24,7 @@ import React from 'react';
|
|||
import { GenericComboBox, GenericComboBoxProps } from './generic_combo_box';
|
||||
import { PhraseSuggestorUI, PhraseSuggestorProps } from './phrase_suggestor';
|
||||
import { ValueInputType } from './value_input_type';
|
||||
import { withKibana } from '../../../../../../../plugins/kibana_react/public';
|
||||
import { withKibana } from '../../../../../kibana_react/public';
|
||||
|
||||
interface Props extends PhraseSuggestorProps {
|
||||
value?: string;
|
|
@ -23,7 +23,7 @@ import { uniq } from 'lodash';
|
|||
import React from 'react';
|
||||
import { GenericComboBox, GenericComboBoxProps } from './generic_combo_box';
|
||||
import { PhraseSuggestorUI, PhraseSuggestorProps } from './phrase_suggestor';
|
||||
import { withKibana } from '../../../../../../../plugins/kibana_react/public';
|
||||
import { withKibana } from '../../../../../kibana_react/public';
|
||||
|
||||
interface Props extends PhraseSuggestorProps {
|
||||
values?: string[];
|
|
@ -21,8 +21,8 @@ import { EuiIcon, EuiLink, EuiFormHelpText, EuiFormControlLayoutDelimited } from
|
|||
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
|
||||
import { get } from 'lodash';
|
||||
import React from 'react';
|
||||
import { useKibana } from '../../../../../../../plugins/kibana_react/public';
|
||||
import { IFieldType } from '../../../../../../../plugins/data/public';
|
||||
import { useKibana } from '../../../../../kibana_react/public';
|
||||
import { IFieldType } from '../../..';
|
||||
import { ValueInputType } from './value_input_type';
|
||||
|
||||
interface RangeParams {
|
|
@ -24,7 +24,7 @@ import React, { Component } from 'react';
|
|||
import { UiSettingsClientContract } from 'src/core/public';
|
||||
import { FilterEditor } from './filter_editor';
|
||||
import { FilterView } from './filter_view';
|
||||
import { esFilters, utils, IIndexPattern } from '../../../../../../plugins/data/public';
|
||||
import { esFilters, utils, IIndexPattern } from '../..';
|
||||
|
||||
interface Props {
|
||||
id: string;
|
|
@ -21,7 +21,7 @@ import { EuiBadge, useInnerText } from '@elastic/eui';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import React, { FC } from 'react';
|
||||
import { FilterLabel } from '../filter_editor/lib/filter_label';
|
||||
import { esFilters } from '../../../../../../../plugins/data/public';
|
||||
import { esFilters } from '../../..';
|
||||
|
||||
interface Props {
|
||||
filter: esFilters.Filter;
|
21
src/plugins/data/public/ui/filter_bar/index.ts
Normal file
21
src/plugins/data/public/ui/filter_bar/index.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export { FilterBar } from './filter_bar';
|
||||
export { FilterLabel } from './filter_editor/lib/filter_label';
|
|
@ -17,4 +17,4 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export { FilterBar } from './filter_bar';
|
||||
export * from './filter_bar';
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { ES_FIELD_TYPES } from '../../../../../../src/plugins/data/public';
|
||||
import { ES_FIELD_TYPES } from '../../../../../../src/plugins/data/common';
|
||||
import {
|
||||
ML_JOB_AGGREGATION,
|
||||
KIBANA_AGGREGATION,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { Dictionary } from '../../../common/types/common';
|
||||
import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public';
|
||||
import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/common';
|
||||
|
||||
import { AggName } from './aggregations';
|
||||
import { EsFieldName } from './fields';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { Dictionary } from '../../../common/types/common';
|
||||
import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public';
|
||||
import { KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/common';
|
||||
|
||||
import { AggName } from './aggregations';
|
||||
import { EsFieldName } from './fields';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue