Skip to content

Commit 924b230

Browse files
authored
Move search bar into data plugin (#35389)
* Moved filter bar to data plugin (still not working) * Moved filter options from search bar into filter bar
1 parent c870f67 commit 924b230

File tree

16 files changed

+131
-75
lines changed

16 files changed

+131
-75
lines changed

src/legacy/core_plugins/data/public/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,32 @@
1717
* under the License.
1818
*/
1919

20+
import { SearchBarService } from './search_bar';
2021
import { QueryBarService } from './query_bar';
2122
import { IndexPatternsService, IndexPatternsSetup } from './index_patterns';
2223

2324
class DataPlugin {
2425
private readonly indexPatterns: IndexPatternsService;
26+
private readonly searchBar: SearchBarService;
2527
private readonly queryBar: QueryBarService;
2628

2729
constructor() {
2830
this.indexPatterns = new IndexPatternsService();
2931
this.queryBar = new QueryBarService();
32+
this.searchBar = new SearchBarService();
3033
}
3134

3235
public setup() {
3336
return {
3437
indexPatterns: this.indexPatterns.setup(),
38+
search: this.searchBar.setup(),
3539
query: this.queryBar.setup(),
3640
};
3741
}
3842

3943
public stop() {
4044
this.indexPatterns.stop();
45+
this.searchBar.stop();
4146
this.queryBar.stop();
4247
}
4348
}

src/legacy/core_plugins/data/public/index_patterns/index_patterns_service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import setupRouteWithDefaultPattern from 'ui/index_patterns/route_setup/load_def
5151
import { getFromSavedObject, isFilterable } from 'ui/index_patterns/static_utils';
5252

5353
// IndexPattern, StaticIndexPattern, StaticIndexPatternField, Field
54-
5554
import * as types from 'ui/index_patterns';
5655

5756
/**

src/legacy/core_plugins/data/public/query_bar/query_bar_service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* under the License.
1818
*/
1919

20+
import { once } from 'lodash';
2021
import { QueryBar } from './components/query_bar';
2122
import { fromUser } from './lib/from_user';
2223
import { toUser } from './lib/to_user';
@@ -32,7 +33,7 @@ import { setupDirective } from './directive';
3233
export class QueryBarService {
3334
public setup() {
3435
return {
35-
loadLegacyDirectives: _.once(setupDirective),
36+
loadLegacyDirectives: once(setupDirective),
3637
helpers: {
3738
fromUser,
3839
toUser,

src/legacy/ui/public/search_bar/components/search_bar.tsx renamed to src/legacy/core_plugins/data/public/search_bar/components/search_bar.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ import { FilterBar } from 'ui/filter_bar';
2828
import { IndexPattern } from 'ui/index_patterns';
2929
import { Storage } from 'ui/storage';
3030

31-
import { data } from 'plugins/data';
32-
const { QueryBar } = data.query.ui;
31+
import { QueryBar } from '../../query_bar';
3332

3433
interface Query {
3534
query: string;
@@ -124,16 +123,16 @@ class SearchBarUI extends Component<Props, State> {
124123

125124
public render() {
126125
const filtersAppliedText = this.props.intl.formatMessage({
127-
id: 'common.ui.searchBar.filtersButtonFiltersAppliedTitle',
126+
id: 'data.search.searchBar.filtersButtonFiltersAppliedTitle',
128127
defaultMessage: 'filters applied.',
129128
});
130129
const clickToShowOrHideText = this.state.isFiltersVisible
131130
? this.props.intl.formatMessage({
132-
id: 'common.ui.searchBar.filtersButtonClickToShowTitle',
131+
id: 'data.search.searchBar.filtersButtonClickToShowTitle',
133132
defaultMessage: 'Select to hide',
134133
})
135134
: this.props.intl.formatMessage({
136-
id: 'common.ui.searchBar.filtersButtonClickToHideTitle',
135+
id: 'data.search.searchBar.filtersButtonClickToHideTitle',
137136
defaultMessage: 'Select to show',
138137
});
139138

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import 'ngreact';
21+
import { wrapInI18nContext } from 'ui/i18n';
22+
import { uiModules } from 'ui/modules';
23+
import { SearchBar } from '../components';
24+
25+
const app = uiModules.get('app/data', ['react']);
26+
27+
export function setupDirective() {
28+
app.directive('searchBar', (reactDirective, localStorage) => {
29+
return reactDirective(
30+
wrapInI18nContext(SearchBar),
31+
[
32+
['query', { watchDepth: 'reference' }],
33+
['store', { watchDepth: 'reference' }],
34+
['intl', { watchDepth: 'reference' }],
35+
36+
['onQuerySubmit', { watchDepth: 'reference' }],
37+
['onFiltersUpdated', { watchDepth: 'reference' }],
38+
['onRefreshChange', { watchDepth: 'reference' }],
39+
40+
['indexPatterns', { watchDepth: 'collection' }],
41+
['filters', { watchDepth: 'collection' }],
42+
43+
'appName',
44+
'screenTitle',
45+
'showFilterBar',
46+
'showQueryBar',
47+
'showDatePicker',
48+
'dateRangeFrom',
49+
'dateRangeTo',
50+
'isRefreshPaused',
51+
'refreshInterval',
52+
'disableAutoFocus',
53+
'showAutoRefreshOnly',
54+
],
55+
{},
56+
{
57+
store: localStorage,
58+
},
59+
);
60+
});
61+
}

src/legacy/ui/public/search_bar/index.tsx renamed to src/legacy/core_plugins/data/public/search_bar/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@
1717
* under the License.
1818
*/
1919

20-
import './directive';
21-
22-
export { SearchBar } from './components';
20+
export { SearchBarService } from './search_bar_service';
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { once } from 'lodash';
21+
import { SearchBar } from './components/search_bar';
22+
23+
// @ts-ignore
24+
import { setupDirective } from './directive';
25+
26+
/**
27+
* Search Bar Service
28+
* @internal
29+
*/
30+
export class SearchBarService {
31+
public setup() {
32+
return {
33+
ui: {
34+
SearchBar,
35+
},
36+
loadLegacyDirectives: once(setupDirective),
37+
};
38+
}
39+
40+
public stop() {
41+
// nothing to do here yet
42+
}
43+
}
44+
45+
/** @public */
46+
export type SearchBarSetup = ReturnType<SearchBarService['setup']>;

src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { wrapInI18nContext } from 'ui/i18n';
2626
import { toastNotifications } from 'ui/notify';
2727

2828
import 'ui/listen';
29-
import 'ui/search_bar';
3029
import 'ui/apply_filters';
3130

3231
import { panelActionsStore } from './store/panel_actions_store';
@@ -59,6 +58,9 @@ import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing';
5958

6059
import { DashboardViewportProvider } from './viewport/dashboard_viewport_provider';
6160

61+
import { data } from 'plugins/data';
62+
data.search.loadLegacyDirectives();
63+
6264
const app = uiModules.get('app/dashboard', [
6365
'elasticsearch',
6466
'ngRoute',

src/legacy/core_plugins/kibana/public/discover/controllers/discover.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import 'ui/fixed_scroll';
3636
import 'ui/index_patterns';
3737
import 'ui/state_management/app_state';
3838
import { timefilter } from 'ui/timefilter';
39-
import 'ui/search_bar';
4039
import { hasSearchStategyForIndexPattern, isDefaultTypeIndexPattern } from 'ui/courier';
4140
import { toastNotifications } from 'ui/notify';
4241
import { VisProvider } from 'ui/vis';
@@ -70,6 +69,9 @@ import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../breadcrumbs';
7069
import { buildVislibDimensions } from 'ui/visualize/loader/pipeline_helpers/build_pipeline';
7170
import 'ui/capabilities/route_setup';
7271

72+
import { data } from 'plugins/data';
73+
data.search.loadLegacyDirectives();
74+
7375
const fetchStatuses = {
7476
UNINITIALIZED: 'uninitialized',
7577
LOADING: 'loading',

0 commit comments

Comments
 (0)