Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new BaseObjectHeader class to create detail view header #1104

Draft
wants to merge 11 commits into
base: dependencies
Choose a base branch
from
8 changes: 2 additions & 6 deletions application/controllers/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Icinga\Module\Icingadb\Model\Comment;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\CommentDetail;
use Icinga\Module\Icingadb\Widget\ItemList\CommentList;
use Icinga\Module\Icingadb\Widget\Detail\CommentHeader;
use ipl\Stdlib\Filter;
use ipl\Web\Url;

Expand Down Expand Up @@ -49,11 +49,7 @@ public function init()

public function indexAction()
{
$this->addControl((new CommentList([$this->comment]))
->setViewMode('minimal')
->setDetailActionsDisabled()
->setCaptionDisabled()
->setNoSubjectLink());
$this->addControl(new CommentHeader($this->comment));

$this->addContent((new CommentDetail($this->comment))->setTicketLinkEnabled());

Expand Down
14 changes: 4 additions & 10 deletions application/controllers/DowntimeController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in application/controllers/DowntimeController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:indexAction\(\) has no return type specified\.$# in path /home/runner/work/icingadb-web/icingadb-web/application/controllers/DowntimeController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/DowntimeController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\Icingadb\\Controllers\\DowntimeController\:\:indexAction\(\) has no return type specified\.$# in path /home/runner/work/icingadb-web/icingadb-web/application/controllers/DowntimeController.php was not matched in reported errors.

/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */

Expand All @@ -10,7 +10,7 @@
use Icinga\Module\Icingadb\Model\Downtime;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\DowntimeDetail;
use Icinga\Module\Icingadb\Widget\ItemList\DowntimeList;
use Icinga\Module\Icingadb\Widget\Detail\DowntimeHeader;
use ipl\Stdlib\Filter;
use ipl\Web\Url;

Expand Down Expand Up @@ -57,17 +57,11 @@
$this->downtime = $downtime;
}

public function indexAction()
public function indexAction(): void
{
$detail = new DowntimeDetail($this->downtime);
$this->addControl(new DowntimeHeader($this->downtime));

$this->addControl((new DowntimeList([$this->downtime]))
->setViewMode('minimal')
->setDetailActionsDisabled()
->setCaptionDisabled()
->setNoSubjectLink());

$this->addContent($detail);
$this->addContent(new DowntimeDetail($this->downtime));

$this->setAutorefreshInterval(10);
}
Expand Down
11 changes: 2 additions & 9 deletions application/controllers/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

namespace Icinga\Module\Icingadb\Controllers;

use ArrayObject;
use Icinga\Module\Icingadb\Model\History;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\EventDetail;
use Icinga\Module\Icingadb\Widget\ItemList\HistoryList;
use ipl\Orm\ResultSet;
use Icinga\Module\Icingadb\Widget\Detail\EventHeader;
use ipl\Stdlib\Filter;

class EventController extends Controller
Expand Down Expand Up @@ -60,12 +58,7 @@ public function init()

public function indexAction()
{
$this->addControl((new HistoryList(new ResultSet(new ArrayObject([$this->event]))))
->setViewMode('minimal')
->setPageSize(1)
->setCaptionDisabled()
->setNoSubjectLink()
->setDetailActionsDisabled());
$this->addControl(new EventHeader($this->event));
$this->addContent((new EventDetail($this->event))->setTicketLinkEnabled());
}
}
22 changes: 4 additions & 18 deletions application/controllers/HostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
use Icinga\Module\Icingadb\Redis\VolatileStateResults;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\HostDetail;
use Icinga\Module\Icingadb\Widget\Detail\HostHeader;
use Icinga\Module\Icingadb\Widget\Detail\HostInspectionDetail;
use Icinga\Module\Icingadb\Widget\Detail\HostMetaInfo;
use Icinga\Module\Icingadb\Widget\Detail\QuickActions;
use Icinga\Module\Icingadb\Widget\ItemList\HostList;
use Icinga\Module\Icingadb\Widget\ItemList\HistoryList;
use Icinga\Module\Icingadb\Widget\ItemList\ServiceList;
use ipl\Stdlib\Filter;
Expand Down Expand Up @@ -57,6 +57,8 @@ public function init()
$this->host = $host;
$this->loadTabsForObject($host);

$this->addControl(new HostHeader($this->host));

