Skip to content

Commit

Permalink
Fix Discover intial pageload for non DQL language
Browse files Browse the repository at this point in the history
Signed-off-by: Suchit Sahoo <[email protected]>
  • Loading branch information
LDrago27 committed Aug 30, 2024
1 parent 1039db4 commit 3f1f5cf
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/plugins/data/public/query/query_string/query_string_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,32 @@ export class QueryStringManager {
}

public getDefaultQuery() {
return {
query: this.getDefaultQueryString(),
language: this.getDefaultLanguage(),
...(this.uiSettings &&
this.uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED) && {
dataset: this.datasetService?.getDefault(),
}),
const defaultLanguageId = this.getDefaultLanguage();
const defaultQuery = this.getDefaultQueryString();
const defaultDataset = this.datasetService?.getDefault();

const query = {
query: defaultQuery,
language: defaultLanguageId,
dataset: defaultDataset,
};

if (
this.uiSettings &&
this.uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED) &&
defaultDataset &&
this.languageService
) {
const language = this.languageService.getLanguage(defaultLanguageId);

Check warning on line 79 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#L79

Added line #L79 was not covered by tests
const newQueryString = language?.getQueryString(query) || '';

return {

Check warning on line 82 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#L82

Added line #L82 was not covered by tests
...query,
query: newQueryString,
};
}

return query;
}

public formatQuery(query: Query | string | undefined): Query {
Expand Down

0 comments on commit 3f1f5cf

Please sign in to comment.