Skip to content

Commit

Permalink
Allow using non-row panels in dashboard's panels (#684)
Browse files Browse the repository at this point in the history
As discussed in grafana/grafana#50855 (comment), panels of rows with collapsed=False should be added to the list of panels that contains that row.

Adding non-row panels makes auto_panel_ids() fail with
```
  File ".../grafanalib/core.py", line 1751, in auto_panel_ids
    ids = set([panel.id for panel in self._iter_panels() if panel.id])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../grafanalib/core.py", line 1731, in _iter_panels
    for row_panel in panel._iter_panels():
                     ^^^^^^^^^^^^^^^^^^
AttributeError: 'TimeSeries' object has no attribute '_iter_panels'
```

This change fixes this exception.
  • Loading branch information
max-melentyev authored Jan 3, 2025
1 parent 5c3b17e commit 3ed1a9c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions grafanalib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,12 +1825,10 @@ def _iter_panels(self):
yield panel

for panel in self.panels:
if hasattr(panel, 'panels'):
yield panel
yield panel
if hasattr(panel, '_iter_panels'):
for row_panel in panel._iter_panels():
yield row_panel
else:
yield panel

def _map_panels(self, f):
return attr.evolve(
Expand Down

0 comments on commit 3ed1a9c

Please sign in to comment.