What version are you running?
Review Board 2.0.1
What's the URL of the page this enhancement relates to, if any?
The main dashboard.
Describe the enhancement and the motivation for it.
The full discussion is tracked here:
https://groups.google.com/d/msg/reviewboard/dBgLHUrjyp8/WOLTOnbkF4wJ
I would like to be able to add SidebarNavItems that add custom queries to the main dashboard.
I attempted this by writing my own DashboardDataGrid and SidebarSection, and then passing them both into DataGridSidebarItemsHook, but it seems that you need to pass a datagrid that already exists.
Here is a condensed version of the code I attempted for quick reference:
class MyDashboardDataGrid(DashboardDataGrid):
def load_extra_state(self, profile):
# pass custom queryset and change title
view = self.request.GET.get('view', self.default_view)
q = Q(repository__name='MyRepo', target_groups__name='internal', status='P')
if view == 'outstanding':
q = q & Q(shipit_count__lt=2, issue_open_count=0) # TODO: make sure the review isn't yours
self.queryset = ReviewRequest.objects.filter(q)
self.title = _('Requests That Need Reviews (Reviews with # ship-its < 2, no open issues, not yours)')
return super(MyDashboardDataGrid, self).load_extra_state(profile)
class MySidebarSection(BaseSidebarSection):
label = 'My Dashboard'
def get_items(self):
yield SidebarNavItem(self, 'Needs More Reviews', view_id='outstanding')
class MyDashboard(Extension):
metadata = {
'Name': 'My Dashboard',
'Summary': 'Summary here',
}
is_configurable = True
def initialize(self):
# Your extension initialization is done here.
DataGridSidebarItemsHook(self, MyDashboardDataGrid, [MySidebarSection])
What operating system are you using? What browser?
Windows and Ubuntu. Mostly Chrome.
Please provide any additional information below.
Thanks!