-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Search Sessions] added an info flyout to session management #90559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lizozom
merged 12 commits into
elastic:master
from
lizozom:sessions/session-info-in-mgmt
Feb 10, 2021
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
50ee222
added an info flyout to session management
9afe5f3
better filter serialization
91a79e0
Fix jest tests
e29c76b
jest
f451b05
Merge branch 'master' of github.com:elastic/kibana into sessions/sess…
5be1a59
Merge branch 'master' of github.com:elastic/kibana into sessions/sess…
2cc2815
display the originalState as a json object
8485f3e
code review
fd59d8b
Merge branch 'master' into sessions/session-info-in-mgmt
kibanamachine d00a26c
Merge branch 'master' of github.com:elastic/kibana into sessions/sess…
668f5dd
Text improvements
ae3d2ea
Merge branch 'sessions/session-info-in-mgmt' of github.com:lizozom/ki…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
160 changes: 160 additions & 0 deletions
160
x-pack/plugins/data_enhanced/public/search/sessions_mgmt/components/actions/info_button.tsx
This file contains hidden or 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,160 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { | ||
| EuiDescriptionList, | ||
| EuiFlyout, | ||
| EuiFlyoutBody, | ||
| EuiFlyoutHeader, | ||
| EuiPortal, | ||
| EuiSpacer, | ||
| EuiText, | ||
| EuiTitle, | ||
| } from '@elastic/eui'; | ||
| import { FormattedMessage } from '@kbn/i18n/react'; | ||
| import moment from 'moment'; | ||
| import React, { Component, Fragment } from 'react'; | ||
| import { Filter, Query, TimeRange } from 'src/plugins/data/public'; | ||
| import { UISession } from '../../types'; | ||
| import { TableText } from '../'; | ||
|
|
||
| interface Props { | ||
| searchSession: UISession; | ||
| } | ||
|
|
||
| interface State { | ||
| isLoading: boolean; | ||
| isFlyoutVisible: boolean; | ||
| calloutTitle: string; | ||
| error: Error | null; | ||
| } | ||
|
|
||
| export class InfoButton extends Component<Props, State> { | ||
| constructor(props: Props) { | ||
| super(props); | ||
|
|
||
| this.state = { | ||
| isLoading: false, | ||
| isFlyoutVisible: false, | ||
| calloutTitle: 'Search Session Info', | ||
| error: null, | ||
| }; | ||
|
|
||
| this.closeFlyout = this.closeFlyout.bind(this); | ||
| this.showFlyout = this.showFlyout.bind(this); | ||
| } | ||
|
|
||
| public renderInfo() { | ||
| const { error: err } = this.state; | ||
| if (err) { | ||
| return err.message; | ||
| } | ||
|
|
||
| const { created, id, initialState, restoreState } = this.props.searchSession; | ||
|
|
||
| const sessionInfo = [ | ||
| { | ||
| title: 'Search Session Id', | ||
| description: id, | ||
| }, | ||
| { | ||
| title: 'Created at', | ||
| description: moment(created).toLocaleString(), | ||
| }, | ||
| ]; | ||
|
|
||
| if (initialState.timeRange) { | ||
lizozom marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const initialTimerange = initialState.timeRange as TimeRange; | ||
| sessionInfo.push({ | ||
| title: 'Initial time range', | ||
| description: `${initialTimerange.from} - ${initialTimerange.to}`, | ||
| }); | ||
| } | ||
|
|
||
| if (restoreState.timeRange) { | ||
| const restoreTimerange = restoreState.timeRange as TimeRange; | ||
| sessionInfo.push({ | ||
| title: 'Actual time range', | ||
| description: `${restoreTimerange.from} - ${restoreTimerange.to}`, | ||
| }); | ||
| } | ||
|
|
||
| if (restoreState.query) { | ||
| const query = restoreState.query as Query; | ||
| sessionInfo.push({ | ||
| title: 'Query', | ||
| description: query.query ? `${query.query} (${query.language})` : 'N/A', | ||
| }); | ||
| } | ||
|
|
||
| if (restoreState.filters) { | ||
| const filters = restoreState.filters as Filter[]; | ||
| const filterText = filters.map((filter) => JSON.stringify(filter.query)).join('\n'); | ||
| sessionInfo.push({ | ||
| title: 'Filters', | ||
| description: filters && filters.length ? filterText : 'N/A', | ||
| }); | ||
| } | ||
|
|
||
| return ( | ||
| <Fragment> | ||
| <EuiDescriptionList listItems={sessionInfo} type="column" align="center" compressed /> | ||
| <EuiSpacer size="s" /> | ||
| </Fragment> | ||
| ); | ||
| } | ||
|
|
||
| public render() { | ||
| let flyout; | ||
|
|
||
| if (this.state.isFlyoutVisible) { | ||
| flyout = ( | ||
| <EuiPortal> | ||
| <EuiFlyout | ||
| ownFocus | ||
| onClose={this.closeFlyout} | ||
| size="s" | ||
| aria-labelledby="flyoutTitle" | ||
| data-test-subj="searchSessionsFlyout" | ||
| > | ||
| <EuiFlyoutHeader hasBorder> | ||
| <EuiTitle size="m"> | ||
| <h2 id="flyoutTitle">{this.state.calloutTitle}</h2> | ||
| </EuiTitle> | ||
| </EuiFlyoutHeader> | ||
| <EuiFlyoutBody> | ||
| <EuiText>{this.renderInfo()}</EuiText> | ||
| </EuiFlyoutBody> | ||
| </EuiFlyout> | ||
| </EuiPortal> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Fragment> | ||
| <TableText onClick={this.showFlyout}> | ||
| <FormattedMessage | ||
| id="xpack.data.mgmt.searchSessions.actionInfo" | ||
| aria-label="Show search session info" | ||
| defaultMessage="Info" | ||
lizozom marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /> | ||
| </TableText> | ||
| {flyout} | ||
| </Fragment> | ||
| ); | ||
| } | ||
|
|
||
| private closeFlyout = () => { | ||
| this.setState({ | ||
| isFlyoutVisible: false, | ||
| }); | ||
| }; | ||
|
|
||
| private showFlyout = () => { | ||
| this.setState({ isFlyoutVisible: true }); | ||
| }; | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.