Skip to content

Commit

Permalink
Move SearchBar back to data plugin. (#42449) (#42492)
Browse files Browse the repository at this point in the history
Restored an empty service for Saved Queries to use
  • Loading branch information
Liza Katz authored Aug 2, 2019
1 parent 2c8efa4 commit 27a04dc
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export {
} from './index_patterns';
export { Query, QueryBar, QueryBarInput } from './query';
export { FilterBar, ApplyFiltersPopover } from './filter';
export { SearchBar, SearchBarProps } from './search';
export {
FilterManager,
FilterStateManager,
Expand Down
5 changes: 5 additions & 0 deletions src/legacy/core_plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { CoreSetup, CoreStart, Plugin } from '../../../../core/public';
import { ExpressionsService, ExpressionsSetup } from './expressions';
import { SearchService, SearchSetup } from './search';
import { QueryService, QuerySetup } from './query';
import { FilterService, FilterSetup } from './filter';
import { IndexPatternsService, IndexPatternsSetup } from './index_patterns';
Expand All @@ -44,6 +45,7 @@ export interface DataSetup {
indexPatterns: IndexPatternsSetup;
filter: FilterSetup;
query: QuerySetup;
search: SearchSetup;
}

/**
Expand All @@ -63,6 +65,7 @@ export class DataPlugin implements Plugin<DataSetup, void, DataPluginSetupDepend
private readonly filter: FilterService = new FilterService();
private readonly indexPatterns: IndexPatternsService = new IndexPatternsService();
private readonly query: QueryService = new QueryService();
private readonly search: SearchService = new SearchService();

public setup(core: CoreSetup, { __LEGACY, interpreter }: DataPluginSetupDependencies): DataSetup {
const indexPatternsService = this.indexPatterns.setup();
Expand All @@ -75,6 +78,7 @@ export class DataPlugin implements Plugin<DataSetup, void, DataPluginSetupDepend
indexPatterns: indexPatternsService.indexPatterns,
}),
query: this.query.setup(),
search: this.search.setup(),
};
}

Expand All @@ -85,5 +89,6 @@ export class DataPlugin implements Plugin<DataSetup, void, DataPluginSetupDepend
this.indexPatterns.stop();
this.filter.stop();
this.query.stop();
this.search.stop();
}
}
22 changes: 22 additions & 0 deletions src/legacy/core_plugins/data/public/search/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 { SearchService, SearchSetup } from './search_service';

export * from './search_bar';
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { SearchBar } from './search_bar';

jest.mock('../../../../data/public', () => {
jest.mock('../../../../../data/public', () => {
return {
FilterBar: () => <div className="filterBar"></div>,
QueryBar: () => <div className="queryBar"></div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import React, { Component } from 'react';
import ResizeObserver from 'resize-observer-polyfill';
import { Storage } from 'ui/storage';

import { IndexPattern, Query, QueryBar, FilterBar } from '../../../../data/public';
import { IndexPattern, Query, QueryBar, FilterBar } from '../../../../../data/public';

interface DateRange {
from: string;
Expand Down Expand Up @@ -111,7 +111,7 @@ class SearchBarUI extends Component<SearchBarProps, State> {
const filterCount = this.getFilterLength();
const filtersAppliedText = this.props.intl.formatMessage(
{
id: 'kibana_react.search.searchBar.filtersButtonFiltersAppliedTitle',
id: 'data.search.searchBar.searchBar.filtersButtonFiltersAppliedTitle',
defaultMessage:
'{filterCount} {filterCount, plural, one {filter} other {filters}} applied.',
},
Expand All @@ -121,11 +121,11 @@ class SearchBarUI extends Component<SearchBarProps, State> {
);
const clickToShowOrHideText = this.state.isFiltersVisible
? this.props.intl.formatMessage({
id: 'kibana_react.search.searchBar.filtersButtonClickToShowTitle',
id: 'data.search.searchBar.searchBar.filtersButtonClickToShowTitle',
defaultMessage: 'Select to hide',
})
: this.props.intl.formatMessage({
id: 'kibana_react.search.searchBar.filtersButtonClickToHideTitle',
id: 'data.search.searchBar.searchBar.filtersButtonClickToHideTitle',
defaultMessage: 'Select to show',
});

Expand All @@ -139,7 +139,7 @@ class SearchBarUI extends Component<SearchBarProps, State> {
aria-expanded={!!this.state.isFiltersVisible}
title={`${filterCount ? filtersAppliedText : ''} ${clickToShowOrHideText}`}
>
{i18n.translate('kibana_react.search.searchBar.filtersButtonLabel', {
{i18n.translate('data.search.searchBar.searchBar.filtersButtonLabel', {
defaultMessage: 'Filters',
description: 'The noun "filter" in plural.',
})}
Expand Down
35 changes: 35 additions & 0 deletions src/legacy/core_plugins/data/public/search/search_service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.
*/

/**
* Search Service
* @internal
*/

export class SearchService {
public setup() {
return {};
}

public stop() {}
}

/** @public */

export type SearchSetup = ReturnType<SearchService['setup']>;
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana_react/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@

/** @public types */
export { TopNavMenu, TopNavMenuData } from './top_nav_menu';
export { SearchBar, SearchBarProps } from './search_bar';
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { TopNavMenu } from './top_nav_menu';
import { TopNavMenuData } from './top_nav_menu_data';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';

jest.mock('../search_bar', () => {
jest.mock('../../../../core_plugins/data/public', () => {
return {
SearchBar: () => <div className="searchBar"></div>,
SearchBarProps: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { I18nProvider } from '@kbn/i18n/react';
import { TopNavMenuData } from './top_nav_menu_data';
import { TopNavMenuItem } from './top_nav_menu_item';
import { SearchBar, SearchBarProps } from '../search_bar';
import { SearchBar, SearchBarProps } from '../../../../core_plugins/data/public';

type Props = Partial<SearchBarProps> & {
name: string;
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,8 @@
"data.query.queryBar.syntaxOptionsDescription": "{docsLink} (KQL) は、シンプルなクエリ構文とスクリプトフィールドのサポートを提供します。また、KQL はベーシックライセンス以上をご利用の場合、自動入力も提供します。KQL をオフにすると、Kibana は Lucene を使用します。",
"data.query.queryBar.syntaxOptionsDescription.docsLinkText": "こちら",
"data.query.queryBar.syntaxOptionsTitle": "構文オプション",
"kibana_react.search.searchBar.filtersButtonClickToHideTitle": "選択して表示",
"kibana_react.search.searchBar.filtersButtonClickToShowTitle": "選択して非表示",
"data.search.searchBar.searchBar.filtersButtonClickToHideTitle": "選択して表示",
"data.search.searchBar.searchBar.filtersButtonClickToShowTitle": "選択して非表示",
"embeddableApi.actionPanel.title": "オプション",
"embeddableApi.actions.applyFilterActionTitle": "現在のビューにフィルターを適用",
"embeddableApi.addPanel.createNew": "新規 {factoryName} を作成",
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,8 @@
"data.query.queryBar.syntaxOptionsDescription": "{docsLink} (KQL) 提供简化查询语法并支持脚本字段。如果您具有基本许可或更高级别的许可,KQL 还提供自动填充功能。如果关闭 KQL,Kibana 将使用 Lucene。",
"data.query.queryBar.syntaxOptionsDescription.docsLinkText": "此处",
"data.query.queryBar.syntaxOptionsTitle": "语法选项",
"kibana_react.search.searchBar.filtersButtonClickToHideTitle": "选择以显示",
"kibana_react.search.searchBar.filtersButtonClickToShowTitle": "选择以隐藏",
"data.search.searchBar.searchBar.filtersButtonClickToHideTitle": "选择以显示",
"data.search.searchBar.searchBar.filtersButtonClickToShowTitle": "选择以隐藏",
"embeddableApi.actionPanel.title": "选项",
"embeddableApi.actions.applyFilterActionTitle": "将筛选应用于当前视图",
"embeddableApi.addPanel.createNew": "创建新的{factoryName}",
Expand Down

0 comments on commit 27a04dc

Please sign in to comment.