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] Show "Unsaved changes" badge on time filter changes in case time range is stored along with saved search #178659

Merged
merged 8 commits into from
Mar 20, 2024

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Mar 13, 2024

Closes #172288

There's two parts to this:

  • When updating the saved search, update the time range as well using the current state of the services.timefilter instance
  • Similar to filter updates, run an update action on the state container if the time changes

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@@ -375,6 +375,14 @@ export function getDiscoverStateContainer({
* state containers initializing and subscribing to changes triggering e.g. data fetching
*/
const initializeAndSync = () => {
const timefilerUnsubscribe = services.timefilter.getTimeUpdate$().subscribe(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ This needs to be the first thing that's wired up because the next line is pulling the current state from the URL which might change the time filter and thus needs to re-check whether the saved search has changed

@flash1293 flash1293 added Feature:Discover Discover Application backport:skip This commit does not require backporting Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.14.0 release_note:fix labels Mar 14, 2024
@@ -17,6 +17,8 @@ export const savedSearchMock = {
id: 'the-saved-search-id',
title: 'A saved search',
searchSource: createSearchSourceMock({ index: dataViewMock }),
columns: ['default_column'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ Making the mocked saved search more realistic, as these are filled in automatically when discover loads the saved search

@flash1293 flash1293 marked this pull request as ready for review March 14, 2024 10:46
@flash1293 flash1293 requested a review from a team as a code owner March 14, 2024 10:46
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@flash1293
Copy link
Contributor Author

/ci

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Hi Joe,
Thanks for working on the fix! Left some comments.

// This needs to be the first thing that's wired up because initAndSync is pulling the current state from the URL which
// might change the time filter and thus needs to re-check whether the saved search has changed.
const timefilerUnsubscribe = services.timefilter.getTimeUpdate$().subscribe(() => {
savedSearchContainer.update({
Copy link
Contributor

Choose a reason for hiding this comment

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

This method contains a lot of logic. What if we apply only timeRange and refreshInterval changes here instead of the whole update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made an update, is this what you had in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, thanks! I think we also need to update refreshInterval if it got changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, could you take another look?

Comment on lines 57 to 59
if (savedSearch.timeRestore) {
savedSearch.timeRange = services.timefilter.getTime();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (savedSearch.timeRestore) {
savedSearch.timeRange = services.timefilter.getTime();
}

It should already work based on the code at the end of the function. Doesn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, missed that, thanks!

@flash1293
Copy link
Contributor Author

/ci

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Works great, thanks! 👍

…d_search.test.ts

Co-authored-by: Julia Rechkunova <julia.rechkunova@gmail.com>
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 581.8KB 582.2KB +413.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@flash1293 flash1293 merged commit 5012949 into elastic:main Mar 20, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Discover Discover Application release_note:fix Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.14.0
Projects
None yet
5 participants