Skip to content

Commit

Permalink
[Unified search] Create unified search plugin (#127651)
Browse files Browse the repository at this point in the history
* [Unified search] Create unified search plugin

* add unified_search into USES_STYLED_COMPONENTS

* fix JEST group 4

* update limits for data plugin

* fix: remove unifiedSearch plugin from x-pack/plugins/file_upload

* feat: updated .github/CODEOWNERS and set @elastic/kibana-app-services as a code owner

* apply PR comments

* [CI] Auto-commit changed files from 'node scripts/build_plugin_list_docs'

* feat: moved filter bar, apply filters folders and apply filter action from Data plugin to unified search plugin

* fix Checks

* fix Checks

* fix Linting and Default CI Group #16

* fix Checks

* fix Checks

* fix Linting (with types)

* fix show FILTER_BAR

* fix Jest Tests

* feat replece indexPatternsContranct in setIndexPatterns to DataViewsContract

* feat: removed unnecessary interface in unified search

* fix Checks

* fix Checks

* fix Jest Tests, Checks

* fix Checks

* resolve comments

Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 5, 2022
1 parent 9b85ae9 commit 3e2761d
Show file tree
Hide file tree
Showing 262 changed files with 1,467 additions and 1,058 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
/src/plugins/bfetch/ @elastic/kibana-app-services
/src/plugins/data_view_management/ @elastic/kibana-app-services
/src/plugins/inspector/ @elastic/kibana-app-services
/src/plugins/unified_search/ @elastic/kibana-app-services
/x-pack/examples/ui_actions_enhanced_examples/ @elastic/kibana-app-services
/x-pack/plugins/data_enhanced/ @elastic/kibana-app-services
/x-pack/plugins/embeddable_enhanced/ @elastic/kibana-app-services
Expand Down
3 changes: 2 additions & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"visTypeVega": "src/plugins/vis_types/vega",
"visTypeVislib": "src/plugins/vis_types/vislib",
"visTypeXy": "src/plugins/vis_types/xy",
"visualizations": "src/plugins/visualizations"
"visualizations": "src/plugins/visualizations",
"unifiedSearch": "src/plugins/unified_search"
},
"translations": []
}
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ In general this plugin provides:
- Exposing a context menu for the user to choose the appropriate action when there are multiple actions attached to a single trigger.
|{kib-repo}blob/{branch}/src/plugins/unified_search/README.md[unifiedSearch]
|Contains all the components of Kibana's unified search experience. Specifically:
|{kib-repo}blob/{branch}/src/plugins/url_forwarding/README.md[urlForwarding]
|This plugins contains helpers to redirect legacy URLs. It can be used to forward old URLs to their new counterparts.
Expand Down
2 changes: 1 addition & 1 deletion examples/search_examples/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"description": "Example plugin of how to use data plugin search services",
"server": true,
"ui": true,
"requiredPlugins": ["navigation", "data", "developerExamples", "kibanaUtils", "share"],
"requiredPlugins": ["navigation", "data", "developerExamples", "kibanaUtils", "share", "unifiedSearch"],
"optionalPlugins": [],
"requiredBundles": ["kibanaReact"],
"owner": {
Expand Down
4 changes: 3 additions & 1 deletion examples/search_examples/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const LINKS: ExampleLink[] = [

export const renderApp = (
{ notifications, savedObjects, http, application }: CoreStart,
{ data, navigation }: AppPluginStartDependencies,
{ data, navigation, unifiedSearch }: AppPluginStartDependencies,
{ element, history }: AppMountParameters
) => {
ReactDOM.render(
Expand All @@ -53,6 +53,7 @@ export const renderApp = (
navigation={navigation}
data={data}
http={http}
unifiedSearch={unifiedSearch}
/>
</Route>
<Route path={LINKS[1].path}>
Expand All @@ -63,6 +64,7 @@ export const renderApp = (
navigation={navigation}
notifications={notifications}
data={data}
unifiedSearch={unifiedSearch}
/>
</Route>

Expand Down
5 changes: 4 additions & 1 deletion examples/search_examples/public/search/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
isCompleteResponse,
isErrorResponse,
} from '../../../../src/plugins/data/public';
import { UnifiedSearchPublicPluginStart } from '../../../../src/plugins/unified_search/public';
import type { DataViewField, DataView } from '../../../../src/plugins/data_views/public';
import { IMyStrategyResponse } from '../../common/types';
import { AbortError } from '../../../../src/plugins/kibana_utils/common';
Expand All @@ -53,6 +54,7 @@ interface SearchExamplesAppDeps {
http: CoreStart['http'];
navigation: NavigationPublicPluginStart;
data: DataPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
}

function getNumeric(fields?: DataViewField[]) {
Expand Down Expand Up @@ -85,8 +87,9 @@ export const SearchExamplesApp = ({
notifications,
navigation,
data,
unifiedSearch,
}: SearchExamplesAppDeps) => {
const { IndexPatternSelect } = data.ui;
const { IndexPatternSelect } = unifiedSearch.ui;
const [getCool, setGetCool] = useState<boolean>(false);
const [fibonacciN, setFibonacciN] = useState<number>(10);
const [timeTook, setTimeTook] = useState<number | undefined>();
Expand Down
5 changes: 4 additions & 1 deletion examples/search_examples/public/search_sessions/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
SearchSessionState,
TimeRange,
} from '../../../../src/plugins/data/public';
import { UnifiedSearchPublicPluginStart } from '../../../../src/plugins/unified_search/public';
import type { DataView, DataViewField } from '../../../../src/plugins/data_views/public';
import {
createStateContainer,
Expand All @@ -60,6 +61,7 @@ interface SearchSessionsExampleAppDeps {
notifications: CoreStart['notifications'];
navigation: NavigationPublicPluginStart;
data: DataPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
}

/**
Expand Down Expand Up @@ -89,8 +91,9 @@ export const SearchSessionsExampleApp = ({
notifications,
navigation,
data,
unifiedSearch,
}: SearchSessionsExampleAppDeps) => {
const { IndexPatternSelect } = data.ui;
const { IndexPatternSelect } = unifiedSearch.ui;

const [isSearching, setIsSearching] = useState<boolean>(false);
const [request, setRequest] = useState<IEsSearchRequest | null>(null);
Expand Down
2 changes: 2 additions & 0 deletions examples/search_examples/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public';
import { DataPublicPluginStart } from '../../../src/plugins/data/public';
import { UnifiedSearchPublicPluginStart } from '../../../src/plugins/unified_search/public';
import { DeveloperExamplesSetup } from '../../developer_examples/public';
import { SharePluginSetup } from '../../../src/plugins/share/public';

Expand All @@ -24,4 +25,5 @@ export interface AppPluginSetupDependencies {
export interface AppPluginStartDependencies {
navigation: NavigationPublicPluginStart;
data: DataPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
}
2 changes: 1 addition & 1 deletion packages/kbn-babel-preset/styled_components_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
*/
USES_STYLED_COMPONENTS: [
/packages[\/\\]kbn-ui-shared-deps-(npm|src)[\/\\]/,
/src[\/\\]plugins[\/\\](data|kibana_react)[\/\\]/,
/src[\/\\]plugins[\/\\](unified_search|kibana_react)[\/\\]/,
/x-pack[\/\\]plugins[\/\\](apm|beats_management|cases|fleet|infra|lists|observability|osquery|security_solution|timelines|uptime|ux)[\/\\]/,
/x-pack[\/\\]test[\/\\]plugin_functional[\/\\]plugins[\/\\]resolver_test[\/\\]/,
],
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ pageLoadAssetSize:
visTypeMetric: 23332
bfetch: 22837
kibanaUtils: 79713
data: 491273
dataViews: 43532
expressions: 140958
fieldFormats: 65209
Expand All @@ -124,5 +123,7 @@ pageLoadAssetSize:
sessionView: 77750
cloudSecurityPosture: 19109
visTypeGauge: 24113
unifiedSearch: 49195
data: 454087
expressionXY: 26500
eventAnnotation: 19334
2 changes: 0 additions & 2 deletions src/plugins/data/public/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Side Public License, v 1.
*/

export type { ApplyGlobalFilterActionContext } from './apply_filter_action';
export { ACTION_GLOBAL_APPLY_FILTER, createFilterAction } from './apply_filter_action';
export { createFiltersFromValueClickAction } from './filters/create_filters_from_value_click';
export { createFiltersFromRangeSelectAction } from './filters/create_filters_from_range_select';
export * from './select_range_action';
Expand Down
5 changes: 0 additions & 5 deletions src/plugins/data/public/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ import {
getEsQueryConfig,
} from '../common';

import { FilterLabel, FilterItem } from './ui';

import {
getDisplayValueFromFilter,
generateFilters,
Expand Down Expand Up @@ -90,9 +88,6 @@ const convertRangeFilterToTimeRangeString = oldConvertRangeFilterToTimeRangeStri
* @removeBy 8.1
*/
export const esFilters = {
FilterLabel,
FilterItem,

FILTERS,
FilterStateStore,

Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/public/index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
@import './ui/index';
@import './utils/table_inspector_view/index';
18 changes: 5 additions & 13 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export * from './deprecated';
*/

export { getEsQueryConfig, FilterStateStore } from '../common';
export { FilterLabel, FilterItem } from './ui';
export {
getDisplayValueFromFilter,
generateFilters,
Expand Down Expand Up @@ -259,15 +258,6 @@ export const search = {
* UI components
*/

export type {
SearchBarProps,
StatefulSearchBarProps,
IndexPatternSelectProps,
QueryStringInputProps,
} from './ui';

export { QueryStringInput, SearchBar } from './ui';

/**
* Types to be shared externally
* @public
Expand All @@ -281,6 +271,8 @@ export {
getDefaultQuery,
FilterManager,
TimeHistory,
getQueryLog,
mapAndFlattenFilters,
} from './query';

export type {
Expand All @@ -293,6 +285,9 @@ export type {
QueryStateChange,
QueryStart,
AutoRefreshDoneFn,
PersistedLog,
QueryStringContract,
QuerySetup,
} from './query';

export type { AggsStart } from './search/aggs';
Expand All @@ -303,8 +298,6 @@ export type { SavedObject } from '../common';

export { isTimeRange, isQuery, flattenHit, calculateBounds, tabifyAggResponse } from '../common';

export type { ApplyGlobalFilterActionContext } from './actions';
export { ACTION_GLOBAL_APPLY_FILTER } from './actions';
export { APPLY_FILTER_TRIGGER } from './triggers';

/*
Expand All @@ -321,7 +314,6 @@ export type {
DataPublicPluginSetup,
DataPublicPluginStart,
IDataPluginServices,
DataPublicPluginStartUi,
DataPublicPluginStartActions,
} from './types';

Expand Down
4 changes: 0 additions & 4 deletions src/plugins/data/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ const createStartContract = (): Start => {
search: searchServiceMock.createStartContract(),
fieldFormats: fieldFormatsServiceMock.createStartContract(),
query: queryStartMock,
ui: {
IndexPatternSelect: jest.fn(),
SearchBar: jest.fn().mockReturnValue(null),
},
dataViews,
/**
* @deprecated Use dataViews service instead. All index pattern interfaces were renamed.
Expand Down
32 changes: 2 additions & 30 deletions src/plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import type {
import { AutocompleteService } from './autocomplete';
import { SearchService } from './search/search_service';
import { QueryService } from './query';
import { createIndexPatternSelect } from './ui/index_pattern_select';
import {
setIndexPatterns,
setNotifications,
Expand All @@ -29,17 +28,13 @@ import {
setUiSettings,
setTheme,
} from './services';
import { createSearchBar } from './ui/search_bar/create_search_bar';
import {
ACTION_GLOBAL_APPLY_FILTER,
createFilterAction,
createFiltersFromValueClickAction,
createFiltersFromRangeSelectAction,
createValueClickAction,
createSelectRangeAction,
} from './actions';
import { APPLY_FILTER_TRIGGER, applyFilterTrigger } from './triggers';
import { UsageCollectionSetup } from '../../usage_collection/public';
import { applyFilterTrigger } from './triggers';
import { getTableViewDescription } from './utils/table_inspector_view';
import { NowProvider, NowProviderInternalContract } from './now_provider';
import { getAggsFormats, DatatableUtilitiesService } from '../common';
Expand All @@ -57,7 +52,6 @@ export class DataPublicPlugin
private readonly searchService: SearchService;
private readonly queryService: QueryService;
private readonly storage: IStorageWrapper;
private usageCollection: UsageCollectionSetup | undefined;
private readonly nowProvider: NowProviderInternalContract;

constructor(initializerContext: PluginInitializerContext<ConfigSchema>) {
Expand All @@ -82,7 +76,6 @@ export class DataPublicPlugin
): DataPublicPluginSetup {
const startServices = createStartServicesGetter(core.getStartServices);

this.usageCollection = usageCollection;
setTheme(core.theme);

const searchService = this.searchService.setup(core, {
Expand All @@ -99,9 +92,6 @@ export class DataPublicPlugin
});

uiActions.registerTrigger(applyFilterTrigger);
uiActions.registerAction(
createFilterAction(queryService.filterManager, queryService.timefilter.timefilter, core.theme)
);

inspector.registerView(
getTableViewDescription(() => ({
Expand Down Expand Up @@ -161,11 +151,6 @@ export class DataPublicPlugin
}))
);

uiActions.addTriggerAction(
APPLY_FILTER_TRIGGER,
uiActions.getAction(ACTION_GLOBAL_APPLY_FILTER)
);

const datatableUtilities = new DatatableUtilitiesService(search.aggs, dataViews, fieldFormats);
const dataServices = {
actions: {
Expand All @@ -182,20 +167,7 @@ export class DataPublicPlugin
nowProvider: this.nowProvider,
};

const SearchBar = createSearchBar({
core,
data: dataServices,
storage: this.storage,
usageCollection: this.usageCollection,
});

return {
...dataServices,
ui: {
IndexPatternSelect: createIndexPatternSelect(dataViews),
SearchBar,
},
};
return dataServices;
}

public stop() {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/query/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export * from './timefilter';
export * from './saved_query';
export * from './persisted_log';
export * from './state_sync';
export type { QueryStringContract } from './query_string';
4 changes: 0 additions & 4 deletions src/plugins/data/public/query/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@
*/

export * from './add_to_query_log';
export * from './from_user';
export * from './get_default_query';
export * from './get_query_log';
export * from './match_pairs';
export * from './to_user';
export * from './to_user';
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/fetch/handle_response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiSpacer } from '@elastic/eui';
import { IKibanaSearchResponse } from 'src/plugins/data/common';
import { ShardFailureOpenModalButton } from '../../ui/shard_failure_modal';
import { ShardFailureOpenModalButton } from '../../shard_failure_modal';
import { ThemeServiceStart } from '../../../../../core/public';
import { toMountPoint } from '../../../../kibana_react/public';
import { getNotifications } from '../../services';
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data/public/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ export { handleResponse } from './fetch';
export type { SearchInterceptorDeps } from './search_interceptor';
export { SearchInterceptor } from './search_interceptor';
export * from './errors';

export { SearchService } from './search_service';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { setOverlays } from '../../services';
import { setOverlays } from '../services';
import { OverlayStart } from 'kibana/public';

export const openModal = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiButton, EuiTextAlign } from '@elastic/eui';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import { getOverlays } from '../../services';
import { ThemeServiceStart } from '../../../../../core/public';
import { toMountPoint } from '../../../../kibana_react/public';
import { getOverlays } from '../services';
import { ThemeServiceStart } from '../../../../core/public';
import { toMountPoint } from '../../../kibana_react/public';
import { ShardFailureModal } from './shard_failure_modal';
import { ShardFailureRequest } from './shard_failure_types';

Expand Down
Loading

0 comments on commit 3e2761d

Please sign in to comment.