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]Sample Queries and Saved Queries in No Results Page #8616

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

sejli
Copy link
Member

@sejli sejli commented Oct 17, 2024

Description

  • Adds support for dataset types to return a list of sample queries
  • Update Discover no results page to display listed sample queries and saved queries

Issues Resolved

Screenshot

image image

Testing the changes

Changelog

  • feat: Adds sample queries and saved queries to Discover no results 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

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 2.50000% with 39 lines in your changes missing coverage. Please review.

Project coverage is 60.82%. Comparing base (6659139) to head (419c12b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...c/application/components/no_results/no_results.tsx 4.34% 22 Missing ⚠️
...ublic/application/view_components/canvas/index.tsx 0.00% 8 Missing ⚠️
...y_string/dataset_service/lib/index_pattern_type.ts 0.00% 3 Missing ⚠️
...ery/query_string/dataset_service/lib/index_type.ts 0.00% 3 Missing ⚠️
...gins/query_enhancements/public/datasets/s3_type.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8616      +/-   ##
==========================================
- Coverage   60.85%   60.82%   -0.03%     
==========================================
  Files        3793     3793              
  Lines       90350    90387      +37     
  Branches    14176    14186      +10     
==========================================
+ Hits        54978    54982       +4     
- Misses      31897    31932      +35     
+ Partials     3475     3473       -2     
Flag Coverage Δ
Linux_1 29.08% <2.70%> (-0.02%) ⬇️
Linux_2 56.39% <ø> (ø)
Linux_3 37.67% <2.70%> (-0.02%) ⬇️
Linux_4 29.79% <0.00%> (-0.01%) ⬇️
Windows_1 29.09% <2.70%> (-0.02%) ⬇️
Windows_2 56.34% <ø> (ø)
Windows_3 37.67% <2.70%> (?)
Windows_4 29.79% <0.00%> (-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.

@sejli sejli changed the title [Discover][WIP] Sample Queries and Saved Queries in No Results Page [Discover]Sample Queries and Saved Queries in No Results Page Oct 18, 2024
/**
* Returns a list of sample queries for this dataset type
*/
getSampleQueries?: (dataset: Dataset, language: string) => any;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not be specific about the return value being an array of title-query combos?

Copy link
Member

Choose a reason for hiding this comment

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

+1, i think maybe we should consider just returning an actual Query object and not the query string.

)
);
}
if (query && languageService.getLanguage(query?.language)?.sampleQueries) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be:

