Skip to content
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

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

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
} 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);

Check warning on line 55 in src/plugins/data/common/utils/helpers.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/common/utils/helpers.ts#L55

Added line #L55 was not covered by tests
}

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 @@
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 @@
</EuiButtonEmpty>
);
}
const time = Math.floor(elapsedTime / 1000);
return (

Check warning on line 80 in src/plugins/data/public/query/query_string/language_service/lib/query_result.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/language_service/lib/query_result.tsx#L79-L80

Added lines #L79 - L80 were not covered by tests
<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 @@
}

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 @@
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 @@
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
Loading