From 3be596641fef0713b8ec1aa5b383369b43f565a8 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 8 Jun 2022 16:14:54 +0200 Subject: [PATCH] Render also the cog icon when there is more than 1 home --- application/controllers/DashboardsController.php | 14 ++++++++++---- .../Web/Dashboard/Common/DashboardManager.php | 2 +- library/Icinga/Web/Dashboard/Dashboard.php | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/application/controllers/DashboardsController.php b/application/controllers/DashboardsController.php index 6f17a656a..bac7c1452 100644 --- a/application/controllers/DashboardsController.php +++ b/application/controllers/DashboardsController.php @@ -48,8 +48,6 @@ class DashboardsController extends CompatController $pane = $this->getParam('pane'); $this->dashboard->load(DashboardHome::DEFAULT_HOME, $pane); - $this->createTabs(); - $activeHome = $this->dashboard->getActiveHome(); if (! $activeHome || ! $activeHome->hasEntries()) { $this->addTitleTab(t('Welcome')); @@ -64,6 +62,8 @@ class DashboardsController extends CompatController $this->dashboard->addHtml($welcomeForm); } + $this->createTabs(); + $this->addContent($this->dashboard); } @@ -472,9 +472,15 @@ class DashboardsController extends CompatController { $tabs = $this->dashboard->getTabs(); $activeHome = $this->dashboard->getActiveHome(); - if ($activeHome && ($activeHome->getName() !== DashboardHome::DEFAULT_HOME || $activeHome->hasEntries())) { + if ($activeHome + && ( + ! $activeHome->isDefaultHome() + || $activeHome->hasEntries() + || count($this->dashboard->getEntries()) > 1 + ) + ) { $params = []; - if ($activeHome->getName() !== DashboardHome::DEFAULT_HOME) { + if (! $activeHome->isDefaultHome()) { $params['home'] = $activeHome->getName(); } diff --git a/library/Icinga/Web/Dashboard/Common/DashboardManager.php b/library/Icinga/Web/Dashboard/Common/DashboardManager.php index f97c84b78..fea2831c8 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardManager.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardManager.php @@ -144,7 +144,7 @@ trait DashboardManager $home = $home instanceof DashboardHome ? $home : $this->getEntry($home); $home->removeEntries(); - if ($home->getName() !== DashboardHome::DEFAULT_HOME) { + if (! $home->isDefaultHome()) { DBUtils::getConn()->delete(DashboardHome::TABLE, ['id = ?' => $home->getUuid()]); } elseif (! $home->isDisabled()) { DBUtils::getConn()->update(DashboardHome::TABLE, ['disabled' => DBUtils::bool2BoolEnum(true)], [ diff --git a/library/Icinga/Web/Dashboard/Dashboard.php b/library/Icinga/Web/Dashboard/Dashboard.php index 101d63b0b..bf1c1b985 100644 --- a/library/Icinga/Web/Dashboard/Dashboard.php +++ b/library/Icinga/Web/Dashboard/Dashboard.php @@ -114,7 +114,7 @@ class Dashboard extends BaseHtmlElement implements DashboardEntry public function getTabs() { $activeHome = $this->getActiveHome(); - if ($activeHome && $activeHome->getName() !== DashboardHome::DEFAULT_HOME) { + if ($activeHome && ! $activeHome->isDefaultHome()) { $url = Url::fromPath(self::BASE_ROUTE . '/home')->getUrlWithout(['home', $this->tabParam]); $url->addParams(['home' => $activeHome->getName()]); } else {