Move apply filters popover ⇒ NP (#51566)

* Move ApplyFiltersPopoverContent and applyFiltersPopover to NP

* code review
This commit is contained in:
Liza Katz 2019-11-26 13:45:37 +02:00 committed by GitHub
parent cfed9c6c48
commit 9e168391af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 88 deletions

View file

@ -1167,7 +1167,7 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy';
| Legacy Platform | New Platform | Notes |
| ------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `import 'ui/apply_filters'` | `import { ApplyFiltersPopover } from '../data/public'` | Directive is deprecated. |
| `import 'ui/apply_filters'` | `import { applyFiltersPopover } from '../data/public'` | Directive is deprecated. |
| `import 'ui/filter_bar'` | `import { FilterBar } from '../data/public'` | Directive is deprecated. |
| `import 'ui/query_bar'` | `import { QueryBarInput } from '../data/public'` | Directives are deprecated. |
| `import 'ui/search_bar'` | `import { SearchBar } from '../data/public'` | Directive is deprecated. |

View file

@ -29,10 +29,10 @@ import {
esFilters,
FilterManager,
TimefilterContract,
applyFiltersPopover,
changeTimeFilter,
extractTimeFilter,
} from '../../../../../../plugins/data/public';
import { applyFiltersPopover } from '../apply_filters/apply_filters_popover';
import { IndexPatternsStart } from '../../index_patterns';
export const GLOBAL_APPLY_FILTER_ACTION = 'GLOBAL_APPLY_FILTER_ACTION';

View file

@ -1,74 +0,0 @@
/*
* 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.
*/
import { EuiModal, EuiOverlayMask } from '@elastic/eui';
import React, { Component } from 'react';
import { ApplyFiltersPopoverContent } from './apply_filter_popover_content';
import { IndexPattern } from '../../index_patterns/index_patterns';
import { esFilters } from '../../../../../../plugins/data/public';
interface Props {
filters: esFilters.Filter[];
onCancel: () => void;
onSubmit: (filters: esFilters.Filter[]) => void;
indexPatterns: IndexPattern[];
}
interface State {
isFilterSelected: boolean[];
}
export class ApplyFiltersPopover extends Component<Props, State> {
public render() {
if (!this.props.filters || this.props.filters.length === 0) {
return '';
}
return (
<EuiOverlayMask>
<EuiModal onClose={this.props.onCancel}>
<ApplyFiltersPopoverContent
filters={this.props.filters}
onCancel={this.props.onCancel}
onSubmit={this.props.onSubmit}
indexPatterns={this.props.indexPatterns}
/>
</EuiModal>
</EuiOverlayMask>
);
}
}
type cancelFunction = () => void;
type submitFunction = (filters: esFilters.Filter[]) => void;
export const applyFiltersPopover = (
filters: esFilters.Filter[],
indexPatterns: IndexPattern[],
onCancel: cancelFunction,
onSubmit: submitFunction
) => {
return (
<ApplyFiltersPopoverContent
indexPatterns={indexPatterns}
filters={filters}
onCancel={onCancel}
onSubmit={onSubmit}
/>
);
};

View file

@ -29,7 +29,6 @@ export function plugin() {
/** @public types */
export { DataSetup, DataStart };
export { ApplyFiltersPopover } from './filter';
export {
Field,
FieldType,

View file

@ -30,17 +30,12 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { Component } from 'react';
import { IndexPattern } from '../../index_patterns';
import {
mapAndFlattenFilters,
esFilters,
utils,
FilterLabel,
} from '../../../../../../plugins/data/public';
import { mapAndFlattenFilters, esFilters, utils, IIndexPattern } from '../..';
import { FilterLabel } from '../filter_bar';
interface Props {
filters: esFilters.Filter[];
indexPatterns: IndexPattern[];
indexPatterns: IIndexPattern[];
onCancel: () => void;
onSubmit: (filters: esFilters.Filter[]) => void;
}

View file

@ -17,4 +17,25 @@
* under the License.
*/
export { ApplyFiltersPopover } from './apply_filters';
import React from 'react';
import { ApplyFiltersPopoverContent } from './apply_filter_popover_content';
import { IIndexPattern, esFilters } from '../..';
type CancelFnType = () => void;
type SubmitFnType = (filters: esFilters.Filter[]) => void;
export const applyFiltersPopover = (
filters: esFilters.Filter[],
indexPatterns: IIndexPattern[],
onCancel: CancelFnType,
onSubmit: SubmitFnType
) => {
return (
<ApplyFiltersPopoverContent
indexPatterns={indexPatterns}
filters={filters}
onCancel={onCancel}
onSubmit={onSubmit}
/>
);
};

View file

@ -17,4 +17,4 @@
* under the License.
*/
export { ApplyFiltersPopover } from './apply_filters_popover';
export { applyFiltersPopover } from './apply_filters_popover';

View file

@ -17,4 +17,5 @@
* under the License.
*/
export * from './filter_bar';
export { FilterBar } from './filter_bar';
export { applyFiltersPopover } from './apply_filters';