-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Move search bar and query bar to data plugin #35300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d0b68fc
68a9714
78017a6
f12314d
caee10e
90b0875
1d07044
867a210
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| @import 'src/legacy/ui/public/styles/styling_constants'; | ||
|
|
||
| @import './query_bar/index'; | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,22 +18,32 @@ | |
| */ | ||
|
|
||
| import { IndexPatternsService } from './index_patterns'; | ||
| import { SearchBarService } from './search_bar'; | ||
| import { QueryBarService } from './query_bar'; | ||
|
|
||
| class DataService { | ||
| private readonly indexPatterns: IndexPatternsService; | ||
| private readonly searchBar: SearchBarService; | ||
| private readonly queryBar: QueryBarService; | ||
|
|
||
| constructor() { | ||
| this.indexPatterns = new IndexPatternsService(); | ||
| this.searchBar = new SearchBarService(); | ||
| this.queryBar = new QueryBarService(); | ||
| } | ||
|
|
||
| public setup() { | ||
| return { | ||
| indexPatterns: this.indexPatterns.setup(), | ||
| ...this.searchBar.setup(), | ||
| ...this.queryBar.setup(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have clear namespaces in the contract to make it clear what services own what methods: search: this.searchBar.setup(),
query: this.queryBar.setup(),This would prevent confusion for users because instead of importing like this: import { data } from 'plugins/data';
const { toUser, fromUser } = data.helpers; // helpers for what?They could instead do: import { data } from 'plugins/data';
const { toUser, fromUser } = data.queryBar.helpers;And if we are concerned about a dev's experience in having to destructure services just to get a React component, we could create a // plugins/data/public/components.ts
export { QueryBar } from './query_bar/components/query_bar';
export { SearchBar } from './search_bar/components/search_bar';
// plugins/foo-plugin/public/setup.ts
import { QueryBar, SearchBar } from 'plugins/data/components'; |
||
| }; | ||
| } | ||
|
|
||
| public stop() { | ||
| this.indexPatterns.stop(); | ||
| this.searchBar.stop(); | ||
| this.queryBar.stop(); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -43,7 +53,8 @@ class DataService { | |
| * the data that will eventually be injected by the new platform. | ||
| */ | ||
| // eslint-disable-next-line import/no-default-export | ||
| export default new DataService().setup(); | ||
| const data = new DataService().setup(); | ||
| export { data }; | ||
lizozom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** @public */ | ||
| export type DataSetup = ReturnType<DataService['setup']>; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,18 +21,20 @@ | |
|
|
||
| import 'ngreact'; | ||
| import { wrapInI18nContext } from 'ui/i18n'; | ||
| import { uiModules } from '../../modules'; | ||
| import { uiModules } from 'ui/modules'; | ||
| import { QueryBar } from '../components'; | ||
|
|
||
| const app = uiModules.get('app/kibana', ['react']); | ||
| const app = uiModules.get('app/data', ['react']); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know a lot about we probably also don't need
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure it's worth investing time into angular code that will be removed soon anyway. What do you think?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess what I meant was, will it make it easier to remove angular code later if it is scoped more granularly now, especially since we are already changing these names now? Definitely not worth investing the time if it won't help us later -- I was only suggesting it if you think it will save us time trying to figure out what's up with all of the various |
||
|
|
||
| app.directive('queryBar', (reactDirective, localStorage) => { | ||
| return reactDirective( | ||
| wrapInI18nContext(QueryBar), | ||
| undefined, | ||
| {}, | ||
| { | ||
| store: localStorage, | ||
| } | ||
| ); | ||
| }); | ||
| export function setupDirective() { | ||
| app.directive('queryBar', (reactDirective, localStorage) => { | ||
| return reactDirective( | ||
| wrapInI18nContext(QueryBar), | ||
| undefined, | ||
| {}, | ||
| { | ||
| store: localStorage, | ||
| } | ||
| ); | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * 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 { QueryBar } from './components/query_bar'; | ||
| import { fromUser } from './lib/from_user'; | ||
| import { toUser } from './lib/to_user'; | ||
|
|
||
| // @ts-ignore | ||
| import { setupDirective } from './directive'; | ||
|
|
||
| /** | ||
| * Search Bar Service | ||
lizozom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * | ||
| * @internal | ||
| */ | ||
| export class QueryBarService { | ||
| public setup() { | ||
| setupDirective(); | ||
| return { | ||
| helpers: { | ||
| fromUser, | ||
| toUser, | ||
| }, | ||
| QueryBar, | ||
| }; | ||
| } | ||
|
|
||
| public stop() { | ||
| // nothing to do here yet | ||
| } | ||
| } | ||
|
|
||
| /** @public */ | ||
| export type QueryBarSetup = ReturnType<QueryBarService['setup']>; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * 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 { SearchBar } from './components/search_bar'; | ||
|
|
||
| // @ts-ignore | ||
| import { setupDirective } from './directive'; | ||
|
|
||
| /** | ||
| * Search Bar Service | ||
| * | ||
| * @internal | ||
| */ | ||
| export class SearchBarService { | ||
| public setup() { | ||
| setupDirective(); | ||
| return { | ||
| SearchBar, | ||
| }; | ||
| } | ||
|
|
||
| public stop() { | ||
| // nothing to do here yet | ||
| } | ||
| } | ||
|
|
||
| /** @public */ | ||
| export type SearchBarSetup = ReturnType<SearchBarService['setup']>; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,6 @@ import { wrapInI18nContext } from 'ui/i18n'; | |
| import { toastNotifications } from 'ui/notify'; | ||
|
|
||
| import 'ui/listen'; | ||
| import 'ui/search_bar'; | ||
| import 'ui/apply_filters'; | ||
|
|
||
| import { panelActionsStore } from './store/panel_actions_store'; | ||
|
|
@@ -59,6 +58,8 @@ import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing'; | |
|
|
||
| import { DashboardViewportProvider } from './viewport/dashboard_viewport_provider'; | ||
|
|
||
| import 'plugins/data'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I assume these imports are here because this code needs the directives that are wrapped in In making this change we are losing the context that Thinking out loud; what if, instead of calling // search_bar_service.ts
setup() {
return {
SearchBar,
loadLegacyDirectives: _.once(setupDirective)
}
}
// dashboard_app.js
import { data } from 'plugins/data';
data.search.loadLegacyDirectives();The first module that calls There are other ways we could go about this too -- I am mostly interested in what you think about how we can make these dependencies more explicit.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was also bothered by the implicit import here. However, there are going to be multiple loadLegacyDirectives in many files.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that would work too - the only downside I can think of is that by making the services implicit, we'll just have to reverse-engineer all references to If we are already doing the work today of pulling directives into specific services and updating downstream imports, keeping everything explicit might save us from more work later (avoiding an "autoload" type situation where you don't know what a module's true dependencies are). But I'd defer to you on this -- you've spent much more time dealing with various legacy angular directives at this point 😃
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found a nice (and necessary) middle ground, which you can see in the filter bar PR |
||
|
|
||
| const app = uiModules.get('app/dashboard', [ | ||
| 'elasticsearch', | ||
| 'ngRoute', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.