Suggestion: Remove Dashboard Sidebar Menu When Empty

I don’t use the Dashboards module but it always shows in the navbar.

I suggest the following change to dashboard_menu.php:

$listmenu = $dashboard->build_menu_array('view'); //BB: move this to get the list before including the menu in the navbar

if(!empty($listmenu)) { //BB: if the list is empty, don't put the menu in the navbar
  // navbar link
  $menu['tabs'][] = array(
      'icon'=>'dashboard',
      'text'=> dgettext("dashboard_messages","Dashboards"),
      'path'=> 'dashboard/view',
      'order' => 3,
      'data'=> array('sidebar' => '#sidebar_dashboard')
  );
}
1 Like

The problem with this is that it is the only route to the Dashboard menu - It does not appear in the left menu.

Sorry, yes, you are right.

I should have said that I find this menu annoying when I am providing an app with a read-only apikey to someone. In this situation they can’t use the menu to create a dashboard, so it is just a dead button.

Let me amend my proposal.

$listmenu = $dashboard->build_menu_array('view');
	
	
if(!empty($listmenu) || $session["write"]) { //if the dashboard menu isn't empty, or if the session is write, show the menu
// navbar link
$menu['tabs'][] = array(
    'icon'=>'dashboard',
    'text'=> dgettext("dashboard_messages","Dashboards"),
    'path'=> 'dashboard/view',
    'order' => 3,
    'data'=> array('sidebar' => '#sidebar_dashboard')
);
}

Stick it up as a PR on GitHub. You can just edit the file on the web interface - no need to clone locally etc.