Skip to content

Commit 769fa71

Browse files
authored
[Search] Send to background UI (#81793) (#83415)
Also adds xpack.data_enhanced.search.sendToBackground.enabled config option
1 parent 2238f5f commit 769fa71

File tree

19 files changed

+649
-7
lines changed

19 files changed

+649
-7
lines changed

src/dev/storybook/aliases.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const storybookAliases = {
2222
canvas: 'x-pack/plugins/canvas/storybook',
2323
codeeditor: 'src/plugins/kibana_react/public/code_editor/.storybook',
2424
dashboard_enhanced: 'x-pack/plugins/dashboard_enhanced/.storybook',
25+
data_enhanced: 'x-pack/plugins/data_enhanced/.storybook',
2526
embeddable: 'src/plugins/embeddable/.storybook',
2627
infra: 'x-pack/plugins/infra/.storybook',
2728
security_solution: 'x-pack/plugins/security_solution/.storybook',

src/plugins/data/common/search/session/mocks.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 { BehaviorSubject } from 'rxjs';
2021
import { ISessionService } from './types';
2122

2223
export function getSessionServiceMock(): jest.Mocked<ISessionService> {
@@ -25,6 +26,6 @@ export function getSessionServiceMock(): jest.Mocked<ISessionService> {
2526
start: jest.fn(),
2627
restore: jest.fn(),
2728
getSessionId: jest.fn(),
28-
getSession$: jest.fn(),
29+
getSession$: jest.fn(() => new BehaviorSubject(undefined).asObservable()),
2930
};
3031
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
module.exports = require('@kbn/storybook').defaultConfig;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { schema, TypeOf } from '@kbn/config-schema';
8+
9+
export const configSchema = schema.object({
10+
search: schema.object({
11+
sendToBackground: schema.object({
12+
enabled: schema.boolean({ defaultValue: false }),
13+
}),
14+
}),
15+
});
16+
17+
export type ConfigSchema = TypeOf<typeof configSchema>;

x-pack/plugins/data_enhanced/kibana.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
"optionalPlugins": ["kibanaUtils", "usageCollection"],
1313
"server": true,
1414
"ui": true,
15-
"requiredBundles": ["kibanaUtils"]
15+
"requiredBundles": ["kibanaUtils", "kibanaReact"]
1616
}

x-pack/plugins/data_enhanced/public/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { PluginInitializerContext } from 'kibana/public';
78
import { DataEnhancedPlugin, DataEnhancedSetup, DataEnhancedStart } from './plugin';
9+
import { ConfigSchema } from '../config';
810

9-
export const plugin = () => new DataEnhancedPlugin();
11+
export const plugin = (initializerContext: PluginInitializerContext<ConfigSchema>) =>
12+
new DataEnhancedPlugin(initializerContext);
1013

1114
export { DataEnhancedSetup, DataEnhancedStart };
1215

x-pack/plugins/data_enhanced/public/plugin.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
7+
import React from 'react';
8+
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/public';
89
import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../../src/plugins/data/public';
10+
911
import { setAutocompleteService } from './services';
1012
import { setupKqlQuerySuggestionProvider, KUERY_LANGUAGE_NAME } from './autocomplete';
11-
1213
import { EnhancedSearchInterceptor } from './search/search_interceptor';
14+
import { toMountPoint } from '../../../../src/plugins/kibana_react/public';
15+
import { createConnectedBackgroundSessionIndicator } from './search';
16+
import { ConfigSchema } from '../config';
1317

1418
export interface DataEnhancedSetupDependencies {
1519
data: DataPublicPluginSetup;
@@ -25,6 +29,8 @@ export class DataEnhancedPlugin
2529
implements Plugin<void, void, DataEnhancedSetupDependencies, DataEnhancedStartDependencies> {
2630
private enhancedSearchInterceptor!: EnhancedSearchInterceptor;
2731

32+
constructor(private initializerContext: PluginInitializerContext<ConfigSchema>) {}
33+
2834
public setup(
2935
core: CoreSetup<DataEnhancedStartDependencies>,
3036
{ data }: DataEnhancedSetupDependencies
@@ -52,6 +58,18 @@ export class DataEnhancedPlugin
5258

5359
public start(core: CoreStart, plugins: DataEnhancedStartDependencies) {
5460
setAutocompleteService(plugins.data.autocomplete);
61+
62+
if (this.initializerContext.config.get().search.sendToBackground.enabled) {
63+
core.chrome.setBreadcrumbsAppendExtension({
64+
content: toMountPoint(
65+
React.createElement(
66+
createConnectedBackgroundSessionIndicator({
67+
sessionService: plugins.data.search.session,
68+
})
69+
)
70+
),
71+
});
72+
}
5573
}
5674

5775
public stop() {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export * from './ui';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.backgroundSessionIndicator {
2+
padding: 0 $euiSizeXS;
3+
}
4+
5+
@include euiBreakpoint('xs', 's') {
6+
.backgroundSessionIndicator__popoverContainer.euiFlexGroup--responsive .euiFlexItem {
7+
margin-bottom: $euiSizeXS !important;
8+
}
9+
}
10+
11+
.backgroundSessionIndicator__verticalDivider {
12+
@include euiBreakpoint('xs', 's') {
13+
margin-left: $euiSizeXS;
14+
padding-left: $euiSizeXS;
15+
}
16+
17+
@include euiBreakpoint('m', 'l', 'xl') {
18+
border-left: $euiBorderThin;
19+
align-self: stretch;
20+
margin-left: $euiSizeS;
21+
padding-left: $euiSizeS;
22+
}
23+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import React from 'react';
8+
import { storiesOf } from '@storybook/react';
9+
import { BackgroundSessionIndicator } from './background_session_indicator';
10+
import { BackgroundSessionViewState } from '../connected_background_session_indicator';
11+
12+
storiesOf('components/BackgroundSessionIndicator', module).add('default', () => (
13+
<>
14+
<div>
15+
<BackgroundSessionIndicator state={BackgroundSessionViewState.Loading} />
16+
</div>
17+
<div>
18+
<BackgroundSessionIndicator state={BackgroundSessionViewState.Completed} />
19+
</div>
20+
<div>
21+
<BackgroundSessionIndicator state={BackgroundSessionViewState.BackgroundLoading} />
22+
</div>
23+
<div>
24+
<BackgroundSessionIndicator state={BackgroundSessionViewState.BackgroundCompleted} />
25+
</div>
26+
<div>
27+
<BackgroundSessionIndicator state={BackgroundSessionViewState.Restored} />
28+
</div>
29+
</>
30+
));

0 commit comments

Comments
 (0)