From b69fb09c9072bbf2bfb7519275a2cd42e71e7204 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 18 Dec 2024 12:53:57 +0100 Subject: [PATCH] Don't show `parents` `children` tab if `icingadb.schema` does not support it --- application/controllers/HostController.php | 19 +++++++++++------- application/controllers/ServiceController.php | 20 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index d47a8e3d..c900f570 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -8,6 +8,7 @@ use ArrayIterator; use Icinga\Exception\NotFoundError; use Icinga\Module\Icingadb\Command\Object\GetObjectCommand; use Icinga\Module\Icingadb\Command\Transport\CommandTransport; +use Icinga\Module\Icingadb\Common\Backend; use Icinga\Module\Icingadb\Common\CommandActions; use Icinga\Module\Icingadb\Common\HostLinks; use Icinga\Module\Icingadb\Common\Links; @@ -434,13 +435,17 @@ class HostController extends Controller protected function createTabs(): Tabs { - $hasDependencyNode = DependencyNode::on($this->getDb()) - ->columns([new Expression('1')]) - ->filter(Filter::all( - Filter::equal('host_id', $this->host->id), - Filter::unlike('service_id', '*') - )) - ->first() !== null; + if (! Backend::supportsDependencies()) { + $hasDependencyNode = false; + } else { + $hasDependencyNode = DependencyNode::on($this->getDb()) + ->columns([new Expression('1')]) + ->filter(Filter::all( + Filter::equal('host_id', $this->host->id), + Filter::unlike('service_id', '*') + )) + ->first() !== null; + } $tabs = $this->getTabs() ->add('index', [ diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index ec09701f..0d5a5164 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -407,13 +407,17 @@ class ServiceController extends Controller protected function createTabs(): Tabs { - $hasDependecyNode = DependencyNode::on($this->getDb()) - ->columns([new Expression('1')]) - ->filter(Filter::all( - Filter::equal('service_id', $this->service->id), - Filter::equal('host_id', $this->service->host_id) - )) - ->first() !== null; + if (! Backend::supportsDependencies()) { + $hasDependencyNode = false; + } else { + $hasDependencyNode = DependencyNode::on($this->getDb()) + ->columns([new Expression('1')]) + ->filter(Filter::all( + Filter::equal('service_id', $this->service->id), + Filter::equal('host_id', $this->service->host_id) + )) + ->first() !== null; + } $tabs = $this->getTabs() ->add('index', [ @@ -425,7 +429,7 @@ class ServiceController extends Controller 'url' => ServiceLinks::history($this->service, $this->service->host) ]); - if ($hasDependecyNode) { + if ($hasDependencyNode) { $tabs->add('parents', [ 'label' => $this->translate('Parents'), 'url' => Url::fromPath(