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

Sync query and filter when refreshing discover page #8168

Merged

Conversation

abbyhu2000
Copy link
Member

@abbyhu2000 abbyhu2000 commented Sep 12, 2024

Description

This PR resolves previously identified three similar bugs when using legacy discover:

Query and filter failed to persist when:

  • refresh the page
  • switching between default discover table and datagrid
  • using the share link

Issues Resolved

Screenshot

Screen.Recording.2024-09-12.at.1.28.21.PM.mov

Testing the changes

Changelog

  • fix: Sync query and filter when refreshing discover page

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

ashwin-pc
ashwin-pc previously approved these changes Sep 12, 2024
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.

Can we add a test for this as a fast follow?

Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 64.04%. Comparing base (8118024) to head (88fb745).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ic/application/view_components/utils/use_search.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8168      +/-   ##
==========================================
+ Coverage   64.03%   64.04%   +0.01%     
==========================================
  Files        3740     3740              
  Lines       88580    88582       +2     
  Branches    13790    13791       +1     
==========================================
+ Hits        56720    56732      +12     
+ Misses      31262    31252      -10     
  Partials      598      598              
Flag Coverage Δ
Linux_1 30.04% <0.00%> (-0.01%) ⬇️
Linux_2 58.79% <ø> (ø)
Linux_3 40.39% <0.00%> (-0.01%) ⬇️
Linux_4 31.47% <ø> (ø)
Windows_1 30.07% <0.00%> (+0.01%) ⬆️
Windows_2 58.74% <ø> (ø)
Windows_3 40.39% <0.00%> (-0.01%) ⬇️
Windows_4 31.47% <ø> (ø)

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.

@kavilla
Copy link
Member

kavilla commented Sep 12, 2024

is this correctly for 2.17?

kavilla
kavilla previously approved these changes Sep 12, 2024
@@ -324,6 +324,11 @@ export const useSearch = (services: DiscoverViewServices) => {
const savedSearchInstance = await getSavedSearchById(savedSearchId);
setSavedSearch(savedSearchInstance);

// if saved search does not exist, do not atempt to sync filters and query from savedObject
if (!savedSearch) {
Copy link
Member

@kavilla kavilla Sep 12, 2024

Choose a reason for hiding this comment

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

i think the linter will complain that this isn't included in the dependency if it wasn't disabled? however i noticed that 325 sets this value.

i can see in the future someone listening to the linter and including the savedsearch in the dependencies.

shouldn't we just do

if (!savedSearchInstance) {

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 savedSearchId instead since it is already a dependency

Copy link
Member Author

Choose a reason for hiding this comment

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

savedSearchInstance does not work here because it is always defined

Copy link
Member Author

Choose a reason for hiding this comment

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

savedSearchId here wont work as well, because when we create a new saved search, the id is null, but we do not want to return here.

@abbyhu2000 abbyhu2000 dismissed stale reviews from kavilla and ashwin-pc via ec40894 September 12, 2024 22:44
kavilla
kavilla previously approved these changes Sep 12, 2024
sejli
sejli previously approved these changes Sep 12, 2024
abbyhu2000 and others added 4 commits September 13, 2024 00:05
Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
@abbyhu2000
Copy link
Member Author

Manual 2.17 backport : #8179

@abbyhu2000
Copy link
Member Author

link check failure is not related: * [404] [http://sites.google.com/site/murmurhash/](http://sites.google.com/site/murmurhash/) | Failed: Network error: Not Found

@abbyhu2000 abbyhu2000 merged commit 18875f7 into opensearch-project:main Sep 13, 2024
65 of 67 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 13, 2024
* revert back to use savedSearch

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>

* change to use savedSearchId

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>

* Changeset file for PR #8168 created/updated

* revert to use savesearch

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>

---------

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 18875f7)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants