Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] fix: fixed unsupported language issue due to cached language in localStorage #8678

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/8674.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Fixed unsupported language is used from localStorage ([#8674](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8674))
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,27 @@
};
};

private getDefaultLanguage() {
return (
this.storage.get('userQueryLanguage') ||
this.uiSettings.get(UI_SETTINGS.SEARCH_QUERY_LANGUAGE)
private isLanguageSupported(languageId: string) {
const currentAppId = this.getCurrentAppId();

Check warning on line 229 in src/plugins/data/public/query/query_string/query_string_manager.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/query_string_manager.ts#L229

Added line #L229 was not covered by tests
if (!currentAppId) {
return false;

Check warning on line 231 in src/plugins/data/public/query/query_string/query_string_manager.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/query_string_manager.ts#L231

Added line #L231 was not covered by tests
}

return containsWildcardOrValue(

Check warning on line 234 in src/plugins/data/public/query/query_string/query_string_manager.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/query_string_manager.ts#L234

Added line #L234 was not covered by tests
this.languageService.getLanguage(languageId)?.supportedAppNames,
currentAppId
);
}

private getDefaultLanguage() {
const lastUsedLanguage = this.storage.get('userQueryLanguage');
if (lastUsedLanguage && this.isLanguageSupported(lastUsedLanguage)) {
return lastUsedLanguage;

Check warning on line 243 in src/plugins/data/public/query/query_string/query_string_manager.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/query_string_manager.ts#L243

Added line #L243 was not covered by tests
}

return this.uiSettings.get(UI_SETTINGS.SEARCH_QUERY_LANGUAGE);
}

private getCurrentAppId = () => {
let appId;
try {
Expand Down
Loading