-
Notifications
You must be signed in to change notification settings - Fork 906
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
Fix Loading and Editing Saved Searches in Discover #8306
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8306 +/- ##
==========================================
- Coverage 60.86% 60.85% -0.02%
==========================================
Files 3793 3793
Lines 90367 90381 +14
Branches 14182 14189 +7
==========================================
- Hits 55000 54998 -2
- Misses 31890 31902 +12
- Partials 3477 3481 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -28,6 +28,7 @@ | |||
* under the License. | |||
*/ | |||
|
|||
import { QueryStringContract } from 'src/plugins/data/public/'; |
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.
unfortunately we should import public into common folder. the compiler might complain about this.
we should consider taking the required function from the query string service (cache dataset) and exporting it in the common folder so that it's reusable by the dataset service and search source service
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.
Where would i see it complaining?
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 am surprised too that CI is not failing.
src/plugins/data/common/search/search_source/create_search_source.ts
Outdated
Show resolved
Hide resolved
cbeb3b5
to
5828bfb
Compare
138437d
to
70a911a
Compare
02317e8
to
97a42ef
Compare
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.
The changes looks good. Can we add some tests for the logic here. I want to make sure that things like "Filters in URL are higher priority than the filters in saved search" have test that will break if thats ever not true in future
src/plugins/discover/public/application/utils/state_management/discover_slice.tsx
Outdated
Show resolved
Hide resolved
src/plugins/discover/public/application/components/top_nav/open_search_panel.tsx
Show resolved
Hide resolved
src/plugins/discover/public/application/components/top_nav/get_top_nav_links.tsx
Show resolved
Hide resolved
97a42ef
to
2ab3400
Compare
I have added couple of tests opensearch-project/opensearch-dashboards-functional-test#1585 . One to verify the above scenario and one to ensure we are resetting the existing filters when we are trying to create a new search. |
); | ||
|
||
useEffect(() => { | ||
const subscription = queryString.getUpdates$(0).subscribe((query: Query) => { | ||
if (query.dataset !== selectedDataset) { |
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.
We recently removed this useEffect()
in #8347 to avoid duplicate calls. Does this if
condition avoid the duplicate calls? Are we adding this back in so it picks up updates from state sync?
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.
@sejli The reasoning behind adding this , is when we are using to load the state from the saved Object it loads it without using the dataset selector component. Therefore although the actual query state has been updated but since the dataset selector is not triggered, the dataset selector content is not updated. The if condition is to avoid multiple updates.
2ab3400
to
6788fdd
Compare
data.query.queryString.setQuery(query); | ||
// Filters in URL are higher priority than the filters in saved search | ||
const urlFilters = (osdUrlStateStorage.get('_q') as QueryState)?.filters ?? []; | ||
if (!urlFilters || urlFilters.length === 0) { |
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.
This is untrusted input; right?
if (!urlFilters || urlFilters.length === 0) { | |
if (!Array.isArray(urlFilters) || urlFilters.length === 0) { |
// Filters in URL are higher priority than the filters in saved search | ||
const urlFilters = (osdUrlStateStorage.get('_q') as QueryState)?.filters ?? []; | ||
if (!urlFilters || urlFilters.length === 0) { | ||
filterManager.setAppFilters(actualFilters); |
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.
wouldn't we want to make sure to call filterManager.setAppFilters([]);
when urlFilters
is bad?
6788fdd
to
8fbfc88
Compare
Will add additional unit tests & concerns in a follow up PR. |
const indexPattern = indexPatternCache.get(id); | ||
if (indexPattern) { | ||
return true; | ||
} | ||
return 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.
nit: return !!indexPatternCache.get(id);
if ( | ||
searchSourceDependencies.queryStringService && | ||
fields.query?.dataset && | ||
fields.query?.dataset?.type !== 'INDEX_PATTERN' && |
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: at this point, don't need ? in ?.dataset
) { | ||
await searchSourceDependencies.queryStringService | ||
.getDatasetService() | ||
.cacheDataset(fields.query?.dataset); |
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.
does this do the right thing if dataset is undefined?
const newQueryString = newQuery.query; | ||
if (this.inputRef.getValue() !== newQueryString) { | ||
const newQueryString = this.props.query.query; | ||
if (this.inputRef.getValue() !== newQueryString && typeof newQueryString === 'string') { |
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.
is inputRef.getValue() behind prop because its a controlled input (e.g. its value is defined by props)?
8fbfc88
to
5bd3466
Compare
5bd3466
to
9c8e62f
Compare
Signed-off-by: Suchit Sahoo <[email protected]>
Signed-off-by: Suchit Sahoo <[email protected]>
Signed-off-by: Suchit Sahoo <[email protected]>
9c8e62f
to
27f7856
Compare
Signed-off-by: Ashwin P Chandran <[email protected]>
@@ -9,6 +9,7 @@ import { DatasetSelector as ConnectedDatasetSelector } from './index'; | |||
import { DatasetSelector } from './dataset_selector'; | |||
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public'; | |||
import { Dataset } from '../../../common'; | |||
import { of } from 'rxjs'; |
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.
import { of } from 'rxjs'; |
Can we get an ETA when this will be approved and Merged? |
Any news on this? |
This Pull Request is no longer needed. The fixes for this has been addressed in #8689 that has been merged into main. |
Description
This PR aims at resolving the following issues.
The CI group 6 failure for the PR has been addressed as part of this PR opensearch-project/opensearch-dashboards-functional-test#1585.
Issues Resolved
#8339
#8338
Screenshot
Testing the changes
Meeting.Recording.-.Sahoo.Suchit.Instant.Meeting.9.mp4
Meeting.Recording.-.Sahoo.Suchit.Instant.Meeting.10.mp4
Follow the steps mentioned in the video to test out the changes.
Changelog
Check List
yarn test:jest
yarn test:jest_integration