Skip to content

Commit

Permalink
Don't show parents children tab if icingadb.schema version < 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Dec 18, 2024
1 parent 6fb2e4b commit fb557c7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
19 changes: 12 additions & 7 deletions application/controllers/HostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;
Expand Down Expand Up @@ -432,13 +433,17 @@ protected function fetchNodes(bool $fetchParents = false): Query

protected function createTabs(): Tabs
{
$hasDependencyNode = DependencyNode::on($this->getDb())
->columns('1')
->filter(Filter::all(
Filter::equal('host_id', $this->host->id),
Filter::unlike('service_id', '*')
))
->first() !== null;
if (Backend::getDbSchemaVersion() < 6) {
$hasDependencyNode = false;
} else {
$hasDependencyNode = DependencyNode::on($this->getDb())
->columns('1')
->filter(Filter::all(
Filter::equal('host_id', $this->host->id),
Filter::unlike('service_id', '*')
))
->first() !== null;
}

$tabs = $this->getTabs()
->add('index', [
Expand Down
21 changes: 13 additions & 8 deletions application/controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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\Links;
use Icinga\Module\Icingadb\Common\ServiceLinks;
Expand Down Expand Up @@ -400,13 +401,17 @@ protected function fetchNodes(bool $fetchParents = false): Query

protected function createTabs(): Tabs
{
$hasDependecyNode = DependencyNode::on($this->getDb())
->columns('1')
->filter(Filter::all(
Filter::equal('service_id', $this->service->id),
Filter::equal('host_id', $this->service->host_id)
))
->first() !== null;
if (Backend::getDbSchemaVersion() < 6) {
$hasDependencyNode = false;
} else {
$hasDependencyNode = DependencyNode::on($this->getDb())
->columns('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', [
Expand All @@ -418,7 +423,7 @@ protected function createTabs(): Tabs
'url' => ServiceLinks::history($this->service, $this->service->host)
]);

if ($hasDependecyNode) {
if ($hasDependencyNode) {
$tabs->add('parents', [
'label' => t('Parents'),
'url' => Url::fromPath(
Expand Down

0 comments on commit fb557c7

Please sign in to comment.