Skip to content

Commit

Permalink
Create a pre wired version of SearchBar (#46702)
Browse files Browse the repository at this point in the history
* Bind search bar

* create prewired data components

* Pass NP data plugin to shim plugin, to access autocomplete
Pass storage and autocomplete to createSearchBar method
Add appName and autocomplete to IDataPluginServices
QueryBarInput to consume autocomplete and appName from context
QueryBarTopRow to consume appName from context
Remove appName from SearchBar
Added AutocompletePublicPluginSetup and AutocompletePublicPluginStart types

* Use KibanaContextProvider in vis editor and graph

* Use KibanaContextProvider in maps

* Use prewirted SearchBar in TopNavMenu

* Use KibanaContextProbider in Lens

* Fix appName usage in query bar input

* fixed query bar top row appName

* update tests

* fixed bind search bar bug

* mock SearchBar

* Removed unnecessary mocks

* Delete unused mock

* Fixed exporting of data plugin types

* Updated maps snapshot

* Fixed some TS issues

* Fixed jest tests

* Context adjustments in TSVB

* componentWillMount

* Code review fixes

* Pass dataTestSubj to query bar input

* Graph data
  • Loading branch information
Liza Katz authored Oct 2, 2019
1 parent eab5553 commit 0cd9d6c
Show file tree
Hide file tree
Showing 39 changed files with 2,941 additions and 1,969 deletions.
5 changes: 4 additions & 1 deletion src/legacy/core_plugins/data/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ export const setup = dataPlugin.setup(npSetup.core, {
__LEGACY: legacyPlugin.setup(),
});

export const start = dataPlugin.start(npStart.core);
export const start = dataPlugin.start(npStart.core, {
data: npStart.plugins.data,
__LEGACY: legacyPlugin.start(),
});
46 changes: 42 additions & 4 deletions src/legacy/core_plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
*/

import { CoreSetup, CoreStart, Plugin } from '../../../../core/public';
import { SearchService, SearchSetup } from './search';
import { SearchService, SearchSetup, createSearchBar, StatetfulSearchBarProps } from './search';
import { QueryService, QuerySetup } from './query';
import { FilterService, FilterSetup } from './filter';
import { TimefilterService, TimefilterSetup } from './timefilter';
import { IndexPatternsService, IndexPatternsSetup } from './index_patterns';
import { LegacyDependenciesPluginSetup } from './shim/legacy_dependencies_plugin';
import {
LegacyDependenciesPluginSetup,
LegacyDependenciesPluginStart,
} from './shim/legacy_dependencies_plugin';
import { DataPublicPluginStart } from '../../../../plugins/data/public';

/**
* Interface for any dependencies on other plugins' `setup` contracts.
Expand All @@ -34,6 +38,11 @@ export interface DataPluginSetupDependencies {
__LEGACY: LegacyDependenciesPluginSetup;
}

export interface DataPluginStartDependencies {
data: DataPublicPluginStart;
__LEGACY: LegacyDependenciesPluginStart;
}

/**
* Interface for this plugin's returned `setup` contract.
*
Expand All @@ -47,6 +56,22 @@ export interface DataSetup {
timefilter: TimefilterSetup;
}

/**
* Interface for this plugin's returned `start` contract.
*
* @public
*/
export interface DataStart {
indexPatterns: IndexPatternsSetup;
filter: FilterSetup;
query: QuerySetup;
search: SearchSetup;
timefilter: TimefilterSetup;
ui: {
SearchBar: React.ComponentType<StatetfulSearchBarProps>;
};
}

/**
* Data Plugin - public
*
Expand All @@ -58,7 +83,9 @@ export interface DataSetup {
* in the setup/start interfaces. The remaining items exported here are either types,
* or static code.
*/
export class DataPlugin implements Plugin<DataSetup, {}, DataPluginSetupDependencies> {
export class DataPlugin
implements
Plugin<DataSetup, DataStart, DataPluginSetupDependencies, DataPluginStartDependencies> {
// Exposed services, sorted alphabetically
private readonly filter: FilterService = new FilterService();
private readonly indexPatterns: IndexPatternsService = new IndexPatternsService();
Expand Down Expand Up @@ -96,9 +123,20 @@ export class DataPlugin implements Plugin<DataSetup, {}, DataPluginSetupDependen
return this.setupApi;
}

public start(core: CoreStart) {
public start(core: CoreStart, { __LEGACY, data }: DataPluginStartDependencies) {
const SearchBar = createSearchBar({
core,
store: __LEGACY.storage,
timefilter: this.setupApi.timefilter,
filterManager: this.setupApi.filter.filterManager,
autocomplete: data.autocomplete,
});

return {
...this.setupApi!,
ui: {
SearchBar,
},
};
}

Expand Down
Loading

0 comments on commit 0cd9d6c

Please sign in to comment.