Suggested change
if (query && languageService.getLanguage(query?.language)?.sampleQueries) {
if (query?.language && languageService.getLanguage(query.language)?.sampleQueries) {

@@ -35,6 +35,11 @@ export interface EditorEnhancements {
queryEditorExtension?: QueryEditorExtensionConfig;
}

export interface SampleQuery {
Copy link
Member

@kavilla kavilla Oct 18, 2024

Choose a reason for hiding this comment

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

unrelated to this PR, unless we want to modify the type from query: string to query: Query. i think we should create an action item to unify this and recent query and saved queries to extend from a base class. because i can see a world where we add buttons near the sample queries and instead of fighting to update to set the query behavior subject we can just push the entire query object. for example, it will set the date range to 1 week before and 1 week after.

recent query kind of acts the same and so does saved queries. so if we have a base class we could re-use it everywhere. not sure of a good name though but an example to drive the point home like QueryWithAttributes

},
]
: []),
...(savedQueries.length > 0
Copy link
Member

Choose a reason for hiding this comment

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

ah even more so now i think we should consider unifying saved query and sample query at least since they both have the same content

AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Oct 18, 2024
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Oct 18, 2024
Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

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

lgtm, should address the typing comment in a followup

@AMoo-Miki AMoo-Miki merged commit 9da1b77 into opensearch-project:main Oct 18, 2024
67 of 68 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-8616-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 9da1b77bca36d209be7ec9a986500b691fc521e0
# Push it to GitHub
git push --set-upstream origin backport/backport-8616-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-8616-to-2.x.

AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Oct 19, 2024
…arch-project#8616)

* Sample Queries and Saved Queries in No Results Page

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>

* Changeset file for PR opensearch-project#8616 created/updated

* Update styling

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
(cherry picked from commit 9da1b77)
amsiglan pushed a commit to amsiglan/OpenSearch-Dashboards that referenced this pull request Oct 19, 2024
…arch-project#8616)

* Sample Queries and Saved Queries in No Results Page

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>

* Changeset file for PR opensearch-project#8616 created/updated

* Update styling

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
AMoo-Miki added a commit that referenced this pull request Oct 19, 2024
…o Results Page #8616  (#8663)

* Update Discover appearance (#8651)

* Update Discover appearance

Signed-off-by: Miki <[email protected]>

* Changeset file for PR #8651 created/updated

---------

Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

(cherry picked from commit 17103ba)
Signed-off-by: Miki <[email protected]>

* Improve Empty State Handling: Add No Index Patterns Panel with Data Selection in Discover View (#8613)

* Improve Empty State Handling: Add No Index Patterns Panel with Data Selection in Discover View

This PR primarily addresses the scenario when no index patterns (general) is available in the Discover view.
Instead of redirecting users to the index management page, it introduces a new "No Index Patterns" panel.
This panel provides users with the option to open a data selector and add index patterns
directly from the Discover view, improving the user experience for new or empty deployments.

To achieve, we move the selectedDataset state from ConnectedDatasetSelector to the app container's
state management. This allows the AdvancedSelector, opened from the AppContainer, to update
the dataset state effectively. Key changes include:

* Implementing NoIndexPatternsPanel and AdvancedSelector components.
* Refactoring dataset state management in AppContainer and Sidebar.
* Modifying DiscoverCanvas to conditionally render NoIndexPatternsPanel.
* Updating ConnectedDatasetSelector to use shared state and dataset change handling.

Signed-off-by: Anan Zhuang <[email protected]>
Signed-off-by: Miki <[email protected]>

* Update design of no data selected

Signed-off-by: Miki <[email protected]>

* use i18n

Signed-off-by: Anan Zhuang <[email protected]>
Signed-off-by: Miki <[email protected]>

* fix comments

Signed-off-by: Anan Zhuang <[email protected]>

* Update design of no data selected

Signed-off-by: Miki <[email protected]>

* fix lint error

Signed-off-by: Anan Zhuang <[email protected]>

---------

Signed-off-by: Anan Zhuang <[email protected]>
Signed-off-by: Miki <[email protected]>
Co-authored-by: Miki <[email protected]>

(cherry picked from commit 6659139)
Signed-off-by: Miki <[email protected]>

* [Discover]Sample Queries and Saved Queries in No Results Page (#8616)

* Sample Queries and Saved Queries in No Results Page

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>

* Changeset file for PR #8616 created/updated

* Update styling

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
(cherry picked from commit 9da1b77)

---------

Signed-off-by: Miki <[email protected]>
Signed-off-by: Anan Zhuang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Anan Zhuang <[email protected]>
Co-authored-by: Sean Li <[email protected]>
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Oct 19, 2024
Also:
* Fix some React errors

Signed-off-by: Miki <[email protected]>

---------

Fix random big number during loading in query editor result (opensearch-project#8650)

* Fix random big number during loading in query editor result

Signed-off-by: abbyhu2000 <[email protected]>

* Changeset file for PR opensearch-project#8650 created/updated

* Fix initial loading number

Signed-off-by: abbyhu2000 <[email protected]>
(cherry picked from commit a7414f0)

---------

[bug] address different issues with dataset selector (opensearch-project#8665)

* [bug] address some issues with dataset selector

Moved the dataset selector back to the search bar and access it by ref in the sidebar.

Avoid out of sync issue.
* update the logic for ensuring index pattern
* dont add ability to open button
* empty state but missing data set selector button
* fix tests
* add back styling

Signed-off-by: Kawika Avilla <[email protected]>
(cherry picked from commit e23f332)

---------

[bug] Discover UI stuck on searching after deleting index pattern (opensearch-project#8659)

* [bug] Discover UI stuck on searching after deleting index pattern

When using Discover with query enhancement enabled, deleting an index pattern from Index Management does not properly update the "Recently selected data" list in Discover. This causes the UI to become stuck in a "Searching" state when attempting to use
Discover after deleting an index pattern.

Handle the error case where the use index patterns hook caught error when
enhancements was enabled.

issue resolved:
opensearch-project#8612

(cherry picked from commit 4808094)

---------

[Discover]Sample Queries and Saved Queries in No Results Page (opensearch-project#8616)

* Sample Queries and Saved Queries in No Results Page

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>

* Changeset file for PR opensearch-project#8616 created/updated

* Update styling

Signed-off-by: Miki <[email protected]>

(cherry picked from commit 9da1b77)

---------

Improve Empty State Handling: Add No Index Patterns Panel with Data Selection in Discover View (opensearch-project#8613)

* Improve Empty State Handling: Add No Index Patterns Panel with Data Selection in Discover View

This PR primarily addresses the scenario when no index patterns (general) is available in the Discover view.
Instead of redirecting users to the index management page, it introduces a new "No Index Patterns" panel.
This panel provides users with the option to open a data selector and add index patterns
directly from the Discover view, improving the user experience for new or empty deployments.

To achieve, we move the selectedDataset state from ConnectedDatasetSelector to the app container's
state management. This allows the AdvancedSelector, opened from the AppContainer, to update
the dataset state effectively. Key changes include:

* Implementing NoIndexPatternsPanel and AdvancedSelector components.
* Refactoring dataset state management in AppContainer and Sidebar.
* Modifying DiscoverCanvas to conditionally render NoIndexPatternsPanel.
* Updating ConnectedDatasetSelector to use shared state and dataset change handling.

* Update design of no data selected
* use i18n
* fix comments
* Update design of no data selected
* fix lint error

Signed-off-by: Anan Zhuang <[email protected]>

(cherry picked from commit 6659139)

---------

Update Discover appearance (opensearch-project#8651)

* Update Discover appearance

Signed-off-by: Miki <[email protected]>

(cherry picked from commit 17103ba)

---------

Move DatasetSelector from data plugin queryString comp to DataExplorer (opensearch-project#8598)

* Move DatasetSelector to DataExplorer
* Style Disover after moving DatasetSelector to DataExplorer
* fix the test by adding the getUpdates$ method to the mock queryString object

Signed-off-by: Anan Zhuang <[email protected]>

(cherry picked from commit 923cce8)
@AMoo-Miki
Copy link
Collaborator

Manually backported to 2.x with #8670

ashwin-pc added a commit to ashwin-pc/OpenSearch-Dashboards that referenced this pull request Oct 19, 2024
ashwin-pc pushed a commit to ashwin-pc/OpenSearch-Dashboards that referenced this pull request Oct 19, 2024
…arch-project#8616)

* Sample Queries and Saved Queries in No Results Page

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>

* Changeset file for PR opensearch-project#8616 created/updated

* Update styling

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
sejli added a commit to sejli/OpenSearch-Dashboards that referenced this pull request Oct 21, 2024
…arch-project#8616)

* Sample Queries and Saved Queries in No Results Page

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>

* Changeset file for PR opensearch-project#8616 created/updated

* Update styling

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
ruanyl pushed a commit that referenced this pull request Oct 22, 2024
…, #8650, #8668  (#8670)

* Fix No data selected appearance (#8668)

Also:
* Fix some React errors

Signed-off-by: Miki <[email protected]>

---------

Fix random big number during loading in query editor result (#8650)

* Fix random big number during loading in query editor result

Signed-off-by: abbyhu2000 <[email protected]>

* Changeset file for PR #8650 created/updated

* Fix initial loading number

Signed-off-by: abbyhu2000 <[email protected]>
(cherry picked from commit a7414f0)

---------

[bug] address different issues with dataset selector (#8665)

* [bug] address some issues with dataset selector

Moved the dataset selector back to the search bar and access it by ref in the sidebar.

Avoid out of sync issue.
* update the logic for ensuring index pattern
* dont add ability to open button
* empty state but missing data set selector button
* fix tests
* add back styling

Signed-off-by: Kawika Avilla <[email protected]>
(cherry picked from commit e23f332)

---------

[bug] Discover UI stuck on searching after deleting index pattern (#8659)

* [bug] Discover UI stuck on searching after deleting index pattern

When using Discover with query enhancement enabled, deleting an index pattern from Index Management does not properly update the "Recently selected data" list in Discover. This causes the UI to become stuck in a "Searching" state when attempting to use
Discover after deleting an index pattern.

Handle the error case where the use index patterns hook caught error when
enhancements was enabled.

issue resolved:
#8612

(cherry picked from commit 4808094)

---------

[Discover]Sample Queries and Saved Queries in No Results Page (#8616)

* Sample Queries and Saved Queries in No Results Page

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>

* Changeset file for PR #8616 created/updated

* Update styling

Signed-off-by: Miki <[email protected]>

(cherry picked from commit 9da1b77)

---------

Improve Empty State Handling: Add No Index Patterns Panel with Data Selection in Discover View (#8613)

* Improve Empty State Handling: Add No Index Patterns Panel with Data Selection in Discover View

This PR primarily addresses the scenario when no index patterns (general) is available in the Discover view.
Instead of redirecting users to the index management page, it introduces a new "No Index Patterns" panel.
This panel provides users with the option to open a data selector and add index patterns
directly from the Discover view, improving the user experience for new or empty deployments.

To achieve, we move the selectedDataset state from ConnectedDatasetSelector to the app container's
state management. This allows the AdvancedSelector, opened from the AppContainer, to update
the dataset state effectively. Key changes include:

* Implementing NoIndexPatternsPanel and AdvancedSelector components.
* Refactoring dataset state management in AppContainer and Sidebar.
* Modifying DiscoverCanvas to conditionally render NoIndexPatternsPanel.
* Updating ConnectedDatasetSelector to use shared state and dataset change handling.

* Update design of no data selected
* use i18n
* fix comments
* Update design of no data selected
* fix lint error

Signed-off-by: Anan Zhuang <[email protected]>

(cherry picked from commit 6659139)

---------

Update Discover appearance (#8651)

* Update Discover appearance

Signed-off-by: Miki <[email protected]>

(cherry picked from commit 17103ba)

---------

Move DatasetSelector from data plugin queryString comp to DataExplorer (#8598)

* Move DatasetSelector to DataExplorer
* Style Disover after moving DatasetSelector to DataExplorer
* fix the test by adding the getUpdates$ method to the mock queryString object

Signed-off-by: Anan Zhuang <[email protected]>

(cherry picked from commit 923cce8)

* Resolve merge errors from manual backports

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Miki <[email protected]>
Co-authored-by: Anan Zhuang <[email protected]>
Qxisylolo pushed a commit to Qxisylolo/OpenSearch-Dashboards that referenced this pull request Oct 30, 2024
…arch-project#8616)

* Sample Queries and Saved Queries in No Results Page

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>

* Changeset file for PR opensearch-project#8616 created/updated

* Update styling

Signed-off-by: Miki <[email protected]>

---------

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Miki <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Miki <[email protected]>
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.

4 participants