grafana / iot-sitewise-datasource

IoT Sitewise
Apache License 2.0
19 stars 9 forks source link

Unable to select assets by hierarchy after selecting by model #284

Open sarahzinger opened 4 months ago

sarahzinger commented 4 months ago

What happened: I was switching between selecting an asset using the Asset Browser (click on "Explore" folder--note not related to grafana's explore page) and noticed that I have a choice between selecting assets by hierarchy or by model. If I choose a model and then clear it I'm unable to select by hierarchy unless I refresh the page.

What you expected to happen: I would expect a page refresh to be unnecessary to deselect and reselect an asset regardless of if it is a model or hierarchy asset.

How to reproduce it (as minimally and precisely as possible):

Environment:

tracy-french commented 4 months ago

@sarahzinger I believe part of the issue is there is an asset model selection stored in state, which is hidden in the asset browser modal (i.e., not represented in the query editor). You also cannot deselect the selected asset model from the asset browser. Only a different asset model may be selected. It appears the only way to get out of listing assets by asset model is to delete the query or refresh the page.

Could a solution to this issue be allowing the deselection of the asset model? It could be done in the asset browser by allowing the drop-down to be cleared and/or we could show the selected asset model in the query editor and allow the user to deselect it without requiring them to open the asset browser.

sarahzinger commented 4 months ago

@tracy-french yeah I imagine there are a few potential solutions we could consider, I'm not sure I have enough context to know the best solution just yet. It seems to me like like we pass any state as props down to the modal, no?

As a side note: I personally find it a bit confusing that we have both the modal and the dropdown. I wonder if it might make sense to put all selection/state in the modal and run the fetch for models/assets when you move from one tab to another? And then we can do what you were suggesting as well and deselect within the modal as well.

I also think this modal in general could you some ui improvements. It might be good to checkout the Cloudwatch Datasource for inspiration. In the query editor when you select log groups you can query all log groups and also deselect there as well. But we also have the ability to remove a selection from outside of the modal, but if you want to reselect you need to open the modal again.

Screenshot 2024-02-28 at 12 43 06 PM Screenshot 2024-02-28 at 12 43 20 PM