-
Notifications
You must be signed in to change notification settings - Fork 894
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
Add SearchOnLoad Preference for dataset #8513
Add SearchOnLoad Preference for dataset #8513
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8513 +/- ##
==========================================
- Coverage 60.93% 60.93% -0.01%
==========================================
Files 3767 3771 +4
Lines 89387 89555 +168
Branches 13985 14020 +35
==========================================
+ Hits 54471 54566 +95
- Misses 31519 31579 +60
- Partials 3397 3410 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
72b5b0e
to
edbfd00
Compare
src/plugins/discover/public/application/view_components/utils/use_search.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Suchit Sahoo <[email protected]>
edbfd00
to
aae4ca9
Compare
queryStatus: { startTime }, | ||
}), | ||
[shouldSearchOnPageLoad, startTime] | ||
[shouldSearchOnPageLoad, startTime, skipInitialFetch] |
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.
should we check for skipInitialFetch.current
instead?
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.
+1.
@@ -30,6 +30,8 @@ export interface DatasetTypeConfig { | |||
icon: EuiIconProps; | |||
/** Optional tooltip text */ | |||
tooltip?: string; | |||
/** Optional preference for search on page load else defaulted to true */ | |||
searchOnLoad?: boolean; |
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: So you set this one as an optional property. Seems searchOnLoad property is added to some dataset types but not all? Seems we have searchOnLoad on index pattern type, index type and s3 type. what else types need this searchOnLoad that allows this property to be missing? To make it consistent, maybe remove ? because this return !datasetType || (datasetService?.getType(datasetType)?.meta?.searchOnLoad ?? true
already set the default value to true right? so ?
is not necessary.
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.
nice callout. I think we should have different types for the config we provide and the config we receive from the service. Not a blocker for the PR though
@@ -111,6 +112,15 @@ export const useSearch = (services: DiscoverViewServices) => { | |||
requests: new RequestAdapter(), | |||
}; | |||
|
|||
const getDatasetAutoSearchOnPageLoadPreference = () => { |
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 know it is a bit too much to ask. maybe we should add a test here given we have more and more logic in useSearch.
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.
+1 we definitely need to add a test for this
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 okay with merging this fix if it is urgent. A few nit points and one question: When a search is not performed automatically due to this setting, consider adding a visual indicator to inform the user that they need to manually trigger the search given that most users are familiar with old auto search and might not know they need to click.
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.
Can be a fast follow but lets add tests for the fix.
@@ -30,6 +30,8 @@ export interface DatasetTypeConfig { | |||
icon: EuiIconProps; | |||
/** Optional tooltip text */ | |||
tooltip?: string; | |||
/** Optional preference for search on page load else defaulted to true */ | |||
searchOnLoad?: boolean; |
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.
nice callout. I think we should have different types for the config we provide and the config we receive from the service. Not a blocker for the PR though
@@ -111,6 +112,15 @@ export const useSearch = (services: DiscoverViewServices) => { | |||
requests: new RequestAdapter(), | |||
}; | |||
|
|||
const getDatasetAutoSearchOnPageLoadPreference = () => { |
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.
+1 we definitely need to add a test for this
queryStatus: { startTime }, | ||
}), | ||
[shouldSearchOnPageLoad, startTime] | ||
[shouldSearchOnPageLoad, startTime, skipInitialFetch] |
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.
+1.
Signed-off-by: Suchit Sahoo <[email protected]> (cherry picked from commit 5c8b2e3) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 5c8b2e3) Signed-off-by: Suchit Sahoo <[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>
Signed-off-by: Suchit Sahoo <[email protected]>
Signed-off-by: Suchit Sahoo <[email protected]>
Description
This introduces a searchOnPageLoad preference for each dataset type.
Issues Resolved
Screenshot
Testing the changes
For this demonstration below I have explicitly updated the
searchOnLoad
preference for indexes to be false.Meeting+Recording+-+Sahoo.+Suchit+Instant+Meeting.1.mp4
Changelog
Check List
yarn test:jest
yarn test:jest_integration