Move apply filters action to NP (#52156)
* move action * attach action in start * Remove uiActions from core_plugins/data * Don't export apply filters popup * import DataPublicPlugin after all other deps have loaded * lint * Remove unused import
This commit is contained in:
parent
3d36356cab
commit
43c55cf6a4
|
@ -1193,7 +1193,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'` | N/A. Replaced by triggering an APPLY_FILTER_TRIGGER trigger. | Directive is deprecated. |
|
||||
| `import 'ui/filter_bar'` | `import { FilterBar } from '../data/public'` | Directive is deprecated. |
|
||||
| `import 'ui/query_bar'` | `import { QueryStringInput } from '../data/public'` | Directives are deprecated. |
|
||||
| `import 'ui/search_bar'` | `import { SearchBar } from '../data/public'` | Directive is deprecated. |
|
||||
|
|
|
@ -43,5 +43,4 @@ export const setup = dataPlugin.setup(npSetup.core);
|
|||
|
||||
export const start = dataPlugin.start(npStart.core, {
|
||||
data: npStart.plugins.data,
|
||||
uiActions: npSetup.plugins.uiActions,
|
||||
});
|
||||
|
|
|
@ -22,19 +22,12 @@ import { createSearchBar, StatetfulSearchBarProps } from './search';
|
|||
import { Storage, IStorageWrapper } from '../../../../../src/plugins/kibana_utils/public';
|
||||
import { DataPublicPluginStart } from '../../../../plugins/data/public';
|
||||
import { initLegacyModule } from './shim/legacy_module';
|
||||
import { IUiActionsSetup } from '../../../../plugins/ui_actions/public';
|
||||
import {
|
||||
createFilterAction,
|
||||
GLOBAL_APPLY_FILTER_ACTION,
|
||||
} from './filter/action/apply_filter_action';
|
||||
import { APPLY_FILTER_TRIGGER } from '../../../../plugins/embeddable/public';
|
||||
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { setFieldFormats } from '../../../../plugins/data/public/services';
|
||||
|
||||
export interface DataPluginStartDependencies {
|
||||
data: DataPublicPluginStart;
|
||||
uiActions: IUiActionsSetup;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +60,7 @@ export class DataPlugin implements Plugin<void, DataStart, {}, DataPluginStartDe
|
|||
this.storage = new Storage(window.localStorage);
|
||||
}
|
||||
|
||||
public start(core: CoreStart, { data, uiActions }: DataPluginStartDependencies): DataStart {
|
||||
public start(core: CoreStart, { data }: DataPluginStartDependencies): DataStart {
|
||||
// This is required for when Angular code uses Field and FieldList.
|
||||
setFieldFormats(data.fieldFormats);
|
||||
initLegacyModule(data.indexPatterns);
|
||||
|
@ -78,17 +71,6 @@ export class DataPlugin implements Plugin<void, DataStart, {}, DataPluginStartDe
|
|||
storage: this.storage,
|
||||
});
|
||||
|
||||
uiActions.registerAction(
|
||||
createFilterAction(
|
||||
core.overlays,
|
||||
data.query.filterManager,
|
||||
data.query.timefilter.timefilter,
|
||||
data.indexPatterns
|
||||
)
|
||||
);
|
||||
|
||||
uiActions.attachAction(APPLY_FILTER_TRIGGER, GLOBAL_APPLY_FILTER_ACTION);
|
||||
|
||||
return {
|
||||
ui: {
|
||||
SearchBar,
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
"id": "data",
|
||||
"version": "kibana",
|
||||
"server": true,
|
||||
"ui": true
|
||||
"ui": true,
|
||||
"requiredPlugins": ["uiActions"]
|
||||
}
|
||||
|
|
|
@ -18,22 +18,17 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { CoreStart } from 'src/core/public';
|
||||
import { toMountPoint } from '../../../../../../plugins/kibana_react/public';
|
||||
import {
|
||||
IAction,
|
||||
createAction,
|
||||
IncompatibleActionError,
|
||||
} from '../../../../../../plugins/ui_actions/public';
|
||||
import { toMountPoint } from '../../../kibana_react/public';
|
||||
import { IAction, createAction, IncompatibleActionError } from '../../../ui_actions/public';
|
||||
import { getOverlays, getIndexPatterns } from '../services';
|
||||
import { applyFiltersPopover } from '../ui/apply_filters';
|
||||
import {
|
||||
esFilters,
|
||||
FilterManager,
|
||||
TimefilterContract,
|
||||
applyFiltersPopover,
|
||||
changeTimeFilter,
|
||||
extractTimeFilter,
|
||||
IndexPatternsContract,
|
||||
} from '../../../../../../plugins/data/public';
|
||||
} from '..';
|
||||
|
||||
export const GLOBAL_APPLY_FILTER_ACTION = 'GLOBAL_APPLY_FILTER_ACTION';
|
||||
|
||||
|
@ -47,10 +42,8 @@ async function isCompatible(context: ActionContext) {
|
|||
}
|
||||
|
||||
export function createFilterAction(
|
||||
overlays: CoreStart['overlays'],
|
||||
filterManager: FilterManager,
|
||||
timeFilter: TimefilterContract,
|
||||
indexPatternsService: IndexPatternsContract
|
||||
timeFilter: TimefilterContract
|
||||
): IAction<ActionContext> {
|
||||
return createAction<ActionContext>({
|
||||
type: GLOBAL_APPLY_FILTER_ACTION,
|
||||
|
@ -75,12 +68,12 @@ export function createFilterAction(
|
|||
if (selectedFilters.length > 1) {
|
||||
const indexPatterns = await Promise.all(
|
||||
filters.map(filter => {
|
||||
return indexPatternsService.get(filter.meta.index!);
|
||||
return getIndexPatterns().get(filter.meta.index!);
|
||||
})
|
||||
);
|
||||
|
||||
const filterSelectionPromise: Promise<esFilters.Filter[]> = new Promise(resolve => {
|
||||
const overlay = overlays.openModal(
|
||||
const overlay = getOverlays().openModal(
|
||||
toMountPoint(
|
||||
applyFiltersPopover(
|
||||
filters,
|
20
src/plugins/data/public/actions/index.ts
Normal file
20
src/plugins/data/public/actions/index.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* 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 { GLOBAL_APPLY_FILTER_ACTION, createFilterAction } from './apply_filter_action';
|
|
@ -18,14 +18,10 @@
|
|||
*/
|
||||
|
||||
import { PluginInitializerContext } from '../../../core/public';
|
||||
import { DataPublicPlugin } from './plugin';
|
||||
|
||||
export function plugin(initializerContext: PluginInitializerContext) {
|
||||
return new DataPublicPlugin(initializerContext);
|
||||
}
|
||||
|
||||
export { DataPublicPlugin as Plugin };
|
||||
|
||||
export * from '../common';
|
||||
|
||||
export * from './autocomplete_provider';
|
||||
|
@ -39,3 +35,7 @@ export * from './search';
|
|||
export * from './query';
|
||||
|
||||
export * from './ui';
|
||||
|
||||
// Export plugin after all other imports
|
||||
import { DataPublicPlugin } from './plugin';
|
||||
export { DataPublicPlugin as Plugin };
|
||||
|
|
|
@ -19,7 +19,12 @@
|
|||
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
|
||||
import { Storage } from '../../kibana_utils/public';
|
||||
import { DataPublicPluginSetup, DataPublicPluginStart } from './types';
|
||||
import {
|
||||
DataPublicPluginSetup,
|
||||
DataPublicPluginStart,
|
||||
DataSetupDependencies,
|
||||
DataStartDependencies,
|
||||
} from './types';
|
||||
import { AutocompleteProviderRegister } from './autocomplete_provider';
|
||||
import { getSuggestionsProvider } from './suggestions_provider';
|
||||
import { SearchService } from './search/search_service';
|
||||
|
@ -27,7 +32,9 @@ import { FieldFormatsService } from './field_formats_provider';
|
|||
import { QueryService } from './query';
|
||||
import { createIndexPatternSelect } from './ui/index_pattern_select';
|
||||
import { IndexPatterns } from './index_patterns';
|
||||
import { setNotifications, setFieldFormats } from './services';
|
||||
import { setNotifications, setFieldFormats, setOverlays, setIndexPatterns } from './services';
|
||||
import { createFilterAction, GLOBAL_APPLY_FILTER_ACTION } from './actions';
|
||||
import { APPLY_FILTER_TRIGGER } from '../../embeddable/public';
|
||||
|
||||
export class DataPublicPlugin implements Plugin<DataPublicPluginSetup, DataPublicPluginStart> {
|
||||
private readonly autocomplete = new AutocompleteProviderRegister();
|
||||
|
@ -41,27 +48,36 @@ export class DataPublicPlugin implements Plugin<DataPublicPluginSetup, DataPubli
|
|||
this.fieldFormatsService = new FieldFormatsService();
|
||||
}
|
||||
|
||||
public setup(core: CoreSetup): DataPublicPluginSetup {
|
||||
public setup(core: CoreSetup, { uiActions }: DataSetupDependencies): DataPublicPluginSetup {
|
||||
const storage = new Storage(window.localStorage);
|
||||
const queryService = this.queryService.setup({
|
||||
uiSettings: core.uiSettings,
|
||||
storage,
|
||||
});
|
||||
|
||||
uiActions.registerAction(
|
||||
createFilterAction(queryService.filterManager, queryService.timefilter.timefilter)
|
||||
);
|
||||
|
||||
return {
|
||||
autocomplete: this.autocomplete,
|
||||
search: this.searchService.setup(core),
|
||||
fieldFormats: this.fieldFormatsService.setup(core),
|
||||
query: this.queryService.setup({
|
||||
uiSettings: core.uiSettings,
|
||||
storage,
|
||||
}),
|
||||
query: queryService,
|
||||
};
|
||||
}
|
||||
|
||||
public start(core: CoreStart): DataPublicPluginStart {
|
||||
const { uiSettings, http, notifications, savedObjects } = core;
|
||||
public start(core: CoreStart, { uiActions }: DataStartDependencies): DataPublicPluginStart {
|
||||
const { uiSettings, http, notifications, savedObjects, overlays } = core;
|
||||
const fieldFormats = this.fieldFormatsService.start();
|
||||
setNotifications(notifications);
|
||||
setFieldFormats(fieldFormats);
|
||||
setOverlays(overlays);
|
||||
|
||||
const indexPatternsService = new IndexPatterns(uiSettings, savedObjects.client, http);
|
||||
setIndexPatterns(indexPatternsService);
|
||||
|
||||
uiActions.attachAction(APPLY_FILTER_TRIGGER, GLOBAL_APPLY_FILTER_ACTION);
|
||||
|
||||
return {
|
||||
autocomplete: this.autocomplete,
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
*/
|
||||
|
||||
import { NotificationsStart } from 'src/core/public';
|
||||
import { CoreStart } from 'kibana/public';
|
||||
import { FieldFormatsStart } from '.';
|
||||
import { createGetterSetter } from '../../kibana_utils/public';
|
||||
import { IndexPatternsContract } from './index_patterns';
|
||||
|
||||
export const [getNotifications, setNotifications] = createGetterSetter<NotificationsStart>(
|
||||
'Notifications'
|
||||
|
@ -28,3 +30,9 @@ export const [getNotifications, setNotifications] = createGetterSetter<Notificat
|
|||
export const [getFieldFormats, setFieldFormats] = createGetterSetter<FieldFormatsStart>(
|
||||
'FieldFormats'
|
||||
);
|
||||
|
||||
export const [getOverlays, setOverlays] = createGetterSetter<CoreStart['overlays']>('Overlays');
|
||||
|
||||
export const [getIndexPatterns, setIndexPatterns] = createGetterSetter<IndexPatternsContract>(
|
||||
'IndexPatterns'
|
||||
);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
import { CoreStart } from 'src/core/public';
|
||||
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
|
||||
import { IUiActionsSetup, IUiActionsStart } from 'src/plugins/ui_actions/public';
|
||||
import { AutocompletePublicPluginSetup, AutocompletePublicPluginStart } from '.';
|
||||
import { FieldFormatsSetup, FieldFormatsStart } from './field_formats_provider';
|
||||
import { ISearchSetup, ISearchStart } from './search';
|
||||
|
@ -27,6 +28,14 @@ import { QuerySetup, QueryStart } from './query';
|
|||
import { IndexPatternSelectProps } from './ui/index_pattern_select';
|
||||
import { IndexPatternsContract } from './index_patterns';
|
||||
|
||||
export interface DataSetupDependencies {
|
||||
uiActions: IUiActionsSetup;
|
||||
}
|
||||
|
||||
export interface DataStartDependencies {
|
||||
uiActions: IUiActionsStart;
|
||||
}
|
||||
|
||||
export interface DataPublicPluginSetup {
|
||||
autocomplete: AutocompletePublicPluginSetup;
|
||||
search: ISearchSetup;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
export { SuggestionsComponent } from './typeahead/suggestions_component';
|
||||
export { IndexPatternSelect } from './index_pattern_select';
|
||||
export { FilterBar } from './filter_bar';
|
||||
export { applyFiltersPopover } from './apply_filters';
|
||||
export { QueryStringInput } from './query_string_input/query_string_input';
|
||||
|
||||
// temp export - will be removed as final components are migrated to NP
|
||||
|
|
Loading…
Reference in a new issue