forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Search] Send to background UI (elastic#81793)
Also adds xpack.data_enhanced.search.sendToBackground.enabled config option
- Loading branch information
Showing
19 changed files
with
649 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
module.exports = require('@kbn/storybook').defaultConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { schema, TypeOf } from '@kbn/config-schema'; | ||
|
||
export const configSchema = schema.object({ | ||
search: schema.object({ | ||
sendToBackground: schema.object({ | ||
enabled: schema.boolean({ defaultValue: false }), | ||
}), | ||
}), | ||
}); | ||
|
||
export type ConfigSchema = TypeOf<typeof configSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export * from './ui'; |
23 changes: 23 additions & 0 deletions
23
..._enhanced/public/search/ui/background_session_indicator/background_session_indicator.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.backgroundSessionIndicator { | ||
padding: 0 $euiSizeXS; | ||
} | ||
|
||
@include euiBreakpoint('xs', 's') { | ||
.backgroundSessionIndicator__popoverContainer.euiFlexGroup--responsive .euiFlexItem { | ||
margin-bottom: $euiSizeXS !important; | ||
} | ||
} | ||
|
||
.backgroundSessionIndicator__verticalDivider { | ||
@include euiBreakpoint('xs', 's') { | ||
margin-left: $euiSizeXS; | ||
padding-left: $euiSizeXS; | ||
} | ||
|
||
@include euiBreakpoint('m', 'l', 'xl') { | ||
border-left: $euiBorderThin; | ||
align-self: stretch; | ||
margin-left: $euiSizeS; | ||
padding-left: $euiSizeS; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ed/public/search/ui/background_session_indicator/background_session_indicator.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { BackgroundSessionIndicator } from './background_session_indicator'; | ||
import { BackgroundSessionViewState } from '../connected_background_session_indicator'; | ||
|
||
storiesOf('components/BackgroundSessionIndicator', module).add('default', () => ( | ||
<> | ||
<div> | ||
<BackgroundSessionIndicator state={BackgroundSessionViewState.Loading} /> | ||
</div> | ||
<div> | ||
<BackgroundSessionIndicator state={BackgroundSessionViewState.Completed} /> | ||
</div> | ||
<div> | ||
<BackgroundSessionIndicator state={BackgroundSessionViewState.BackgroundLoading} /> | ||
</div> | ||
<div> | ||
<BackgroundSessionIndicator state={BackgroundSessionViewState.BackgroundCompleted} /> | ||
</div> | ||
<div> | ||
<BackgroundSessionIndicator state={BackgroundSessionViewState.Restored} /> | ||
</div> | ||
</> | ||
)); |
98 changes: 98 additions & 0 deletions
98
...anced/public/search/ui/background_session_indicator/background_session_indicator.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { ReactNode } from 'react'; | ||
import { screen, render } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { BackgroundSessionIndicator } from './background_session_indicator'; | ||
import { BackgroundSessionViewState } from '../connected_background_session_indicator'; | ||
import { IntlProvider } from 'react-intl'; | ||
|
||
function Container({ children }: { children?: ReactNode }) { | ||
return <IntlProvider locale="en">{children}</IntlProvider>; | ||
} | ||
|
||
test('Loading state', async () => { | ||
const onCancel = jest.fn(); | ||
render( | ||
<Container> | ||
<BackgroundSessionIndicator state={BackgroundSessionViewState.Loading} onCancel={onCancel} /> | ||
</Container> | ||
); | ||
|
||
await userEvent.click(screen.getByLabelText('Loading results')); | ||
await userEvent.click(screen.getByText('Cancel')); | ||
|
||
expect(onCancel).toBeCalled(); | ||
}); | ||
|
||
test('Completed state', async () => { | ||
const onSave = jest.fn(); | ||
render( | ||
<Container> | ||
<BackgroundSessionIndicator | ||
state={BackgroundSessionViewState.Completed} | ||
onSaveResults={onSave} | ||
/> | ||
</Container> | ||
); | ||
|
||
await userEvent.click(screen.getByLabelText('Results loaded')); | ||
await userEvent.click(screen.getByText('Save')); | ||
|
||
expect(onSave).toBeCalled(); | ||
}); | ||
|
||
test('Loading in the background state', async () => { | ||
const onCancel = jest.fn(); | ||
render( | ||
<Container> | ||
<BackgroundSessionIndicator | ||
state={BackgroundSessionViewState.BackgroundLoading} | ||
onCancel={onCancel} | ||
/> | ||
</Container> | ||
); | ||
|
||
await userEvent.click(screen.getByLabelText('Loading results in the background')); | ||
await userEvent.click(screen.getByText('Cancel')); | ||
|
||
expect(onCancel).toBeCalled(); | ||
}); | ||
|
||
test('BackgroundCompleted state', async () => { | ||
const onViewSession = jest.fn(); | ||
render( | ||
<Container> | ||
<BackgroundSessionIndicator | ||
state={BackgroundSessionViewState.BackgroundCompleted} | ||
onViewBackgroundSessions={onViewSession} | ||
/> | ||
</Container> | ||
); | ||
|
||
await userEvent.click(screen.getByLabelText('Results loaded in the background')); | ||
await userEvent.click(screen.getByText('View background sessions')); | ||
|
||
expect(onViewSession).toBeCalled(); | ||
}); | ||
|
||
test('Restored state', async () => { | ||
const onRefresh = jest.fn(); | ||
render( | ||
<Container> | ||
<BackgroundSessionIndicator | ||
state={BackgroundSessionViewState.Restored} | ||
onRefresh={onRefresh} | ||
/> | ||
</Container> | ||
); | ||
|
||
await userEvent.click(screen.getByLabelText('Results no longer current')); | ||
await userEvent.click(screen.getByText('Refresh')); | ||
|
||
expect(onRefresh).toBeCalled(); | ||
}); |
Oops, something went wrong.