Skip to content

Commit

Permalink
refactor(events-incident-history-improvements): removed unused css, r…
Browse files Browse the repository at this point in the history
…efactored IconBall class
  • Loading branch information
ncosta-ic committed Apr 19, 2024
1 parent cbffbef commit 6a16054
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 120 deletions.
75 changes: 0 additions & 75 deletions library/Notifications/Widget/CustomIcon.php

This file was deleted.

20 changes: 20 additions & 0 deletions library/Notifications/Widget/IconBall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/* Icinga Notifications Web | (c) 2024 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Notifications\Widget;

use ipl\Html\BaseHtmlElement;
use ipl\Web\Widget\Icon;

class IconBall extends BaseHtmlElement
{
protected $tag = 'span';

protected $defaultAttributes = ['class' => ['icon-ball']];

public function __construct(string $name, $family = 'fa-regular')
{
$this->addHtml(new Icon($name, ['class' => $family]));
}
}
4 changes: 2 additions & 2 deletions library/Notifications/Widget/ItemList/EventListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Icinga\Module\Notifications\Model\Incident;
use Icinga\Module\Notifications\Model\Objects;
use Icinga\Module\Notifications\Model\Source;
use Icinga\Module\Notifications\Widget\CustomIcon;
use Icinga\Module\Notifications\Widget\IconBall;
use Icinga\Module\Notifications\Widget\SourceIcon;
use InvalidArgumentException;
use ipl\Html\BaseHtmlElement;
Expand Down Expand Up @@ -62,7 +62,7 @@ protected function assembleVisual(BaseHtmlElement $visual): void
* TODO(nc): Add proper handling of internal events once
* https://github.com/Icinga/icinga-notifications/issues/162 gets sorted out
*/
$content = new CustomIcon('square-up-right', 'fa-solid');
$content = new IconBall('square-up-right', 'fa-solid');
} else {
switch ($severity) {
case 'ok':
Expand Down
62 changes: 30 additions & 32 deletions library/Notifications/Widget/ItemList/IncidentHistoryListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Icinga\Module\Notifications\Common\Icons;
use Icinga\Module\Notifications\Model\Event;
use Icinga\Module\Notifications\Model\IncidentHistory;
use Icinga\Module\Notifications\Widget\IconBall;
use Icinga\Module\Notifications\Widget\SourceIcon;
use ipl\Html\BaseHtmlElement;
use ipl\Web\Common\BaseListItem;
Expand Down Expand Up @@ -34,30 +35,27 @@ protected function assembleVisual(BaseHtmlElement $visual): void
$content = new Icon($iconName, ['class' => 'severity-' . $this->item->new_severity]);

break;
case 'rule_matched':
case 'closed':
$content = (new Icon($iconName, ['class' => 'type-' . $this->item->type]))->setStyle('fa-regular');
$content = new IconBall($iconName);

break;
case 'notified':
case 'recipient_role_changed':
$style = 'fa-regular';
$family = 'fa-regular';
if ($iconName === Icons::UNSUBSCRIBED || $iconName === Icons::UNMANAGE) {
$style = 'fa-solid';
$family = 'fa-solid';
}

$content = (new Icon($iconName))->setStyle($style);

break;
case 'rule_matched':
$content = new Icon($iconName, ['class' => 'type-' . $this->item->type]);
$content = new IconBall($iconName, $family);

break;
case 'escalation_triggered':
$content = (new Icon($iconName))->setStyle('fa-solid');
$content = new IconBall($iconName, 'fa-solid');

break;
default:
$content = new Icon('');
$content = new IconBall('ellipsis');
}

$visual->addHtml($content);
Expand Down Expand Up @@ -112,6 +110,28 @@ protected function assembleCaption(BaseHtmlElement $caption): void
$caption->add($this->buildMessage());
}

protected function assembleHeader(BaseHtmlElement $header): void
{
$title = $this->createTitle();
if (! $title->isEmpty()) {
$header->addHtml($title);
}

$header->addHtml($this->createCaption());
if ($this->item->type === 'opened' || $this->item->type === 'incident_severity_changed') {
$header->add(
(new SourceIcon(SourceIcon::SIZE_BIG))->addHtml($this->item->event->object->source->getIcon())
);
}

$header->add(new TimeAgo($this->item->time->getTimestamp()));
}

protected function assembleMain(BaseHtmlElement $main): void
{
$main->add($this->createHeader());
}

protected function buildMessage(): string
{
switch ($this->item->type) {
Expand Down Expand Up @@ -231,26 +251,4 @@ protected function buildMessage(): string

return $message;
}

protected function assembleHeader(BaseHtmlElement $header): void
{
$title = $this->createTitle();
if (! $title->isEmpty()) {
$header->addHtml($title);
}

$header->addHtml($this->createCaption());
if ($this->item->type === 'opened' || $this->item->type === 'incident_severity_changed') {
$header->add(
(new SourceIcon(SourceIcon::SIZE_BIG))->addHtml($this->item->event->object->source->getIcon())
);
}

$header->add(new TimeAgo($this->item->time->getTimestamp()));
}

protected function assembleMain(BaseHtmlElement $main): void
{
$main->add($this->createHeader());
}
}
12 changes: 1 addition & 11 deletions public/css/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}
}

.custom-icon {
.icon-ball {
.ball();
.ball-size-l();
.ball-solid(@gray-light);
Expand Down Expand Up @@ -92,13 +92,3 @@
.full-width .add-new-component {
margin: 0 0 1em 1em;
}

div.show-more {
float: right;

:after {
content: "";
clear: both;
display: table;
}
}

0 comments on commit 6a16054

Please sign in to comment.