-
Notifications
You must be signed in to change notification settings - Fork 920
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] Modify the search bar info box content for sql/ppl #8708
[Discover] Modify the search bar info box content for sql/ppl #8708
Conversation
Signed-off-by: Ryan Liang <[email protected]>
❌ Empty Changelog SectionThe 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. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8708 +/- ##
=======================================
Coverage 60.75% 60.76%
=======================================
Files 3798 3798
Lines 90650 90657 +7
Branches 14254 14257 +3
=======================================
+ Hits 55076 55084 +8
+ Misses 32079 32077 -2
- Partials 3495 3496 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Ryan Liang <[email protected]>
Signed-off-by: Ryan Liang <[email protected]>
Signed-off-by: Jialiang Liang <[email protected]>
❌ Empty Changelog SectionThe 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. |
Signed-off-by: Jialiang Liang <[email protected]>
❌ Empty Changelog SectionThe 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. |
Unit testing is WIP. I'd gather some feedback first |
❌ Empty Changelog SectionThe 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. |
Signed-off-by: Jialiang Liang <[email protected]>
useEffect(() => { | ||
if ( | ||
props.selectedLanguage === 'SQL' && | ||
window.localStorage.getItem('hasSeenSQLInfoBox') === 'false' | ||
) { | ||
setIsLanguageReferenceOpen(true); | ||
window.localStorage.setItem('hasSeenSQLInfoBox', 'true'); | ||
} else if ( | ||
props.selectedLanguage === 'PPL' && | ||
window.localStorage.getItem('hasSeenPPLInfoBox') === 'false' | ||
) { | ||
setIsLanguageReferenceOpen(true); | ||
window.localStorage.setItem('hasSeenPPLInfoBox', 'true'); | ||
} | ||
}, [props.selectedLanguage]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to specify this here? can we make it generic. Something like this?
useEffect(() => { | |
if ( | |
props.selectedLanguage === 'SQL' && | |
window.localStorage.getItem('hasSeenSQLInfoBox') === 'false' | |
) { | |
setIsLanguageReferenceOpen(true); | |
window.localStorage.setItem('hasSeenSQLInfoBox', 'true'); | |
} else if ( | |
props.selectedLanguage === 'PPL' && | |
window.localStorage.getItem('hasSeenPPLInfoBox') === 'false' | |
) { | |
setIsLanguageReferenceOpen(true); | |
window.localStorage.setItem('hasSeenPPLInfoBox', 'true'); | |
} | |
}, [props.selectedLanguage]); | |
useEffect(() => { | |
if (autoShow) { | |
const storageKey = `hasSeenInfoBox_${selectedLanguage}`; | |
const hasSeenInfoBox = window.localStorage.getItem(storageKey); | |
if (hasSeenInfoBox === 'false') { | |
setIsLanguageReferenceOpen(true); | |
window.localStorage.setItem(storageKey, 'true'); | |
} | |
} | |
}, [props.selectedLanguage]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I just applied the change
// Initialize local storage keys when the plugin loads, if they don't exist | ||
if (!window.localStorage.getItem('hasSeenSQLInfoBox')) { | ||
window.localStorage.setItem('hasSeenSQLInfoBox', 'false'); | ||
} | ||
if (!window.localStorage.getItem('hasSeenPPLInfoBox')) { | ||
window.localStorage.setItem('hasSeenPPLInfoBox', 'false'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we ned this? why not just use undefined as the intiial state. If the key does not exist, its false by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Signed-off-by: Jialiang Liang <[email protected]>
Signed-off-by: Jialiang Liang <[email protected]>
Signed-off-by: Jialiang Liang <[email protected]>
Signed-off-by: Jialiang Liang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry i missed this in the first review, but we should not be reregistering the language every time the query updates.
cleanup(); | ||
}); | ||
|
||
test('auto-opens the info box on first load if autoShow is true and sets localStorage key', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, but can you add a fast follow test to ensure that this only opens once. Thats the key behavior here. Lets not forget to test that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure lets add that case as a followup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, weird why its still complaining that these lines arent tested. Your tests have covered these lines
const pplControls = [pplLanguageReference()]; | ||
const sqlControls = [sqlLanguageReference()]; | ||
// Subscribe to updates to track language changes | ||
queryString.getUpdates$().subscribe((query) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no, i missed this part. This is risky. We should not be reregistering the language every time the query changes! Did you sanity test discover with this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can avoid this logic entirely since you only need query for the selected language, but looking at the code, you dont really need it right? on line 51&52, you can remove selectedLanguage
since each instance of LanguageReference
is created separately for that language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. I removed the subscriber
Signed-off-by: Jialiang Liang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks much better 😊
const pplControls = [pplLanguageReference('PPL')]; | ||
const sqlControls = [sqlLanguageReference('SQL')]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you dont even need this since pplLanguageReference
will always only be used for PPL right? the additional prop you are sending is redundant
filterable: false, | ||
visualizable: false, | ||
}, | ||
search: new PPLSearchInterceptor({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This is a nice change, but when making a change, keep the scope limited to just whats changing since its harder to review the diff quickly. Especially when there is no functinal benifit from the change. Thsi is just my personal opinion, so take it with a grain of salt.
|
||
import React from 'react'; | ||
import { render, screen, fireEvent, cleanup, act, waitFor } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess you don't need to import this? Because @testing-library/jest-dom
is imported in jest setup files.
const storageKey = `hasSeenInfoBox_${props.selectedLanguage}`; | ||
const hasSeenInfoBox = window.localStorage.getItem(storageKey); | ||
|
||
if (hasSeenInfoBox === null && props.autoShow) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem to need check props.autoShow
here again because it's checked on line 21
if (hasSeenInfoBox === null && props.autoShow) { | |
if (hasSeenInfoBox === null) { |
* [Discover] Modify the search bar info box content for sql/ppl Signed-off-by: Ryan Liang <[email protected]> * Remove comments Signed-off-by: Ryan Liang <[email protected]> * First time pop up - 0 Signed-off-by: Ryan Liang <[email protected]> * First time pop up - 1 Signed-off-by: Jialiang Liang <[email protected]> * Remove the un-used comment and update snapshots Signed-off-by: Jialiang Liang <[email protected]> * Rename SQL into OpenSearch SQL Signed-off-by: Jialiang Liang <[email protected]> * Address comments - 0 Signed-off-by: Jialiang Liang <[email protected]> * Address comments - 1 Signed-off-by: Jialiang Liang <[email protected]> * Enhancements + tests Signed-off-by: Jialiang Liang <[email protected]> * Changeset file for PR #8708 created/updated * remove comment Signed-off-by: Jialiang Liang <[email protected]> * Resolve comments Signed-off-by: Jialiang Liang <[email protected]> --------- Signed-off-by: Ryan Liang <[email protected]> Signed-off-by: Jialiang Liang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit 90c40da) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…arch-project#8708) * [Discover] Modify the search bar info box content for sql/ppl Signed-off-by: Ryan Liang <[email protected]> * Remove comments Signed-off-by: Ryan Liang <[email protected]> * First time pop up - 0 Signed-off-by: Ryan Liang <[email protected]> * First time pop up - 1 Signed-off-by: Jialiang Liang <[email protected]> * Remove the un-used comment and update snapshots Signed-off-by: Jialiang Liang <[email protected]> * Rename SQL into OpenSearch SQL Signed-off-by: Jialiang Liang <[email protected]> * Address comments - 0 Signed-off-by: Jialiang Liang <[email protected]> * Address comments - 1 Signed-off-by: Jialiang Liang <[email protected]> * Enhancements + tests Signed-off-by: Jialiang Liang <[email protected]> * Changeset file for PR opensearch-project#8708 created/updated * remove comment Signed-off-by: Jialiang Liang <[email protected]> * Resolve comments Signed-off-by: Jialiang Liang <[email protected]> --------- Signed-off-by: Ryan Liang <[email protected]> Signed-off-by: Jialiang Liang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
…arch-project#8708) * [Discover] Modify the search bar info box content for sql/ppl Signed-off-by: Ryan Liang <[email protected]> * Remove comments Signed-off-by: Ryan Liang <[email protected]> * First time pop up - 0 Signed-off-by: Ryan Liang <[email protected]> * First time pop up - 1 Signed-off-by: Jialiang Liang <[email protected]> * Remove the un-used comment and update snapshots Signed-off-by: Jialiang Liang <[email protected]> * Rename SQL into OpenSearch SQL Signed-off-by: Jialiang Liang <[email protected]> * Address comments - 0 Signed-off-by: Jialiang Liang <[email protected]> * Address comments - 1 Signed-off-by: Jialiang Liang <[email protected]> * Enhancements + tests Signed-off-by: Jialiang Liang <[email protected]> * Changeset file for PR opensearch-project#8708 created/updated * remove comment Signed-off-by: Jialiang Liang <[email protected]> * Resolve comments Signed-off-by: Jialiang Liang <[email protected]> --------- Signed-off-by: Ryan Liang <[email protected]> Signed-off-by: Jialiang Liang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
…t for sql/ppl (#8762) * [Discover] Modify the search bar info box content for sql/ppl (#8708) * [Discover] Modify the search bar info box content for sql/ppl Signed-off-by: Ryan Liang <[email protected]> * Remove comments Signed-off-by: Ryan Liang <[email protected]> * First time pop up - 0 Signed-off-by: Ryan Liang <[email protected]> * First time pop up - 1 Signed-off-by: Jialiang Liang <[email protected]> * Remove the un-used comment and update snapshots Signed-off-by: Jialiang Liang <[email protected]> * Rename SQL into OpenSearch SQL Signed-off-by: Jialiang Liang <[email protected]> * Address comments - 0 Signed-off-by: Jialiang Liang <[email protected]> * Address comments - 1 Signed-off-by: Jialiang Liang <[email protected]> * Enhancements + tests Signed-off-by: Jialiang Liang <[email protected]> * Changeset file for PR #8708 created/updated * remove comment Signed-off-by: Jialiang Liang <[email protected]> * Resolve comments Signed-off-by: Jialiang Liang <[email protected]> --------- Signed-off-by: Ryan Liang <[email protected]> Signed-off-by: Jialiang Liang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * Add test id for languageReferenceButton Signed-off-by: Jialiang Liang <[email protected]> --------- Signed-off-by: Ryan Liang <[email protected]> Signed-off-by: Jialiang Liang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
opensearch-release-notes-2.18.0.md How do we enable this experimental feature? What is the name of this feature? |
Hi @Gokul-Radhakrishnan , thanks for dropping the above comment. May I ask if the above question is related to the specific implementation of this PR? If it is only a general question that related to Discover feature for version And here are some useful links that related to the issue filing:
cc @ashwin-pc |
@RyanL1997 I want to try out the PPL in Discover. How can I do that? |
Description
Issues Resolved
Screenshot
Version Final:
Screen.Recording.2024-10-27.at.2.26.53.PM.mov
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration