weaveworks / grafanalib

Python library for building Grafana dashboards
Apache License 2.0
1.86k stars 309 forks source link

BUG: Panel ID's are being left as null which is making grafanalib dashboards un-editable #598

Open a-szegel opened 1 year ago

a-szegel commented 1 year ago

I saw an issue where panel.id for Row objects, the nested panel's panel.id is not being properly updated via auto_panel_ids(). They were being left as null. This diff is what fixed me, but I am not sure why it wasn't working as is.

The behavior that I was seeing was that I would click edit on a panel and nothing would happen. I have confirmed that this fix fixes me, and allows panels to be used like normal dashboards (created with the GUI).

         def set_id(panel):
-            return panel if panel.id else attr.evolve(panel, id=next(auto_ids))
+            if panel.id:
+                return panel
+            else:
+                panel.id = next(auto_ids)
+                return panel
+