Skip to content

Commit

Permalink
Merge branch 'main' into saved-queries-new-UI
Browse files Browse the repository at this point in the history
  • Loading branch information
amsiglan authored Oct 24, 2024
2 parents 39f92ac + 9a25d0d commit 5a21c1d
Show file tree
Hide file tree
Showing 19 changed files with 346 additions and 163 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: 2 additions & 0 deletions changelogs/fragments/8693.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Update OTEL sample data description with compatible OS version ([#8693](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8693))
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { migrateLegacyQuery } from './migrate_legacy_query';
import { SearchSource, SearchSourceDependencies } from './search_source';
import { IndexPatternsContract } from '../../index_patterns/index_patterns';
import { SearchSourceFields } from './types';
import { DEFAULT_DATA } from '../../constants';

/**
* Deserializes a json string and a set of referenced objects to a `SearchSource` instance.
Expand All @@ -57,8 +58,13 @@ export const createSearchSource = (
const fields = { ...searchSourceFields };

// hydrating index pattern
if (fields.index && typeof fields.index === 'string') {
fields.index = await indexPatterns.get(searchSourceFields.index as any);
if (
fields.index &&
typeof fields.index === 'string' &&
(!fields.query?.dataset?.type ||
fields.query.dataset.type === DEFAULT_DATA.SET_TYPES.INDEX_PATTERN)
) {
fields.index = await indexPatterns.get(fields.index as string);
}

const searchSource = new SearchSource(fields, searchSourceDependencies);
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
2 changes: 0 additions & 2 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export {
DQLBody,
SingleLineInput,
DatasetSelector,
AdvancedSelector,
NoIndexPatternsPanel,
DatasetSelectorAppearance,
} from './ui';

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 5a21c1d

Please sign in to comment.