Don't show parents children tab if icingadb.schema does not support it

This commit is contained in:
Sukhwinder Dhillon 2024-12-18 12:53:57 +01:00
parent cda2f4bb05
commit b69fb09c90
2 changed files with 24 additions and 15 deletions

View file

@ -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', [

View file

@ -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(