Skip to content

Commit

Permalink
Use ipl web utilities (#112)
Browse files Browse the repository at this point in the history
##Blocked by

- Icinga/ipl-web#183
  • Loading branch information
nilmerg authored Mar 27, 2024
2 parents fa9dc6c + 7cf22da commit a28ca46
Show file tree
Hide file tree
Showing 26 changed files with 67 additions and 517 deletions.
2 changes: 1 addition & 1 deletion application/controllers/ChannelsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Icinga\Module\Notifications\Controllers;

use Icinga\Module\Notifications\Common\BaseItemList;
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Forms\ChannelForm;
use Icinga\Module\Notifications\Model\Channel;
Expand All @@ -16,6 +15,7 @@
use ipl\Html\ValidHtml;
use ipl\Sql\Connection;
use ipl\Stdlib\Filter;
use ipl\Web\Common\BaseItemList;
use ipl\Web\Compat\CompatController;
use ipl\Web\Compat\SearchControls;
use ipl\Web\Control\LimitControl;
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace Icinga\Module\Notifications\Controllers;

use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
use Icinga\Module\Notifications\Common\BaseItemList;
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Model\Contact;
use Icinga\Module\Notifications\Web\Form\ContactForm;
use Icinga\Module\Notifications\Widget\ItemList\ContactList;
use Icinga\Web\Notification;
use ipl\Sql\Connection;
use ipl\Stdlib\Filter;
use ipl\Web\Common\BaseItemList;
use ipl\Web\Compat\CompatController;
use ipl\Web\Compat\SearchControls;
use ipl\Web\Control\LimitControl;
Expand Down
76 changes: 0 additions & 76 deletions library/Notifications/Common/BaseItemList.php

This file was deleted.

132 changes: 0 additions & 132 deletions library/Notifications/Common/BaseListItem.php

This file was deleted.

6 changes: 6 additions & 0 deletions library/Notifications/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
use ipl\Orm\Behavior\MillisecondTimestamp;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Query;
use ipl\Orm\Relations;

/**
* Event model
*
* @property Query|Incident $incident
*/
class Event extends Model
{
public function getTableName()
Expand Down
5 changes: 5 additions & 0 deletions library/Notifications/Model/Incident.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;

/**
* Incident Model
*
* @property int $id
*/
class Incident extends Model
{
public function getTableName()
Expand Down
14 changes: 12 additions & 2 deletions library/Notifications/Widget/Detail/EventDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

use Icinga\Date\DateFormatter;
use Icinga\Module\Notifications\Model\Event;
use Icinga\Module\Notifications\Model\Incident;
use Icinga\Module\Notifications\Model\Objects;
use Icinga\Module\Notifications\Widget\EventSourceBadge;
use Icinga\Module\Notifications\Widget\ItemList\IncidentList;
use InvalidArgumentException;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Html\ValidHtml;
Expand All @@ -21,6 +23,9 @@ class EventDetail extends BaseHtmlElement
/** @var Event */
protected $event;

/** @var Incident */
protected $incident;

protected $defaultAttributes = [
'class' => 'event-detail',
'data-pdfexport-page-breaks-at' => 'h2'
Expand All @@ -30,7 +35,12 @@ class EventDetail extends BaseHtmlElement

public function __construct(Event $event)
{
if (! $event->incident instanceof Incident) {
throw new InvalidArgumentException('Incidents must be loaded with the event');
}

$this->event = $event;
$this->incident = $event->incident;
}

/** @return ValidHtml[] */
Expand Down Expand Up @@ -107,13 +117,13 @@ protected function createRelatedObject(): array
/** @return ValidHtml[]|null */
protected function createIncident(): ?array
{
if ($this->event->incident->id === null) {
if ($this->incident->id === null) {
return null;
}

return [
Html::tag('h2', t('Incident')),
new IncidentList([$this->event->incident])
new IncidentList([$this->incident])
];
}

Expand Down
27 changes: 0 additions & 27 deletions library/Notifications/Widget/EmptyState.php

This file was deleted.

4 changes: 2 additions & 2 deletions library/Notifications/Widget/ItemList/ChannelList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace Icinga\Module\Notifications\Widget\ItemList;

use Icinga\Module\Notifications\Common\BaseItemList;
use ipl\Web\Common\BaseItemList;

/**
* A channel list
*/
class ChannelList extends BaseItemList
{
protected $defaultAttributes = ['class' => 'channel-list'];
protected $defaultAttributes = ['class' => ['action-list', 'channel-list']];

protected function getItemClass(): string
{
Expand Down
2 changes: 1 addition & 1 deletion library/Notifications/Widget/ItemList/ChannelListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Icinga\Module\Notifications\Widget\ItemList;

use Icinga\Module\Notifications\Common\BaseListItem;
use Icinga\Module\Notifications\Model\Channel;
use ipl\Html\BaseHtmlElement;
use ipl\Web\Common\BaseListItem;
use ipl\Web\Url;
use ipl\Web\Widget\Icon;
use ipl\Web\Widget\Link;
Expand Down
4 changes: 2 additions & 2 deletions library/Notifications/Widget/ItemList/ContactList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Icinga\Module\Notifications\Widget\ItemList;

use Icinga\Module\Notifications\Common\BaseItemList;
use ipl\Web\Common\BaseItemList;

class ContactList extends BaseItemList
{
protected $defaultAttributes = ['class' => 'contact-list'];
protected $defaultAttributes = ['class' => ['action-list', 'contact-list']];

protected function getItemClass(): string
{
Expand Down
Loading

0 comments on commit a28ca46

Please sign in to comment.