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

Fix favoriting on label select #908

Merged
merged 9 commits into from
Nov 21, 2024

Conversation

gtk-grafana
Copy link
Contributor

@gtk-grafana gtk-grafana commented Nov 20, 2024

Fixes: #905
Fixes: #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

@gtk-grafana gtk-grafana changed the title "Service" selection: Fix favoriting on label select Fix favoriting on label select Nov 20, 2024
@gtk-grafana gtk-grafana marked this pull request as ready for review November 20, 2024 21:20
@gtk-grafana gtk-grafana requested a review from a team as a code owner November 20, 2024 21:20
src/services/store.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@matyax matyax left a comment

Choose a reason for hiding this comment

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

Fixes the bug, but let's clean this up a bit.

@gtk-grafana
Copy link
Contributor Author

@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!

src/services/store.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@matyax matyax left a comment

Choose a reason for hiding this comment

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

Looks good!

@gtk-grafana gtk-grafana added this to the 1.0.4 milestone Nov 21, 2024
@gtk-grafana gtk-grafana added the bug Something isn't working label Nov 21, 2024
@gtk-grafana gtk-grafana self-assigned this Nov 21, 2024
@gtk-grafana gtk-grafana enabled auto-merge (squash) November 21, 2024 15:10
@gtk-grafana gtk-grafana disabled auto-merge November 21, 2024 15:10
@gtk-grafana gtk-grafana enabled auto-merge (squash) November 21, 2024 15:11
@gtk-grafana gtk-grafana merged commit a45eeff into main Nov 21, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants