-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Changes from 3 commits
5a91d15
a5ee7d9
42e9201
3ea4034
a778a7f
45c8c18
ea530be
e6cd423
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,6 +375,16 @@ export function getDiscoverStateContainer({ | |
* state containers initializing and subscribing to changes triggering e.g. data fetching | ||
*/ | ||
const initializeAndSync = () => { | ||
// 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(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
savedSearchContainer.update({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method contains a lot of logic. What if we apply only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made an update, is this what you had in mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, thanks! I think we also need to update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, could you take another look? |
||
nextDataView: internalStateContainer.getState().dataView, | ||
nextState: appStateContainer.getState(), | ||
useFilterAndQueryServices: true, | ||
}); | ||
}); | ||
|
||
// initialize app state container, syncing with _g and _a part of the URL | ||
const appStateInitAndSyncUnsubscribe = appStateContainer.initAndSync( | ||
savedSearchContainer.getState() | ||
|
@@ -426,6 +436,7 @@ export function getDiscoverStateContainer({ | |
appStateUnsubscribe(); | ||
appStateInitAndSyncUnsubscribe(); | ||
filterUnsubscribe.unsubscribe(); | ||
timefilerUnsubscribe.unsubscribe(); | ||
}; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -54,6 +54,9 @@ export function updateSavedSearch({ | |||||||
.setField('query', state.query ?? undefined) | ||||||||
.setField('filter', [...globalFilters, ...appFilters]); | ||||||||
} | ||||||||
if (savedSearch.timeRestore) { | ||||||||
savedSearch.timeRange = services.timefilter.getTime(); | ||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It should already work based on the code at the end of the function. Doesn't it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, missed that, thanks! |
||||||||
if (state) { | ||||||||
savedSearch.columns = state.columns || []; | ||||||||
savedSearch.sort = (state.sort as SortOrder[]) || []; | ||||||||
|
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.
ℹ️ Making the mocked saved search more realistic, as these are filled in automatically when discover loads the saved search