diff --git a/application/controllers/DashboardsController.php b/application/controllers/DashboardsController.php index 4f75e5888..bd2b9ea13 100644 --- a/application/controllers/DashboardsController.php +++ b/application/controllers/DashboardsController.php @@ -410,6 +410,18 @@ class DashboardsController extends CompatController public function settingsAction() { $this->dashboard->load(); + + $highlightHome = $this->params->get('home'); + if ($highlightHome) { + if (! $this->dashboard->hasEntry($highlightHome)) { + $this->httpNotFound(t('Home "%s" not found'), $highlightHome); + } + + $home = $this->dashboard->getEntry($highlightHome); + $this->dashboard->activateHome($home); + $home->loadDashboardEntries(); // createTabs() won't get the panes otherwise + } + $this->createTabs(); $activeHome = $this->dashboard->getActiveHome(); @@ -444,7 +456,12 @@ class DashboardsController extends CompatController $tabs = $this->dashboard->getTabs(); $activeHome = $this->dashboard->getActiveHome(); if ($activeHome && ($activeHome->getName() !== DashboardHome::DEFAULT_HOME || $activeHome->hasEntries())) { - $tabs->extend(new DashboardSettings()); + $params = []; + if ($activeHome->getName() !== DashboardHome::DEFAULT_HOME) { + $params['home'] = $activeHome->getName(); + } + + $tabs->extend(new DashboardSettings($params)); } return $tabs; diff --git a/library/Icinga/Web/Dashboard/Common/ItemListControl.php b/library/Icinga/Web/Dashboard/Common/ItemListControl.php index 7ed02feff..fed31d192 100644 --- a/library/Icinga/Web/Dashboard/Common/ItemListControl.php +++ b/library/Icinga/Web/Dashboard/Common/ItemListControl.php @@ -23,6 +23,13 @@ abstract class ItemListControl extends BaseHtmlElement */ abstract protected function getHtmlId(): string; + /** + * Get whether the item should be expanded by default + * + * @return bool + */ + abstract protected function shouldExpandByDefault(): bool; + /** * Get a class name for the collapsible control * @@ -84,7 +91,8 @@ abstract class ItemListControl extends BaseHtmlElement { $this->getAttributes()->add([ 'id' => $this->getHtmlId(), - 'class' => 'collapsible' + 'class' => 'collapsible', + 'open' => $this->shouldExpandByDefault() ]); $this->addHtml($this->createItemList()); diff --git a/library/Icinga/Web/Dashboard/ItemList/DashboardHomeList.php b/library/Icinga/Web/Dashboard/ItemList/DashboardHomeList.php index 2967115d4..5f9eac3ec 100644 --- a/library/Icinga/Web/Dashboard/ItemList/DashboardHomeList.php +++ b/library/Icinga/Web/Dashboard/ItemList/DashboardHomeList.php @@ -53,6 +53,11 @@ class DashboardHomeList extends ItemListControl return $this->home->getUuid(); } + protected function shouldExpandByDefault(): bool + { + return $this->home->getActive(); + } + protected function getCollapsibleControlClass(): string { return 'dashboard-list-info'; diff --git a/library/Icinga/Web/Dashboard/ItemList/DashboardList.php b/library/Icinga/Web/Dashboard/ItemList/DashboardList.php index 69b41c598..a4deba46b 100644 --- a/library/Icinga/Web/Dashboard/ItemList/DashboardList.php +++ b/library/Icinga/Web/Dashboard/ItemList/DashboardList.php @@ -35,6 +35,11 @@ class DashboardList extends ItemListControl return bin2hex($this->pane->getUuid()); } + protected function shouldExpandByDefault(): bool + { + return $this->pane->getHome()->getActive(); + } + protected function getCollapsibleControlClass(): string { return 'dashlets-list-info';