Skip to content

Commit

Permalink
[ES|QL] Improves application messages (elastic#168078)
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula authored Oct 5, 2023
1 parent cee55e3 commit e430a7f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions packages/kbn-es-query/src/es_query/es_aggregate_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export function getAggregateQueryMode(query: AggregateQuery): Language {
return Object.keys(query)[0] as Language;
}

export function getLanguageDisplayName(language: string): string {
return language === 'esql' ? 'es|ql' : language;
export function getLanguageDisplayName(language?: string): string {
const displayName = language && language === 'esql' ? 'es|ql' : language ?? 'es|ql';
return displayName.toUpperCase();
}

// retrieves the index pattern from the aggregate query for SQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
{documentationSections && (
<EuiFlexItem grow={false}>
<LanguageDocumentationPopover
language={getLanguageDisplayName(String(language)).toUpperCase()}
language={getLanguageDisplayName(String(language))}
sections={documentationSections}
buttonProps={{
color: 'text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function ChangeDataView({

useEffect(() => {
if (textBasedLanguage) {
setTriggerLabel(getLanguageDisplayName(textBasedLanguage).toUpperCase());
setTriggerLabel(getLanguageDisplayName(textBasedLanguage));
} else {
setTriggerLabel(trigger.label);
}
Expand Down Expand Up @@ -244,7 +244,9 @@ export function ChangeDataView({
{
defaultMessage:
"Switching data views removes the current {textBasedLanguage} query. Save this search to ensure you don't lose work.",
values: { textBasedLanguage },
values: {
textBasedLanguage: getLanguageDisplayName(textBasedLanguage),
},
}
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React, { useState, useCallback } from 'react';
import { i18n } from '@kbn/i18n';

import { getLanguageDisplayName } from '@kbn/es-query';
import {
EuiModal,
EuiModalBody,
Expand Down Expand Up @@ -39,7 +39,7 @@ export default function TextBasedLanguagesTransitionModal({
setDismissModalChecked(e.target.checked);
}, []);

const language = textBasedLanguage?.toUpperCase();
const language = getLanguageDisplayName(textBasedLanguage);
return (
<EuiModal onClose={() => setIsTextLangTransitionModalVisible(false)} style={{ width: 700 }}>
<EuiModalHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const getWrapperWithTooltip = (
position="top"
content={i18n.translate('unifiedSearch.query.queryBar.textBasedNonTimestampWarning', {
defaultMessage:
'Date range selection for {language} queries requires the presence of an @timestamp field in the dataset.',
'Date range selection for {language} queries requires an @timestamp field in the dataset.',
values: { language: displayName },
})}
>
Expand Down

0 comments on commit e430a7f

Please sign in to comment.