$this->setTitleTab($this->getRequest()->getActionName());
$this->setTitle($host->display_name);
}
Expand All @@ -72,10 +74,6 @@ public function indexAction()
$this->controls->addAttributes(['class' => 'overdue']);
}

$this->addControl((new HostList([$this->host]))
->setViewMode('objectHeader')
->setDetailActionsDisabled()
->setNoSubjectLink());
$this->addControl(new HostMetaInfo($this->host));
$this->addControl(new QuickActions($this->host));

Expand All @@ -97,10 +95,6 @@ public function sourceAction()
$this->controls->addAttributes(['class' => 'overdue']);
}

$this->addControl((new HostList([$this->host]))
->setViewMode('objectHeader')
->setDetailActionsDisabled()
->setNoSubjectLink());
$this->addContent(new HostInspectionDetail(
$this->host,
reset($apiResult)
Expand Down Expand Up @@ -158,10 +152,6 @@ public function historyAction()

yield $this->export($history);

$this->addControl((new HostList([$this->host]))
->setViewMode('objectHeader')
->setDetailActionsDisabled()
->setNoSubjectLink());
$this->addControl($sortControl);
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
Expand Down Expand Up @@ -221,10 +211,6 @@ public function servicesAction()
$serviceList = (new ServiceList($services))
->setViewMode($viewModeSwitcher->getViewMode());

$this->addControl((new HostList([$this->host]))
->setViewMode('objectHeader')
->setDetailActionsDisabled()
->setNoSubjectLink());
$this->addControl($paginationControl);
$this->addControl($sortControl);
$this->addControl($limitControl);
Expand Down Expand Up @@ -288,6 +274,6 @@ protected function getCommandTargetsUrl(): Url

protected function getDefaultTabControls(): array
{
return [(new HostList([$this->host]))->setDetailActionsDisabled()->setNoSubjectLink()];
return [(new HostHeader($this->host))];
}
}
6 changes: 3 additions & 3 deletions application/controllers/HostgroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions;
use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\HostgroupHeader;
use Icinga\Module\Icingadb\Widget\ItemList\HostList;
use Icinga\Module\Icingadb\Widget\ItemTable\HostgroupTableRow;
use ipl\Html\Html;
use ipl\Stdlib\Filter;
use ipl\Web\Control\LimitControl;
Expand Down Expand Up @@ -114,10 +114,10 @@ public function indexAction(): Generator

// ICINGAWEB_EXPORT_FORMAT is not set yet and $this->format is inaccessible, yeah...
if ($this->getRequest()->getParam('format') === 'pdf') {
$this->addContent(new HostgroupTableRow($hostgroup));
$this->addContent(new HostgroupHeader($hostgroup));
$this->addContent(Html::tag('h2', null, t('Hosts')));
} else {
$this->addControl(new HostgroupTableRow($hostgroup));
$this->addControl(new HostgroupHeader($hostgroup));
}

$this->addControl($paginationControl);
Expand Down
18 changes: 4 additions & 14 deletions application/controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\QuickActions;
use Icinga\Module\Icingadb\Widget\Detail\ServiceDetail;
use Icinga\Module\Icingadb\Widget\Detail\ServiceHeader;
use Icinga\Module\Icingadb\Widget\Detail\ServiceInspectionDetail;
use Icinga\Module\Icingadb\Widget\Detail\ServiceMetaInfo;
use Icinga\Module\Icingadb\Widget\ItemList\HistoryList;
use Icinga\Module\Icingadb\Widget\ItemList\ServiceList;
use ipl\Stdlib\Filter;
use ipl\Web\Url;

Expand Down Expand Up @@ -65,6 +65,8 @@ public function init()
$this->service = $service;
$this->loadTabsForObject($service);

$this->addControl(new ServiceHeader($this->service));

$this->setTitleTab($this->getRequest()->getActionName());
$this->setTitle(
t('%s on %s', '<service> on <host>'),
Expand All @@ -79,10 +81,6 @@ public function indexAction()
$this->controls->addAttributes(['class' => 'overdue']);
}

$this->addControl((new ServiceList([$this->service]))
->setViewMode('objectHeader')
->setDetailActionsDisabled()
->setNoSubjectLink());
$this->addControl(new ServiceMetaInfo($this->service));
$this->addControl(new QuickActions($this->service));

Expand All @@ -104,10 +102,6 @@ public function sourceAction()
$this->controls->addAttributes(['class' => 'overdue']);
}

