Skip to content

Commit

Permalink
[2.x-manual-backport][Discover] Add Footer Bar for Single Line Editor (
Browse files Browse the repository at this point in the history
…#8565) (#8691)

* [2.x-manual-backport][Discover] Add Footer Bar for Single Line Editor (#8565)

Backport PR:
#8565

From the original PR:

* initial commit for single line editor footer

Signed-off-by: Sean Li <lnse@amazon.com>

* fixing styling and functionality

Signed-off-by: Sean Li <lnse@amazon.com>

* Changeset file for PR #8565 created/updated

* fixing bug with error not showing up in footer

Signed-off-by: Sean Li <lnse@amazon.com>

* fixing loading state thanks ashwinpc

Signed-off-by: Sean Li <lnse@amazon.com>

* trying to surface errors

Signed-off-by: Sean Li <lnse@amazon.com>

* adding new error for error state

Signed-off-by: Sean Li <lnse@amazon.com>

* Revert "fixing loading state thanks ashwinpc"

This reverts commit 64b5969.

* correctly passing async search strat errors

Signed-off-by: Sean Li <lnse@amazon.com>

---------

Signed-off-by: Sean Li <lnse@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

* fix snapshot

Signed-off-by: Anan Zhuang <ananzh@amazon.com>

---------

Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Anan Zhuang <ananzh@amazon.com>
Co-authored-by: Sean Li <lnse@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 23, 2024
1 parent d3e1f5d commit 10f15e5
Show file tree
Hide file tree
Showing 12 changed files with 251 additions and 101 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8565.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Adds editor footer to single line editor on focus ([#8565](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8565))
2 changes: 1 addition & 1 deletion src/plugins/data/common/data_frames/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export type IDataFrameResponse = SearchResponse<any> &
(IDataFrameDefaultResponse | IDataFramePollingResponse | IDataFrameErrorResponse);

export interface IDataFrameError extends SearchResponse<any> {
error: Error;
error: Error | string;
}

export interface PollQueryResultsParams {
Expand Down
7 changes: 1 addition & 6 deletions src/plugins/data/common/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* under the License.
*/

import { i18n } from '@osd/i18n';
import { PollQueryResultsHandler, FetchStatusResponse } from '../data_frames';

export interface QueryStatusOptions {
Expand All @@ -53,11 +52,7 @@ export const handleQueryResults = async <T>(
} while (queryStatus !== 'SUCCESS' && queryStatus !== 'FAILED');

if (queryStatus === 'FAILED') {
throw new Error(
i18n.translate('data.search.request.failed', {
defaultMessage: 'An error occurred while executing the search query',
})
);
throw new Error(queryResultsRes?.body.error);
}

return queryResultsRes;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
background-color: $euiColorLightestShade;
}
}

.editor_footerItem {
// Needed so the footer items never have paddings
padding: 0 !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ export interface QueryStatus {
status: ResultStatus;
body?: {
error?: {
reason?: string;
details: string;
statusCode?: number;
message?: string;
};
statusCode?: number;
};
elapsedMs?: number;
startTime?: number;
Expand Down Expand Up @@ -77,6 +76,22 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
</EuiButtonEmpty>
);
}
const time = Math.floor(elapsedTime / 1000);
return (
<EuiButtonEmpty
color="text"
size="xs"
onClick={() => {}}
isLoading
data-test-subj="queryResultLoading"
className="editor__footerItem"
>
{i18n.translate('data.query.languageService.queryResults.loadTime', {
defaultMessage: 'Loading {time} s',
values: { time },
})}
</EuiButtonEmpty>
);
}

if (props.queryStatus.status === ResultStatus.READY) {
Expand All @@ -101,7 +116,13 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
}

return (
<EuiButtonEmpty iconSide="left" iconType={'checkInCircleEmpty'} size="xs" onClick={() => {}}>
<EuiButtonEmpty
iconSide="left"
iconType={'checkInCircleEmpty'}
iconGap="s"
size="xs"
onClick={() => {}}
>
<EuiText size="xs" color="subdued" data-test-subj="queryResultCompleteMsg">
{message}
</EuiText>
Expand All @@ -122,8 +143,10 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
size="xs"
onClick={onButtonClick}
data-test-subj="queryResultErrorBtn"
className="editor__footerItem"
color="danger"
>
<EuiText size="xs" color="subdued">
<EuiText size="xs" color="danger" className="editor__footerItem">
{i18n.translate('data.query.languageService.queryResults.error', {
defaultMessage: `Error`,
})}
Expand All @@ -137,23 +160,15 @@ export function QueryResult(props: { queryStatus: QueryStatus }) {
data-test-subj="queryResultError"
>
<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>
<div style={{ width: '250px' }} className="eui-textBreakWord">
<EuiText size="s">
<p>
<strong>
{i18n.translate('data.query.languageService.queryResults.details', {
defaultMessage: `Details:`,
{i18n.translate('data.query.languageService.queryResults.message', {
defaultMessage: `Message:`,
})}
</strong>
{props.queryStatus.body.error.details}
</strong>{' '}
{props.queryStatus.body.error.message}
</p>
</EuiText>
</div>
Expand Down
37 changes: 37 additions & 0 deletions src/plugins/data/public/ui/query_editor/_query_editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,40 @@
display: block;
}
}

.queryEditor__footer {
display: flex;
gap: 4px;
background: $euiColorLightestShade;
padding: 2px 4px;
margin-top: 5px;
margin-left: -5px;
margin-right: -5px;
z-index: 1;
position: relative;
align-items: center;
}

.queryEditor__footerSpacer {
flex-grow: 1;
}

.queryEditor__footerItem {
// Needed so the footer items never have paddings
padding: 0 !important;
}

// TODO: Temporary workaround to disable padding for single line editor footer
.euiFormControlLayout--group.euiFormControlLayout--compressed .osdQuerEditor__singleLine .euiText {
padding-top: 0 !important;
padding-bottom: 0 !important;
}

.euiFormControlLayout--group .osdQuerEditor__singleLine .euiText {
background-color: unset !important;
line-height: 21px !important;
}

.euiFormControlLayout--group .osdQuerEditor__singleLine .euiButtonEmpty {
border-right: 0;
}
Loading

0 comments on commit 10f15e5

Please sign in to comment.