Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions library/Notifications/View/IncidentHistoryRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
use Icinga\Module\Notifications\Model\IncidentHistory;
use Icinga\Module\Notifications\Widget\IconBall;
use ipl\Html\Attributes;
use ipl\Html\FormattedString;
use ipl\Html\Html;
use ipl\Html\HtmlDocument;
use ipl\Html\Text;
use ipl\Html\ValidHtml;
use ipl\I18n\Translation;
use ipl\Web\Common\ItemRenderer;
use ipl\Web\Widget\Icon;
Expand All @@ -24,8 +27,13 @@ class IncidentHistoryRenderer implements ItemRenderer
public function assembleAttributes($item, Attributes $attributes, string $layout): void
{
$classes = ['incident-history'];
if ($item->type === 'notified' && $item->notification_state === 'suppressed') {
$classes[] = 'notification-suppressed';
if ($item->type === 'notified') {
$classes[] = 'notification-state';
if ($item->notification_state === 'suppressed') {
$classes[] = 'suppressed';
} elseif ($item->notification_state === 'failed') {
$classes[] = 'failed';
}
}

$attributes->get('class')->addValue($classes);
Expand All @@ -49,7 +57,7 @@ public function assembleTitle($item, HtmlDocument $title, string $layout): void

public function assembleCaption($item, HtmlDocument $caption, string $layout): void
{
$caption->addHtml(new Text($this->buildMessage($item)));
$caption->addHtml($this->buildMessage($item));
}

public function assembleExtendedInfo($item, HtmlDocument $info, string $layout): void
Expand Down Expand Up @@ -154,9 +162,9 @@ protected function getRoleIcon(IncidentHistory $item): string
*
* @param IncidentHistory $item
*
* @return string
* @return ValidHtml
*/
protected function buildMessage(IncidentHistory $item): string
protected function buildMessage(IncidentHistory $item): ValidHtml
{
switch ($item->type) {
case 'opened':
Expand Down Expand Up @@ -212,11 +220,17 @@ protected function buildMessage(IncidentHistory $item): string
$item->channel->type
);
} else {
$message = sprintf(
$this->translate('Contact %s notified via %s (%s)'),
$item->contact->full_name,
$item->channel->type,
IncidentHistory::translateNotificationState($item->notification_state)
$message = new FormattedString(
$this->translate('Contact %s notified via %s %s'),
[
$item->contact->full_name,
$item->channel->type,
Html::tag(
'span',
['class' => 'state-text'],
sprintf('(%s)', IncidentHistory::translateNotificationState($item->notification_state))
)
]
);
}

Expand Down Expand Up @@ -304,8 +318,12 @@ protected function buildMessage(IncidentHistory $item): string
$message = '';
}

if ($item->message) {
$message = $message === '' ? $item->message : $message . ': ' . $item->message;
$messageFromDb = $item->message ? ': ' . $item->message : '';

if (is_string($message)) {
$message = new Text($message . $messageFromDb);
} else {
$message = new FormattedString('%s %s', [$message, $messageFromDb]);
}

return $message;
Expand Down
11 changes: 9 additions & 2 deletions public/css/detail/incident-detail.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
}
}

.list-item.notification-suppressed {
opacity: .75;
.list-item.incident-history.notification-state {
&.suppressed {
opacity: .75;
}

&.failed .state-text {
opacity: .75;
color: @color-critical;
}
}
}
Loading