$this->addControl((new ServiceList([$this->service]))
->setViewMode('objectHeader')
->setDetailActionsDisabled()
->setNoSubjectLink());
$this->addContent(new ServiceInspectionDetail(
$this->service,
reset($apiResult)
Expand Down Expand Up @@ -166,10 +160,6 @@ public function historyAction()

yield $this->export($history);

$this->addControl((new ServiceList([$this->service]))
->setViewMode('objectHeader')
->setDetailActionsDisabled()
->setNoSubjectLink());
$this->addControl($sortControl);
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
Expand Down Expand Up @@ -242,6 +232,6 @@ protected function getCommandTargetsUrl(): Url

protected function getDefaultTabControls(): array
{
return [(new ServiceList([$this->service]))->setDetailActionsDisabled()->setNoSubjectLink()];
return [new ServiceHeader($this->service)];
}
}
6 changes: 3 additions & 3 deletions application/controllers/ServicegroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions;
use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\ServicegroupHeader;
use Icinga\Module\Icingadb\Widget\ItemList\ServiceList;
use Icinga\Module\Icingadb\Widget\ItemTable\ServicegroupTableRow;
use ipl\Html\Html;
use ipl\Stdlib\Filter;
use ipl\Web\Control\LimitControl;
Expand Down Expand Up @@ -122,10 +122,10 @@ public function indexAction(): Generator

// ICINGAWEB_EXPORT_FORMAT is not set yet and $this->format is inaccessible, yeah...
if ($this->getRequest()->getParam('format') === 'pdf') {
$this->addContent(new ServicegroupTableRow($servicegroup));
$this->addContent(new ServicegroupHeader($servicegroup));
$this->addContent(Html::tag('h2', null, t('Services')));
} else {
$this->addControl(new ServicegroupTableRow($servicegroup));
$this->addControl(new ServicegroupHeader($servicegroup));
}

$this->addControl($paginationControl);
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Icinga\Module\Icingadb\Model\User;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\UserDetail;
use Icinga\Module\Icingadb\Widget\ItemTable\UserTableRow;
use Icinga\Module\Icingadb\Widget\Detail\UserHeader;
use ipl\Stdlib\Filter;

class UserController extends Controller
Expand Down Expand Up @@ -40,7 +40,7 @@ public function init()

public function indexAction()
{
$this->addControl(new UserTableRow($this->user));
$this->addControl(new UserHeader($this->user));
$this->addContent(new UserDetail($this->user));

$this->setAutorefreshInterval(10);
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/UsergroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Icinga\Module\Icingadb\Model\Usergroup;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\UsergroupDetail;
use Icinga\Module\Icingadb\Widget\ItemTable\UsergroupTableRow;
use Icinga\Module\Icingadb\Widget\Detail\UsergroupHeader;
use ipl\Stdlib\Filter;

class UsergroupController extends Controller
Expand Down Expand Up @@ -40,7 +40,7 @@ public function init()

public function indexAction()
{
$this->addControl(new UsergroupTableRow($this->usergroup));
$this->addControl(new UsergroupHeader($this->usergroup));
$this->addContent(new UsergroupDetail($this->usergroup));

$this->setAutorefreshInterval(10);
Expand Down
31 changes: 0 additions & 31 deletions library/Icingadb/Common/CaptionDisabled.php

This file was deleted.

6 changes: 1 addition & 5 deletions library/Icingadb/Common/ListItemCommonLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

trait ListItemCommonLayout
{
use CaptionDisabled;

protected function assembleHeader(BaseHtmlElement $header): void
{
$header->addHtml($this->createTitle());
Expand All @@ -19,8 +17,6 @@ protected function assembleHeader(BaseHtmlElement $header): void
protected function assembleMain(BaseHtmlElement $main): void
{
$main->addHtml($this->createHeader());
if (!$this->isCaptionDisabled()) {
$main->addHtml($this->createCaption());
}
$main->addHtml($this->createCaption());
}
}
6 changes: 1 addition & 5 deletions library/Icingadb/Common/ListItemMinimalLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@

trait ListItemMinimalLayout
{
use CaptionDisabled;

protected function assembleHeader(BaseHtmlElement $header): void
{
$header->add($this->createTitle());
if (! $this->isCaptionDisabled()) {
$header->add($this->createCaption());
}
$header->add($this->createCaption());
$header->add($this->createTimestamp());
}

Expand Down
35 changes: 0 additions & 35 deletions library/Icingadb/Common/NoSubjectLink.php

This file was deleted.

Loading
Loading