-
Notifications
You must be signed in to change notification settings - Fork 917
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add query result to the footer * fix unit test * conditional language * native language still use toast * refactor to not use two states * address comments --------- (cherry picked from commit 7e8612f) Signed-off-by: abbyhu2000 <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1c710f1
commit 9d5bf9a
Showing
26 changed files
with
215 additions
and
51 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
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 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
92 changes: 92 additions & 0 deletions
92
src/plugins/data/public/query/query_string/language_service/lib/query_result.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,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 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
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
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 |
---|---|---|
|
@@ -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 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.