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

Reset dirty saved query on reload #43927

Merged
merged 4 commits into from
Aug 27, 2019

Conversation

TinaHeiligers
Copy link
Contributor

Summary

This PR ensures any changes made to a saved query are discarded when it is reloaded.
Addresses 43887

Previous behavior:
When a saved query is reloaded using the Saved Query management popover and changes have been made to the saved query, the changes persist.
dirty_saved_query_must_be_cleared

New behavior:
Any changes made to the loaded saved query when reloaded are discarded.

Clear_loaded_saved_query_changes_on_reload_smaller

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials

For maintainers

- [ ] This was checked for breaking API changes and was labeled appropriately
- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately

@TinaHeiligers TinaHeiligers added release_note:enhancement v7.4.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Aug 23, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Code LGTM, thanks for the change

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@@ -145,6 +145,7 @@ export const SavedQueryManagementComponent: FunctionComponent<Props> = ({
savedQuery={savedQuery}
isSelected={!!loadedSavedQuery && loadedSavedQuery.id === savedQuery.id}
onSelect={savedQueryToSelect => {
onClearSavedQuery();
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately this causes two search requests to elasticsearch to fire, one after the clear and one after the load. It think it would be better to handle this in the app controller. In Discover for example, we can change this line to be $scope.savedQuery = { ...savedQuery }; and that will fix the problem.

The issue is that $scope.savedQuery === savedQuery in this particular case, so even though we're assigning $scope.savedQuery the watcher here won't fire because there was no change. By creating a copy in onSavedQueryUpdated we signal to angular that a change has happened and the watcher needs to fire. The same thing can be done in Visualize and Dashboard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Bargs thanks for catching that! I made the changes that you recommended and checked that there is only one request to elasticsearch. Resetting a dirty state on reload of a saved query is now handled by the app controllers: Discover, Dashboard, and Visualize.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@Bargs Bargs left a comment

Choose a reason for hiding this comment

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

LGTM

@TinaHeiligers TinaHeiligers merged commit 43df3a7 into elastic:master Aug 27, 2019
TinaHeiligers added a commit that referenced this pull request Aug 27, 2019
* Clears changes a loaded saved query before loading another one

* Adds general functional test to ensure changes to a saved query are discarded on reloading it

* Moves resetting a dirty saved query to the app controllers in Discover, Visualize and Dashboard
@TinaHeiligers TinaHeiligers deleted the reset-dirty-saved-query branch August 27, 2019 20:55
@TinaHeiligers TinaHeiligers mentioned this pull request Sep 4, 2019
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants