Should add any label to favorites when adding any ad hoc filter in the UI except for in the combobox.
Also fixes a bug with the service selection search where a custom filter would be actively filtering the labels returned in the UI, but the search input was empty and was not able to be cleared.
Now whenever labels are added (besides directly in the combobox), that label is favorited, and pushed to the top of the dropdowns, and the top of the service list on the next render (I don't think we want to change the order of the service selection list as users are adding filters).
I wasn't happy with subscribing to the combobox and favoriting whenever something was added as we didn't have the context needed to re-render components after adding things to local storage, adding full combobox support could be solved by subscribing in the ServiceScene, and ServiceSelection scene, and avoiding the re-rendering in the ServiceScene since nothing in the UI displays the favorites.
We might want to refactor the components that consume local storage to listen to events or subscribe to some top-level state for re-rendering to get this in a more future proof state.
@matyax I cleaned up the unit test hack (mocked out the local storage functions like you suggested) and refactored a bit. If you could take another look I'd appreciate it!
Fixes: https://github.com/grafana/explore-logs/issues/905 Fixes: https://github.com/grafana/explore-logs/issues/904
Should add any label to favorites when adding any ad hoc filter in the UI except for in the combobox.
Also fixes a bug with the service selection search where a custom filter would be actively filtering the labels returned in the UI, but the search input was empty and was not able to be cleared.
Now whenever labels are added (besides directly in the combobox), that label is favorited, and pushed to the top of the dropdowns, and the top of the service list on the next render (I don't think we want to change the order of the service selection list as users are adding filters).
I wasn't happy with subscribing to the combobox and favoriting whenever something was added as we didn't have the context needed to re-render components after adding things to local storage, adding full combobox support could be solved by subscribing in the ServiceScene, and ServiceSelection scene, and avoiding the re-rendering in the ServiceScene since nothing in the UI displays the favorites.
We might want to refactor the components that consume local storage to listen to events or subscribe to some top-level state for re-rendering to get this in a more future proof state.
Need to follow up with addressing adding combobox filters to favorites in another PR