Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 committed Sep 10, 2024
1 parent e1dfc6f commit 1dafc7e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/plugins/data/public/ui/query_editor/language_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getQueryService } from '../../services';
import { LanguageConfig } from '../../query';
import { Query } from '../..';
import { Dataset } from '../../../common';
import { darkCssDistFilename } from '../../../../../../packages/osd-ui-shared-deps/index';

export interface QueryLanguageSelectorProps {
query: Query;
Expand All @@ -38,8 +39,9 @@ export const QueryLanguageSelector = (props: QueryLanguageSelectorProps) => {
const queryString = getQueryService().queryString;
const languageService = queryString.getLanguageService();

const type = queryString.getDatasetService().getType(props.dataset!.type);
const datasetSupportedLanguages = type?.supportedLanguages(props.dataset!) || [];
const datasetSupportedLanguages = props.dataset
? queryString.getDatasetService().getType(props.dataset.type)?.supportedLanguages(props.dataset)
: undefined;

useEffect(() => {
const subscription = queryString.getUpdates$().subscribe((query: Query) => {
Expand All @@ -61,14 +63,19 @@ export const QueryLanguageSelector = (props: QueryLanguageSelectorProps) => {

languageService
.getLanguages()
.filter((language) => datasetSupportedLanguages.includes(language.id))
.filter((language) => {
if (datasetSupportedLanguages) {
return datasetSupportedLanguages.includes(language.id);

Check warning on line 68 in src/plugins/data/public/ui/query_editor/language_selector.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/query_editor/language_selector.tsx#L68

Added line #L68 was not covered by tests
}
return true;
})
.forEach((language) => {
if (
(language && props.appName && !language.editorSupportedAppNames?.includes(props.appName)) ||
languageService.getUserQueryLanguageBlocklist().includes(language?.id)
)
return;

Check warning on line 77 in src/plugins/data/public/ui/query_editor/language_selector.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/query_editor/language_selector.tsx#L77

Added line #L77 was not covered by tests
languageOptions.unshift(mapExternalLanguageToOptions(language!));
languageOptions.unshift(mapExternalLanguageToOptions(language));
});

const selectedLanguage = {
Expand Down

0 comments on commit 1dafc7e

Please sign in to comment.