Skip to content

Commit

Permalink
[8.11] [ES|QL] Improves application messages (elastic#168078) (elasti…
Browse files Browse the repository at this point in the history
…c#168137)

# Backport

This will backport the following commits from `main` to `8.11`:
- [[ES|QL] Improves application messages
(elastic#168078)](elastic#168078)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-05T17:21:22Z","message":"[ES|QL]
Improves application messages
(elastic#168078)","sha":"e430a7f9fbf0e0aba15188d9470d0dee6727bf2a","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Team:DataDiscovery","backport:prev-minor","v8.11.0","Feature:ES|QL","v8.12.0"],"number":168078,"url":"https://github.com/elastic/kibana/pull/168078","mergeCommit":{"message":"[ES|QL]
Improves application messages
(elastic#168078)","sha":"e430a7f9fbf0e0aba15188d9470d0dee6727bf2a"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/168078","number":168078,"mergeCommit":{"message":"[ES|QL]
Improves application messages
(elastic#168078)","sha":"e430a7f9fbf0e0aba15188d9470d0dee6727bf2a"}}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <[email protected]>
  • Loading branch information
kibanamachine and stratoula authored Oct 5, 2023
1 parent 8c4efe8 commit c65f469
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 c65f469

Please sign in to comment.