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] Modify the search bar info box content for sql/ppl #8708

Merged
merged 12 commits into from
Oct 28, 2024

Conversation

RyanL1997
Copy link
Contributor

@RyanL1997 RyanL1997 commented Oct 26, 2024

Description

  • Modify the search bar info box content for sql/ppl
  • The info box will only show up when it is user's first time to select SQL/PPL
  • Change the language picker's title from "SQL" into "OpenSearch SQL"

Issues Resolved

Screenshot

Version Final:

Screen.Recording.2024-10-27.at.2.26.53.PM.mov

Testing the changes

Changelog

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 26, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.76%. Comparing base (463a6c0) to head (33b1ed2).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
...string/language_service/lib/language_reference.tsx 88.88% 0 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
Linux_1 29.06% <11.11%> (-0.01%) ⬇️
Linux_2 56.39% <ø> (ø)
Linux_3 37.58% <88.88%> (+0.01%) ⬆️
Linux_4 29.83% <11.11%> (-0.01%) ⬇️
Windows_1 29.09% <11.11%> (-0.01%) ⬇️
Windows_2 56.35% <ø> (ø)
Windows_3 37.58% <88.88%> (+<0.01%) ⬆️
Windows_4 29.83% <11.11%> (-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.

Signed-off-by: Ryan Liang <[email protected]>
Signed-off-by: Ryan Liang <[email protected]>
Signed-off-by: Jialiang Liang <[email protected]>
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.

@RyanL1997 RyanL1997 requested a review from huyaboo as a code owner October 27, 2024 00:11
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.

@RyanL1997
Copy link
Contributor Author

Unit testing is WIP. I'd gather some feedback first

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.

Signed-off-by: Jialiang Liang <[email protected]>
Comment on lines 21 to 35
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]);
Copy link
Member

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?

Suggested change
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]);

Copy link
Contributor Author

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

Comment on lines 46 to 52
// 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');
}
Copy link
Member

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

Copy link
Contributor Author

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]>
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.

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 () => {
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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) => {
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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]>
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.

Thanks! This looks much better 😊

Comment on lines +46 to +47
const pplControls = [pplLanguageReference('PPL')];
const sqlControls = [sqlLanguageReference('SQL')];
Copy link
Member

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({
Copy link
Member

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';
Copy link
Member

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) {
Copy link
Member

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

Suggested change
if (hasSeenInfoBox === null && props.autoShow) {
if (hasSeenInfoBox === null) {

@ruanyl ruanyl merged commit 90c40da into opensearch-project:main Oct 28, 2024
72 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 28, 2024
* [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>
Qxisylolo pushed a commit to Qxisylolo/OpenSearch-Dashboards that referenced this pull request Oct 30, 2024
…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>
@ananzh ananzh added v2.18.0 and removed v2.19.0 labels Oct 30, 2024
RyanL1997 added a commit to RyanL1997/OpenSearch-Dashboards that referenced this pull request Oct 30, 2024
…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>
ananzh pushed a commit that referenced this pull request Oct 30, 2024
…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>
@Gokul-Radhakrishnan
Copy link

opensearch-release-notes-2.18.0.md
image

How do we enable this experimental feature?
image

What is the name of this feature?

@RyanL1997
Copy link
Contributor Author

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 2.18.0, I suggest that to file an separate issue under OpenSearch Dashboards repo, so that more maintainers can be looped into the conversation to answer your questions.

And here are some useful links that related to the issue filing:

cc @ashwin-pc

@Gokul-Radhakrishnan
Copy link

@RyanL1997 I want to try out the PPL in Discover. How can I do that?

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.

5 participants