Skip to content

Commit

Permalink
Merge branch 'master' into use-log4j-syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Feb 12, 2020
2 parents 20ecaa8 + 5e687b1 commit c8bc7e4
Show file tree
Hide file tree
Showing 231 changed files with 1,415 additions and 1,394 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ import {
// @ts-ignore
import { onBrushEvent } from './filters/brush_event';
import {
esFilters,
Filter,
FilterManager,
TimefilterContract,
changeTimeFilter,
extractTimeFilter,
mapAndFlattenFilters,
esFilters,
} from '../../../../../plugins/data/public';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getIndexPatterns } from '../../../../../plugins/data/public/services';
Expand All @@ -45,7 +43,7 @@ interface ActionContext {

async function isCompatible(context: ActionContext) {
try {
const filters: esFilters.Filter[] = (await onBrushEvent(context.data, getIndexPatterns)) || [];
const filters: Filter[] = (await onBrushEvent(context.data, getIndexPatterns)) || [];
return filters.length > 0;
} catch {
return false;
Expand All @@ -70,18 +68,18 @@ export function selectRangeAction(
throw new IncompatibleActionError();
}

const filters: esFilters.Filter[] = (await onBrushEvent(data, getIndexPatterns)) || [];
const filters: Filter[] = (await onBrushEvent(data, getIndexPatterns)) || [];

const selectedFilters: esFilters.Filter[] = mapAndFlattenFilters(filters);
const selectedFilters: Filter[] = esFilters.mapAndFlattenFilters(filters);

if (timeFieldName) {
const { timeRangeFilter, restOfFilters } = extractTimeFilter(
const { timeRangeFilter, restOfFilters } = esFilters.extractTimeFilter(
timeFieldName,
selectedFilters
);
filterManager.addFilters(restOfFilters);
if (timeRangeFilter) {
changeTimeFilter(timeFilter, timeRangeFilter);
esFilters.changeTimeFilter(timeFilter, timeRangeFilter);
}
} else {
filterManager.addFilters(selectedFilters);
Expand Down
20 changes: 9 additions & 11 deletions src/legacy/core_plugins/data/public/actions/value_click_action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ import { applyFiltersPopover } from '../../../../../plugins/data/public/ui/apply
// @ts-ignore
import { createFiltersFromEvent } from './filters/create_filters_from_event';
import {
esFilters,
Filter,
FilterManager,
TimefilterContract,
changeTimeFilter,
extractTimeFilter,
mapAndFlattenFilters,
esFilters,
} from '../../../../../plugins/data/public';

export const VALUE_CLICK_ACTION = 'VALUE_CLICK_ACTION';
Expand All @@ -48,7 +46,7 @@ interface ActionContext {

async function isCompatible(context: ActionContext) {
try {
const filters: esFilters.Filter[] = (await createFiltersFromEvent(context.data)) || [];
const filters: Filter[] = (await createFiltersFromEvent(context.data)) || [];
return filters.length > 0;
} catch {
return false;
Expand All @@ -73,9 +71,9 @@ export function valueClickAction(
throw new IncompatibleActionError();
}

const filters: esFilters.Filter[] = (await createFiltersFromEvent(data)) || [];
const filters: Filter[] = (await createFiltersFromEvent(data)) || [];

let selectedFilters: esFilters.Filter[] = mapAndFlattenFilters(filters);
let selectedFilters: Filter[] = esFilters.mapAndFlattenFilters(filters);

if (selectedFilters.length > 1) {
const indexPatterns = await Promise.all(
Expand All @@ -84,7 +82,7 @@ export function valueClickAction(
})
);

const filterSelectionPromise: Promise<esFilters.Filter[]> = new Promise(resolve => {
const filterSelectionPromise: Promise<Filter[]> = new Promise(resolve => {
const overlay = getOverlays().openModal(
toMountPoint(
applyFiltersPopover(
Expand All @@ -94,7 +92,7 @@ export function valueClickAction(
overlay.close();
resolve([]);
},
(filterSelection: esFilters.Filter[]) => {
(filterSelection: Filter[]) => {
overlay.close();
resolve(filterSelection);
}
Expand All @@ -110,13 +108,13 @@ export function valueClickAction(
}

if (timeFieldName) {
const { timeRangeFilter, restOfFilters } = extractTimeFilter(
const { timeRangeFilter, restOfFilters } = esFilters.extractTimeFilter(
timeFieldName,
selectedFilters
);
filterManager.addFilters(restOfFilters);
if (timeRangeFilter) {
changeTimeFilter(timeFilter, timeRangeFilter);
esFilters.changeTimeFilter(timeFilter, timeRangeFilter);
}
} else {
filterManager.addFilters(selectedFilters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
import _ from 'lodash';
import { Subscription } from 'rxjs';
import { State } from 'ui/state_management/state';
import { FilterManager, esFilters } from '../../../../../../plugins/data/public';
import { compareFilters, COMPARE_ALL_OPTIONS } from '../../../../../../plugins/data/public';
import { FilterManager, esFilters, Filter } from '../../../../../../plugins/data/public';

type GetAppStateFunc = () => { filters?: esFilters.Filter[]; save?: () => void } | undefined | null;
type GetAppStateFunc = () => { filters?: Filter[]; save?: () => void } | undefined | null;

/**
* FilterStateManager is responsible for watching for filter changes
Expand Down Expand Up @@ -68,15 +67,15 @@ export class FilterStateManager {
const globalFilters = this.globalState.filters || [];
const appFilters = (appState && appState.filters) || [];

const globalFilterChanged = !compareFilters(
const globalFilterChanged = !esFilters.compareFilters(
this.filterManager.getGlobalFilters(),
globalFilters,
COMPARE_ALL_OPTIONS
esFilters.COMPARE_ALL_OPTIONS
);
const appFilterChanged = !compareFilters(
const appFilterChanged = !esFilters.compareFilters(
this.filterManager.getAppFilters(),
appFilters,
COMPARE_ALL_OPTIONS
esFilters.COMPARE_ALL_OPTIONS
);
const filterStateChanged = globalFilterChanged || appFilterChanged;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* under the License.
*/

import { esFilters } from '../../../../../../../plugins/data/public';
import { Filter } from '../../../../../../../plugins/data/public';

export function getFilter(
store: esFilters.FilterStateStore,
store: any, // I don't want to export only for this, as it should move to data plugin
disabled: boolean,
negated: boolean,
queryKey: string,
queryValue: any
): esFilters.Filter {
): Filter {
return {
$state: {
store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import sinon from 'sinon';

import { State } from 'ui/state_management/state';
import { esFilters } from '../../../../../../../plugins/data/public';
import { Filter } from '../../../../../../../plugins/data/public';

export class StubState implements State {
filters: esFilters.Filter[];
filters: Filter[];
save: sinon.SinonSpy<any[], any>;

constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import { intervalOptions } from '../_interval_options';
import { AggConfigs } from '../../agg_configs';
import { IBucketDateHistogramAggConfig } from '../date_histogram';
import { BUCKET_TYPES } from '../bucket_agg_types';
import { esFilters } from '../../../../../../../../plugins/data/public';
import { RangeFilter } from '../../../../../../../../plugins/data/public';

jest.mock('ui/new_platform');

describe('AggConfig Filters', () => {
describe('date_histogram', () => {
let agg: IBucketDateHistogramAggConfig;
let filter: esFilters.RangeFilter;
let filter: RangeFilter;
let bucketStart: any;
let field: any;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import moment from 'moment';
import { IBucketAggConfig } from '../_bucket_agg_type';
import { DateRangeKey } from '../date_range';
import { esFilters } from '../../../../../../../../plugins/data/public';
import { esFilters, RangeFilterParams } from '../../../../../../../../plugins/data/public';

export const createFilterDateRange = (agg: IBucketAggConfig, { from, to }: DateRangeKey) => {
const filter: esFilters.RangeFilterParams = {};
const filter: RangeFilterParams = {};
if (from) filter.gte = moment(from).toISOString();
if (to) filter.lt = moment(to).toISOString();
if (to && from) filter.format = 'strict_date_optional_time';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/

import { IBucketAggConfig } from '../_bucket_agg_type';
import { esFilters } from '../../../../../../../../plugins/data/public';
import { esFilters, RangeFilterParams } from '../../../../../../../../plugins/data/public';

export const createFilterHistogram = (aggConfig: IBucketAggConfig, key: string) => {
const value = parseInt(key, 10);
const params: esFilters.RangeFilterParams = { gte: value, lt: value + aggConfig.params.interval };
const params: RangeFilterParams = { gte: value, lt: value + aggConfig.params.interval };

return esFilters.buildRangeFilter(
aggConfig.params.field,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import { CidrMask } from '../lib/cidr_mask';
import { IBucketAggConfig } from '../_bucket_agg_type';
import { IpRangeKey } from '../ip_range';
import { esFilters } from '../../../../../../../../plugins/data/public';
import { esFilters, RangeFilterParams } from '../../../../../../../../plugins/data/public';

export const createFilterIpRange = (aggConfig: IBucketAggConfig, key: IpRangeKey) => {
let range: esFilters.RangeFilterParams;
let range: RangeFilterParams;

if (key.type === 'mask') {
range = new CidrMask(key.mask).getRange();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { createFilterTerms } from './terms';
import { AggConfigs } from '../../agg_configs';
import { BUCKET_TYPES } from '../bucket_agg_types';
import { IBucketAggConfig } from '../_bucket_agg_type';
import { esFilters } from '../../../../../../../../plugins/data/public';
import { Filter, ExistsFilter } from '../../../../../../../../plugins/data/public';

jest.mock('ui/new_platform');

Expand Down Expand Up @@ -54,7 +54,7 @@ describe('AggConfig Filters', () => {
aggConfigs.aggs[0] as IBucketAggConfig,
'apache',
{}
) as esFilters.Filter;
) as Filter;

expect(filter).toHaveProperty('query');
expect(filter.query).toHaveProperty('match_phrase');
Expand All @@ -73,7 +73,7 @@ describe('AggConfig Filters', () => {
aggConfigs.aggs[0] as IBucketAggConfig,
'',
{}
) as esFilters.Filter;
) as Filter;

expect(filterFalse).toHaveProperty('query');
expect(filterFalse.query).toHaveProperty('match_phrase');
Expand All @@ -84,7 +84,7 @@ describe('AggConfig Filters', () => {
aggConfigs.aggs[0] as IBucketAggConfig,
'1',
{}
) as esFilters.Filter;
) as Filter;

expect(filterTrue).toHaveProperty('query');
expect(filterTrue.query).toHaveProperty('match_phrase');
Expand All @@ -100,7 +100,7 @@ describe('AggConfig Filters', () => {
aggConfigs.aggs[0] as IBucketAggConfig,
'__missing__',
{}
) as esFilters.ExistsFilter;
) as ExistsFilter;

expect(filter).toHaveProperty('exists');
expect(filter.exists).toHaveProperty('field', 'field');
Expand All @@ -116,7 +116,7 @@ describe('AggConfig Filters', () => {

const [filter] = createFilterTerms(aggConfigs.aggs[0] as IBucketAggConfig, '__other__', {
terms: ['apache'],
}) as esFilters.Filter[];
}) as Filter[];

expect(filter).toHaveProperty('query');
expect(filter.query).toHaveProperty('bool');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { IBucketAggConfig } from '../_bucket_agg_type';
import { esFilters } from '../../../../../../../../plugins/data/public';
import { esFilters, Filter } from '../../../../../../../../plugins/data/public';

export const createFilterTerms = (aggConfig: IBucketAggConfig, key: string, params: any) => {
const field = aggConfig.params.field;
Expand All @@ -30,7 +30,7 @@ export const createFilterTerms = (aggConfig: IBucketAggConfig, key: string, para
const phraseFilter = esFilters.buildPhrasesFilter(field, terms, indexPattern);
phraseFilter.meta.negate = true;

const filters: esFilters.Filter[] = [phraseFilter];
const filters: Filter[] = [phraseFilter];

if (terms.some((term: string) => term === '__missing__')) {
filters.push(esFilters.buildExistsFilter(field, indexPattern));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
SearchSource,
Query,
TimeRange,
esFilters,
Filter,
getTime,
FilterManager,
} from '../../../../../../plugins/data/public';
Expand All @@ -53,7 +53,7 @@ export interface RequestHandlerParams {
aggs: IAggConfigs;
timeRange?: TimeRange;
query?: Query;
filters?: esFilters.Filter[];
filters?: Filter[];
forceFetch: boolean;
filterManager: FilterManager;
uiState?: PersistedState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import _ from 'lodash';
import { i18n } from '@kbn/i18n';

import { esFilters } from '../../../../../plugins/data/public';
import { Filter } from '../../../../../plugins/data/public';
import { SearchSource as SearchSourceClass } from '../legacy_imports';
import { ControlParams, ControlParamsOptions, CONTROL_TYPES } from '../editor_utils';
import { RangeFilterManager } from './filter_manager/range_filter_manager';
Expand All @@ -46,7 +46,7 @@ export function noIndexPatternMsg(indexPatternId: string) {
}

export abstract class Control<FilterManager extends BaseFilterManager> {
private kbnFilter: esFilters.Filter | null = null;
private kbnFilter: Filter | null = null;

enable: boolean = false;
disabledReason: string = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { esFilters, IndexPattern, TimefilterSetup } from '../../../../../plugins/data/public';
import { PhraseFilter, IndexPattern, TimefilterSetup } from '../../../../../plugins/data/public';
import { SearchSource as SearchSourceClass, SearchSourceFields } from '../legacy_imports';

export function createSearchSource(
Expand All @@ -26,7 +26,7 @@ export function createSearchSource(
indexPattern: IndexPattern,
aggs: any,
useTimeFilter: boolean,
filters: esFilters.PhraseFilter[] = [],
filters: PhraseFilter[] = [],
timefilter: TimefilterSetup['timefilter']
) {
const searchSource = initialState ? new SearchSource(initialState) : new SearchSource();
Expand Down
Loading

0 comments on commit c8bc7e4

Please sign in to comment.