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 ae3b36a commit 03a160d
Show file tree
Hide file tree
Showing 2 changed files with 24 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 @@ -434,13 +435,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
20 changes: 12 additions & 8 deletions application/controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,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 @@ -424,7 +428,7 @@ protected function createTabs(): Tabs
'url' => ServiceLinks::history($this->service, $this->service->host)
]);

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

0 comments on commit 03a160d

Please sign in to comment.