From 347d6d7423df22808e0c64079a0b41efc7e47dd7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 11 Sep 2024 02:55:19 +0000 Subject: [PATCH] Remove unsupported languages for dataset (#8100) * remove unsupported languages Signed-off-by: abbyhu2000 * Changeset file for PR #8100 created/updated * address comments Signed-off-by: abbyhu2000 * address comments Signed-off-by: abbyhu2000 --------- Signed-off-by: abbyhu2000 Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit 42317f17a6857503673314e04fc6e817da070ba0) Signed-off-by: github-actions[bot] --- changelogs/fragments/8100.yml | 2 ++ .../public/ui/query_editor/language_selector.tsx | 12 ++++++++++-- src/plugins/data/public/ui/types.ts | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/8100.yml diff --git a/changelogs/fragments/8100.yml b/changelogs/fragments/8100.yml new file mode 100644 index 000000000000..40b48e259a00 --- /dev/null +++ b/changelogs/fragments/8100.yml @@ -0,0 +1,2 @@ +fix: +- Remove unsupported languages for dataset ([#8100](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8100)) \ No newline at end of file diff --git a/src/plugins/data/public/ui/query_editor/language_selector.tsx b/src/plugins/data/public/ui/query_editor/language_selector.tsx index 1965d9a3d46a..2cdac637bc01 100644 --- a/src/plugins/data/public/ui/query_editor/language_selector.tsx +++ b/src/plugins/data/public/ui/query_editor/language_selector.tsx @@ -36,6 +36,13 @@ export const QueryLanguageSelector = (props: QueryLanguageSelectorProps) => { const queryString = getQueryService().queryString; const languageService = queryString.getLanguageService(); + const datasetSupportedLanguages = props.query.dataset + ? queryString + .getDatasetService() + .getType(props.query.dataset.type) + ?.supportedLanguages(props.query.dataset) + : undefined; + useEffect(() => { const subscription = queryString.getUpdates$().subscribe((query: Query) => { if (query.language !== currentLanguage) { @@ -57,10 +64,11 @@ export const QueryLanguageSelector = (props: QueryLanguageSelectorProps) => { languageService.getLanguages().forEach((language) => { if ( (language && props.appName && !language.editorSupportedAppNames?.includes(props.appName)) || - languageService.getUserQueryLanguageBlocklist().includes(language?.id) + languageService.getUserQueryLanguageBlocklist().includes(language?.id) || + (datasetSupportedLanguages && !datasetSupportedLanguages.includes(language.id)) ) return; - languageOptions.unshift(mapExternalLanguageToOptions(language!)); + languageOptions.unshift(mapExternalLanguageToOptions(language)); }); const selectedLanguage = { diff --git a/src/plugins/data/public/ui/types.ts b/src/plugins/data/public/ui/types.ts index d9f656fabb03..ec57cb2e8c2c 100644 --- a/src/plugins/data/public/ui/types.ts +++ b/src/plugins/data/public/ui/types.ts @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { QueryStatus } from '../query'; import { IndexPatternSelectProps } from './index_pattern_select'; import { StatefulSearchBarProps } from './search_bar'; import { SuggestionsComponentProps } from './typeahead/suggestions_component';