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

Add SearchOnLoad Preference for dataset #8513

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

LDrago27
Copy link
Collaborator

@LDrago27 LDrago27 commented Oct 7, 2024

Description

This introduces a searchOnPageLoad preference for each dataset type.

  • When Advanced setting of searchOnPageLoad is OFF we respect the Advanced setting
  • When Advanced setting of searchOnPageLoad is ON we respect the selected dataset's searchOnLoad preference

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

  • skip

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

@github-actions github-actions bot added all-star-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry labels Oct 7, 2024
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

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

Project coverage is 60.93%. Comparing base (58e1645) to head (aae4ca9).
Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
...ic/application/view_components/utils/use_search.ts 0.00% 11 Missing ⚠️
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     
Flag Coverage Δ
Linux_1 29.00% <0.00%> (+0.04%) ⬆️
Linux_2 56.27% <ø> (+0.02%) ⬆️
Linux_3 37.74% <0.00%> (-0.01%) ⬇️
Linux_4 29.92% <ø> (+<0.01%) ⬆️
Windows_1 29.02% <0.00%> (+0.04%) ⬆️
Windows_2 56.23% <ø> (+0.02%) ⬆️
Windows_3 37.74% <0.00%> (-0.01%) ⬇️
Windows_4 29.92% <ø> (+<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.

@LDrago27 LDrago27 changed the title [WIP] Add SearchOnPageLoad Preference for dataset Add SearchOnLoad Preference for dataset Oct 8, 2024
queryStatus: { startTime },
}),
[shouldSearchOnPageLoad, startTime]
[shouldSearchOnPageLoad, startTime, skipInitialFetch]
Copy link
Collaborator

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?

Copy link
Member

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

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.

Copy link
Member

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

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.

Copy link
Member

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

Copy link
Member

@ananzh ananzh left a 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.

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

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

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]
Copy link
Member

Choose a reason for hiding this comment

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

+1.

@LDrago27 LDrago27 merged commit 5c8b2e3 into opensearch-project:main Oct 16, 2024
68 of 69 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 16, 2024
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>
LDrago27 pushed a commit that referenced this pull request Oct 17, 2024
(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>
sejli pushed a commit to sejli/OpenSearch-Dashboards that referenced this pull request Oct 21, 2024
Qxisylolo pushed a commit to Qxisylolo/OpenSearch-Dashboards that referenced this pull request Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
all-star-contributor backport 2.x discover for discover reinvent discover-next Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry v2.18.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Discover runs query again when adding or removing selected fields
4 participants