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

Remove unsupported languages for dataset #8100

Merged

Conversation

abbyhu2000
Copy link
Member

Description

Remove unsupported languages for dataset in language selector

Issues Resolved

Screenshot

Testing the changes

Changelog

  • fix: Remove unsupported languages for dataset

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@@ -36,6 +38,9 @@ export const QueryLanguageSelector = (props: QueryLanguageSelectorProps) => {
const queryString = getQueryService().queryString;
const languageService = queryString.getLanguageService();

const type = queryString.getDatasetService().getType(props.dataset!.type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid non-null assertion as it's one of the major cause of runtime exception.

Suggested change
const type = queryString.getDatasetService().getType(props.dataset!.type);
const type = props.dataset ? queryString.getDatasetService().getType(props.dataset.type) : undefined

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use conditional operator

languageService.getUserQueryLanguageBlocklist().includes(language?.id)
)
return;
languageOptions.unshift(mapExternalLanguageToOptions(language!));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems you don't need non-null assertion here

Suggested change
languageOptions.unshift(mapExternalLanguageToOptions(language!));
languageOptions.unshift(mapExternalLanguageToOptions(language));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.84%. Comparing base (22f1d46) to head (7392a6f).
Report is 34 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8100      +/-   ##
==========================================
+ Coverage   63.71%   63.84%   +0.13%     
==========================================
  Files        3738     3738              
  Lines       88682    88702      +20     
  Branches    13788    13795       +7     
==========================================
+ Hits        56501    56631     +130     
+ Misses      31593    31474     -119     
- Partials      588      597       +9     
Flag Coverage Δ
Linux_1 29.96% <ø> (+<0.01%) ⬆️
Linux_2 58.79% <ø> (ø)
Linux_3 40.27% <100.00%> (+0.21%) ⬆️
Linux_4 31.20% <ø> (ø)
Windows_1 29.97% <ø> (+<0.01%) ⬆️
Windows_2 58.74% <ø> (ø)
Windows_3 40.27% <100.00%> (+0.21%) ⬆️
Windows_4 31.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


export interface QueryLanguageSelectorProps {
query: Query;
onSelectLanguage: (newLanguage: string) => void;
anchorPosition?: PopoverAnchorPosition;
appName?: string;
dataset?: Dataset;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt the query object already contain the dataset?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, removed extra prop

sejli
sejli previously approved these changes Sep 10, 2024
Comment on lines 72 to 77
.forEach((language) => {
if (
(language && props.appName && !language.editorSupportedAppNames?.includes(props.appName)) ||
languageService.getUserQueryLanguageBlocklist().includes(language?.id)
)
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be in filter(), since it's basically just filtering it again but in the forEach() loop? Then, we can pass the mapExternalLanguageOptions() function into a .map() instead of a for loop. Not a blocking comment, just something that might make it a bit easier more readable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combined forEach and filter

Signed-off-by: abbyhu2000 <[email protected]>
@ashwin-pc ashwin-pc merged commit 42317f1 into opensearch-project:main Sep 11, 2024
67 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 11, 2024
* remove unsupported languages

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

* Changeset file for PR #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>
(cherry picked from commit 42317f1)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
abbyhu2000 added a commit that referenced this pull request Sep 12, 2024
* remove unsupported languages



* Changeset file for PR #8100 created/updated

* address comments



* address comments



---------



(cherry picked from commit 42317f1)

Signed-off-by: abbyhu2000 <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Qingyang(Abby) Hu <[email protected]>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 20, 2024
* remove unsupported languages

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

* Changeset file for PR #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>
(cherry picked from commit 42317f1)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
abbyhu2000 pushed a commit that referenced this pull request Sep 21, 2024
* remove unsupported languages



* Changeset file for PR #8100 created/updated

* address comments



* address comments



---------



(cherry picked from commit 42317f1)

Signed-off-by: abbyhu2000 <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
abbyhu2000 added a commit to abbyhu2000/OpenSearch-Dashboards that referenced this pull request Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants