Skip to content

Commit

Permalink
Remove unsupported languages for dataset (opensearch-project#8100)
Browse files Browse the repository at this point in the history
* remove unsupported languages

Signed-off-by: abbyhu2000 <[email protected]>

* Changeset file for PR opensearch-project#8100 created/updated

* address comments

Signed-off-by: abbyhu2000 <[email protected]>

* address comments

Signed-off-by: abbyhu2000 <[email protected]>

---------

Signed-off-by: abbyhu2000 <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
1 parent b438c2e commit 42317f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8100.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Remove unsupported languages for dataset ([#8100](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8100))
12 changes: 10 additions & 2 deletions src/plugins/data/public/ui/query_editor/language_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 = {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/public/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 42317f1

Please sign in to comment.