Skip to content

Commit

Permalink
feat,fix: swapped undefined icon, reverted object name improvements o…
Browse files Browse the repository at this point in the history
…n incident detail, added default style to icon ball

caused by: #155 (more specifically: 49c3608)
  • Loading branch information
ncosta-ic committed Apr 29, 2024
1 parent 028d2bc commit 9a5f7d0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 51 deletions.
2 changes: 2 additions & 0 deletions library/Notifications/Common/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ private function __construct()
public const NOTIFIED = 'paper-plane';

public const RULE_MATCHED = 'filter';

public const UNDEFINED = 'notdef';
}
37 changes: 14 additions & 23 deletions library/Notifications/Widget/Detail/IncidentDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Icinga\Module\Notifications\Widget\Detail;

use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Model\Incident;
use Icinga\Module\Notifications\Model\Objects;
use Icinga\Module\Notifications\Widget\EventSourceBadge;
Expand All @@ -15,8 +14,6 @@
use ipl\Html\Html;
use ipl\Html\HtmlElement;
use ipl\Html\Table;
use ipl\Orm\Query;
use ipl\Sql\Select;
use ipl\Web\Widget\Link;
use ipl\Web\Widget\StateBall;

Expand Down Expand Up @@ -93,28 +90,22 @@ protected function createRelatedObject()

protected function createHistory()
{
$history = $this->incident->incident_history
->with([
'event',
'event.object',
'event.object.source',
'contact',
'rule',
'rule_escalation',
'contactgroup',
'schedule',
'channel'
]);

$history
->withColumns('event.object.id_tags')
->on(Query::ON_SELECT_ASSEMBLED, function (Select $select) use ($history) {
Database::registerGroupBy($history, $select);
});

return [
Html::tag('h2', t('Incident History')),
new IncidentHistoryList($history)
new IncidentHistoryList(
$this->incident->incident_history
->with([
'event',
'event.object',
'event.object.source',
'contact',
'rule',
'rule_escalation',
'contactgroup',
'schedule',
'channel'
])
)
];
}

Expand Down
2 changes: 1 addition & 1 deletion library/Notifications/Widget/IconBall.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IconBall extends BaseHtmlElement

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

public function __construct(string $name, ?string $style = null)
public function __construct(string $name, ?string $style = 'fa-solid')
{
$icon = new Icon($name);
if ($style !== null) {
Expand Down
35 changes: 10 additions & 25 deletions library/Notifications/Widget/ItemList/IncidentHistoryListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,10 @@ class IncidentHistoryListItem extends BaseListItem
protected function assembleVisual(BaseHtmlElement $visual): void
{
$incidentIcon = $this->getIncidentEventIcon();
if ($incidentIcon === '') {
$content = new IconBall('ellipsis', 'fa-solid');
if ($this->item->type === 'incident_severity_changed') {
$content = new Icon($incidentIcon, ['class' => 'severity-' . $this->item->new_severity]);
} else {
switch ($this->item->type) {
case 'incident_severity_changed':
$content = new Icon($incidentIcon, ['class' => 'severity-' . $this->item->new_severity]);

break;
case 'rule_matched':
case 'opened':
case 'closed':
$content = new IconBall($incidentIcon);

break;
case 'notified':
case 'escalation_triggered':
case 'recipient_role_changed':
$content = new IconBall($incidentIcon, 'fa-solid');

break;
default:
$content = new IconBall('ellipsis', 'fa-solid');
}
$content = new IconBall($incidentIcon);
}

$visual->addHtml($content);
Expand Down Expand Up @@ -93,8 +74,10 @@ protected function getIncidentEventIcon(): string
return Icons::RULE_MATCHED;
case 'escalation_triggered':
return Icons::TRIGGERED;
default:
case 'notified':
return Icons::NOTIFIED;
default:
return Icons::UNDEFINED;
}
}

Expand All @@ -103,12 +86,14 @@ protected function getSeverityIcon(): string
switch ($this->item->new_severity) {
case 'ok':
return Icons::OK;
case 'warning':
return Icons::WARNING;
case 'err':
return Icons::ERROR;
case 'crit':
return Icons::CRITICAL;
default:
return Icons::WARNING;
return Icons::UNDEFINED;
}
}

Expand All @@ -128,7 +113,7 @@ protected function getRoleIcon(): string
}
}

return '';
return Icons::UNDEFINED;
}
}

Expand Down
4 changes: 2 additions & 2 deletions public/css/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
margin-top: 0.15em;
}

i.icon:before {
i.icon::before {
font-size: 0.6em;
}

i.icon.fa-paper-plane:before {
i.icon.fa-paper-plane::before {
margin-right: .2em;
}
}
Expand Down

0 comments on commit 9a5f7d0

Please sign in to comment.