Skip to content

Commit 1b60197

Browse files
feat: Add filtering by folder to DashboardList
1 parent 6b6fea7 commit 1b60197

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

grafanalib/core.py

+25-19
Original file line numberDiff line numberDiff line change
@@ -3943,28 +3943,34 @@ class DashboardList(Panel):
39433943
searchQuery = attr.ib(default='', validator=instance_of(str))
39443944
searchTags = attr.ib(default=attr.Factory(list), validator=instance_of(list))
39453945
overrides = attr.ib(default=attr.Factory(list))
3946+
folderUID = attr.ib(default=None, validator=optional(instance_of(str)))
3947+
3948+
def __attrs_post_init__(self):
3949+
if self.folderUID is not None:
3950+
self.showSearch = True
39463951

39473952
def to_json_data(self):
3948-
return self.panel_json(
3949-
{
3950-
'fieldConfig': {
3951-
'defaults': {
3952-
'custom': {},
3953-
},
3954-
'overrides': self.overrides
3955-
},
3956-
'options': {
3957-
'headings': self.showHeadings,
3958-
'search': self.showSearch,
3959-
'recent': self.showRecent,
3960-
'starred': self.showStarred,
3961-
'limit': self.maxItems,
3962-
'query': self.searchQuery,
3963-
'tags': self.searchTags,
3964-
'type': DASHBOARDLIST_TYPE,
3953+
panel_data = {
3954+
'fieldConfig': {
3955+
'defaults': {
3956+
'custom': {},
39653957
},
3966-
}
3967-
)
3958+
'overrides': self.overrides
3959+
},
3960+
'options': {
3961+
'headings': self.showHeadings,
3962+
'search': self.showSearch,
3963+
'recent': self.showRecent,
3964+
'starred': self.showStarred,
3965+
'limit': self.maxItems,
3966+
'query': self.searchQuery,
3967+
'tags': self.searchTags,
3968+
'type': DASHBOARDLIST_TYPE,
3969+
},
3970+
}
3971+
if self.folderUID is not None:
3972+
panel_data['options']['folderUID'] = self.folderUID
3973+
return self.panel_json(panel_data)
39683974

39693975

39703976
@attr.s

0 commit comments

Comments
 (0)