Skip to content

Commit ae31569

Browse files
Notify-state: Highlight failed notify attempt for better visibility
1 parent 900354c commit ae31569

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

library/Notifications/View/IncidentHistoryRenderer.php

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
use Icinga\Module\Notifications\Model\IncidentHistory;
1010
use Icinga\Module\Notifications\Widget\IconBall;
1111
use ipl\Html\Attributes;
12+
use ipl\Html\FormattedString;
13+
use ipl\Html\Html;
1214
use ipl\Html\HtmlDocument;
1315
use ipl\Html\Text;
16+
use ipl\Html\ValidHtml;
1417
use ipl\I18n\Translation;
1518
use ipl\Web\Common\ItemRenderer;
1619
use ipl\Web\Widget\Icon;
@@ -24,8 +27,13 @@ class IncidentHistoryRenderer implements ItemRenderer
2427
public function assembleAttributes($item, Attributes $attributes, string $layout): void
2528
{
2629
$classes = ['incident-history'];
27-
if ($item->type === 'notified' && $item->notification_state === 'suppressed') {
28-
$classes[] = 'notification-suppressed';
30+
if ($item->type === 'notified') {
31+
$classes[] = 'notified';
32+
if ($item->notification_state === 'suppressed') {
33+
$classes[] = 'suppressed';
34+
}elseif ($item->notification_state === 'failed') {
35+
$classes[] = 'failed';
36+
}
2937
}
3038

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

5058
public function assembleCaption($item, HtmlDocument $caption, string $layout): void
5159
{
52-
$caption->addHtml(new Text($this->buildMessage($item)));
60+
$caption->addHtml($this->buildMessage($item));
5361
}
5462

5563
public function assembleExtendedInfo($item, HtmlDocument $info, string $layout): void
@@ -154,9 +162,9 @@ protected function getRoleIcon(IncidentHistory $item): string
154162
*
155163
* @param IncidentHistory $item
156164
*
157-
* @return string
165+
* @return ValidHtml
158166
*/
159-
protected function buildMessage(IncidentHistory $item): string
167+
protected function buildMessage(IncidentHistory $item): ValidHtml
160168
{
161169
switch ($item->type) {
162170
case 'opened':
@@ -212,12 +220,16 @@ protected function buildMessage(IncidentHistory $item): string
212220
$item->channel->type
213221
);
214222
} else {
215-
$message = sprintf(
223+
$message = new FormattedString(
216224
$this->translate('Contact %s notified via %s (%s)'),
217-
$item->contact->full_name,
225+
[$item->contact->full_name,
218226
$item->channel->type,
219-
IncidentHistory::translateNotificationState($item->notification_state)
220-
);
227+
Html::tag(
228+
'span',
229+
['class' => 'state-text'],
230+
IncidentHistory::translateNotificationState($item->notification_state)
231+
)
232+
]);
221233
}
222234

223235
break;
@@ -304,8 +316,12 @@ protected function buildMessage(IncidentHistory $item): string
304316
$message = '';
305317
}
306318

307-
if ($item->message) {
308-
$message = $message === '' ? $item->message : $message . ': ' . $item->message;
319+
$messageFromDb = $item->message ? ': ' . $item->message : '';
320+
321+
if (is_string($message)) {
322+
$message = new Text($message . $messageFromDb);
323+
} else {
324+
$message = new FormattedString('%s %s', [$message, $messageFromDb]);
309325
}
310326

311327
return $message;

public/css/detail/incident-detail.less

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
}
2626
}
2727

28-
.list-item.notification-suppressed {
29-
opacity: .75;
28+
.list-item.incident-history.notified {
29+
&.suppressed {
30+
opacity: .75;
31+
}
32+
33+
&.failed .state-text {
34+
opacity: .75;
35+
color: @color-critical;
36+
}
3037
}
3138
}

0 commit comments

Comments
 (0)