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

[discover] optimize rendering language options #8685

Merged

Conversation

kavilla
Copy link
Member

@kavilla kavilla commented Oct 23, 2024

Description

Optimize the language selector preventing too many renders and potentially setting of the language triggering an update.

Issues Resolved

n/a

Screenshot

Testing the changes

Changelog

  • fix: Optimize rendering the Discover language options

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

Copy link
Contributor

❌ Empty Changelog Section

The Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section.

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 12 lines in your changes missing coverage. Please review.

Project coverage is 60.86%. Comparing base (79fed30) to head (42c611b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../data/public/ui/query_editor/language_selector.tsx 55.55% 7 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8685      +/-   ##
==========================================
- Coverage   60.86%   60.86%   -0.01%     
==========================================
  Files        3793     3793              
  Lines       90447    90456       +9     
  Branches    14203    14204       +1     
==========================================
+ Hits        55053    55057       +4     
- Misses      31906    31910       +4     
- Partials     3488     3489       +1     
Flag Coverage Δ
Linux_1 29.08% <ø> (ø)
Linux_2 56.40% <ø> (ø)
Linux_3 37.69% <55.55%> (+<0.01%) ⬆️
Linux_4 29.85% <ø> (ø)
Windows_1 29.10% <ø> (ø)
Windows_2 56.35% <ø> (ø)
Windows_3 37.69% <55.55%> (+<0.01%) ⬆️
Windows_4 29.85% <ø> (-0.01%) ⬇️

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.

const isAppSupported =
!props.appName || language?.editorSupportedAppNames?.includes(props.appName);

if (!isSupported || isBlocklisted || !isAppSupported) return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be !isBlocklisted?

Copy link
Member Author

Choose a reason for hiding this comment

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

tbh i added this advanced setting in case host wanted to prevent specific languages from showing but i doubt it will be used in the situation where this was in experimental and a language wasn't working. this should be removed in general.

Copy link
Member

Choose a reason for hiding this comment

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

What is that advanced setting supposed to do?


const selectedLanguage = useMemo(
() => ({
label:
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this need to default to something?

Copy link
Member Author

Choose a reason for hiding this comment

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

like if it can't find the value? it could it might make sense to pull from the advanced setting

@kavilla kavilla force-pushed the kavilla/fix_language_selected_issue branch from 0173254 to ee57410 Compare October 23, 2024 05:05
Signed-off-by: Kawika Avilla <[email protected]>
@kavilla kavilla changed the title [discover] memoization plus not setting the user query language [discover] optimize rendering language options Oct 23, 2024
Copy link
Contributor

❌ Create Or Update Content

Something went wrong. Error creating or updating content in repository. Please try again.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

LGTM

const isAppSupported =
!props.appName || language?.editorSupportedAppNames?.includes(props.appName);

if (!isSupported || isBlocklisted || !isAppSupported) return;
Copy link
Member

Choose a reason for hiding this comment

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

What is that advanced setting supposed to do?


languageService.setUserQueryLanguage(currentLanguage);
Copy link
Member

Choose a reason for hiding this comment

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

Was this what caused all those issues?

@ashwin-pc ashwin-pc merged commit 85e0767 into opensearch-project:main Oct 23, 2024
67 of 68 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 23, 2024
* memoization plus not setting the user query language

Signed-off-by: Kawika Avilla <[email protected]>

* clean up commented code

Signed-off-by: Kawika Avilla <[email protected]>

* Changeset file for PR #8685 created/updated

* Changeset file for PR #8685 deleted

---------

Signed-off-by: Kawika Avilla <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 85e0767)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
virajsanghvi pushed a commit that referenced this pull request Oct 23, 2024
* memoization plus not setting the user query language



* clean up commented code



* Changeset file for PR #8685 created/updated

* Changeset file for PR #8685 deleted

---------



(cherry picked from commit 85e0767)

Signed-off-by: Kawika Avilla <[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>
Qxisylolo pushed a commit to Qxisylolo/OpenSearch-Dashboards that referenced this pull request Oct 30, 2024
* memoization plus not setting the user query language

Signed-off-by: Kawika Avilla <[email protected]>

* clean up commented code

Signed-off-by: Kawika Avilla <[email protected]>

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

* Changeset file for PR opensearch-project#8685 deleted

---------

Signed-off-by: Kawika Avilla <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
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