-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add query result and time to the query editor footer #7951
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aff6eac
add query result to the footer
abbyhu2000 ac754c4
fix unit test
abbyhu2000 4f94324
conditional language
abbyhu2000 2037abf
native language still use toast
abbyhu2000 d752f25
refactor to not use two states
abbyhu2000 430b2a7
address comments
abbyhu2000 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| feat: | ||
| - Add query result and time to the query editor footer ([#7951](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7951)) |
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
92 changes: 92 additions & 0 deletions
92
src/plugins/data/public/query/query_string/language_service/lib/query_result.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,92 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { i18n } from '@osd/i18n'; | ||
|
|
||
| import './_recent_query.scss'; | ||
| import { EuiButtonEmpty, EuiPopover, EuiText, EuiPopoverTitle } from '@elastic/eui'; | ||
|
|
||
| import React, { useState } from 'react'; | ||
|
|
||
| export enum ResultStatus { | ||
| UNINITIALIZED = 'uninitialized', | ||
| LOADING = 'loading', // initial data load | ||
| READY = 'ready', // results came back | ||
| NO_RESULTS = 'none', // no results came back | ||
| ERROR = 'error', // error occurred | ||
| } | ||
|
|
||
| export interface QueryStatus { | ||
| status: ResultStatus; | ||
| body?: { | ||
| error?: { | ||
| reason?: string; | ||
| details: string; | ||
| }; | ||
| statusCode?: number; | ||
| }; | ||
| elapsedMs?: number; | ||
| } | ||
|
|
||
| export function QueryResult(props: { queryStatus: QueryStatus }) { | ||
| const [isPopoverOpen, setPopover] = useState(false); | ||
| const onButtonClick = () => { | ||
| setPopover(!isPopoverOpen); | ||
| }; | ||
|
|
||
| if (props.queryStatus.status === ResultStatus.READY) { | ||
| return ( | ||
| <EuiButtonEmpty iconSide="left" iconType={'checkInCircleEmpty'} size="xs" onClick={() => {}}> | ||
| <EuiText size="xs" color="subdued"> | ||
| {props.queryStatus.elapsedMs | ||
| ? `Completed in ${props.queryStatus.elapsedMs} ms` | ||
| : 'Completed'} | ||
| </EuiText> | ||
| </EuiButtonEmpty> | ||
| ); | ||
| } | ||
|
|
||
| if (!props.queryStatus.body || !props.queryStatus.body.error) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <EuiPopover | ||
| button={ | ||
| <EuiButtonEmpty iconSide="left" iconType={'alert'} size="xs" onClick={onButtonClick}> | ||
| <EuiText size="xs" color="subdued"> | ||
| {'Error'} | ||
| </EuiText> | ||
| </EuiButtonEmpty> | ||
| } | ||
| isOpen={isPopoverOpen} | ||
| closePopover={() => setPopover(false)} | ||
| panelPaddingSize="s" | ||
| anchorPosition={'downRight'} | ||
| > | ||
| <EuiPopoverTitle>ERRORS</EuiPopoverTitle> | ||
| <div style={{ width: '250px' }}> | ||
| <EuiText size="s"> | ||
| <strong> | ||
| {i18n.translate('data.query.languageService.queryResults.reasons', { | ||
| defaultMessage: `Reasons:`, | ||
| })} | ||
| </strong> | ||
| {props.queryStatus.body.error.reason} | ||
| </EuiText> | ||
| <EuiText size="s"> | ||
| <p> | ||
| <strong> | ||
| {i18n.translate('data.query.languageService.queryResults.details', { | ||
| defaultMessage: `Details:`, | ||
| })} | ||
| </strong>{' '} | ||
| {props.queryStatus.body.error.details} | ||
| </p> | ||
| </EuiText> | ||
| </div> | ||
| </EuiPopover> | ||
| ); | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,11 @@ import { createPortal } from 'react-dom'; | |
| import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui'; | ||
| import { i18n } from '@osd/i18n'; | ||
| import { AppMountParameters } from '../../../../../../core/public'; | ||
| import { connectStorageToQueryState, opensearchFilters } from '../../../../../data/public'; | ||
| import { | ||
| connectStorageToQueryState, | ||
| opensearchFilters, | ||
| QueryStatus, | ||
| } from '../../../../../data/public'; | ||
| import { useOpenSearchDashboards } from '../../../../../opensearch_dashboards_react/public'; | ||
| import { PLUGIN_ID } from '../../../../common'; | ||
| import { DiscoverViewServices } from '../../../build_services'; | ||
|
|
@@ -21,6 +25,7 @@ import { useDispatch, setSavedQuery, useSelector } from '../../utils/state_manag | |
|
|
||
| import './discover_canvas.scss'; | ||
| import { TopNavMenuItemRenderType } from '../../../../../navigation/public'; | ||
| import { ResultStatus } from '../utils'; | ||
|
|
||
| export interface TopNavProps { | ||
| opts: { | ||
|
|
@@ -34,9 +39,10 @@ export interface TopNavProps { | |
|
|
||
| export const TopNav = ({ opts, showSaveQuery, isEnhancementsEnabled }: TopNavProps) => { | ||
| const { services } = useOpenSearchDashboards<DiscoverViewServices>(); | ||
| const { inspectorAdapters, savedSearch, indexPattern } = useDiscoverContext(); | ||
| const { data$, inspectorAdapters, savedSearch, indexPattern } = useDiscoverContext(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we only require do we think we should maybe just create a new observable that this listens to instead of subscribing to a lot of data in the top nav? |
||
| const [indexPatterns, setIndexPatterns] = useState<IndexPattern[] | undefined>(undefined); | ||
| const [screenTitle, setScreenTitle] = useState<string>(''); | ||
| const [queryStatus, setQueryStatus] = useState<QueryStatus>({ status: ResultStatus.READY }); | ||
| const state = useSelector((s) => s.discover); | ||
| const dispatch = useDispatch(); | ||
|
|
||
|
|
@@ -69,6 +75,16 @@ export const TopNav = ({ opts, showSaveQuery, isEnhancementsEnabled }: TopNavPro | |
| uiSettings | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| const subscription = data$.subscribe((queryData) => { | ||
| const result = { | ||
| status: queryData.status, | ||
| ...queryData.queryStatus, | ||
| }; | ||
| setQueryStatus(result); | ||
| }); | ||
abbyhu2000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, [data$]); | ||
|
|
||
| useEffect(() => { | ||
| let isMounted = true; | ||
| const initializeDataset = async () => { | ||
|
|
@@ -160,6 +176,7 @@ export const TopNav = ({ opts, showSaveQuery, isEnhancementsEnabled }: TopNavPro | |
| datePickerRef={opts?.optionalRef?.datePickerRef} | ||
| groupActions={showActionsInGroup} | ||
| screenTitle={screenTitle} | ||
| queryStatus={queryStatus} | ||
| /> | ||
| </> | ||
| ); | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ | |
|
|
||
| export * from './canvas'; | ||
| export * from './panel'; | ||
| export * from './utils'; | ||
6 changes: 6 additions & 0 deletions
6
src/plugins/discover/public/application/view_components/utils/index.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,6 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| export { SearchData, ResultStatus } from './use_search'; |
Oops, something went wrong.
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.