From bc2e7588d752b9c86ddce2bde48f5105a9abf5ab Mon Sep 17 00:00:00 2001
From: Johannes Meyer <johannes.meyer@icinga.com>
Date: Wed, 17 Jul 2019 08:49:41 +0200
Subject: [PATCH] FormNotifications: Don't ignore warning and error
 notifications

---
 .../Web/Form/Decorator/FormNotifications.php  | 20 +++++++++++++++----
 public/css/icinga/forms.less                  | 12 ++++++++++-
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/library/Icinga/Web/Form/Decorator/FormNotifications.php b/library/Icinga/Web/Form/Decorator/FormNotifications.php
index 2ab1afc33..46734dfc6 100644
--- a/library/Icinga/Web/Form/Decorator/FormNotifications.php
+++ b/library/Icinga/Web/Form/Decorator/FormNotifications.php
@@ -37,10 +37,7 @@ class FormNotifications extends Zend_Form_Decorator_Abstract
             return $content;
         }
 
-        $html = '<div class="form-notifications">'
-            . Icinga::app()->getViewRenderer()->view->icon('ok', '', ['class' => 'form-notification-icon'])
-            . '<ul class="form-notification-list">';
-
+        $html = '<ul class="form-notification-list">';
         foreach (array(Form::NOTIFICATION_ERROR, Form::NOTIFICATION_WARNING, Form::NOTIFICATION_INFO) as $type) {
             if (isset($notifications[$type])) {
                 $html .= '<li><ul class="notification-' . $this->getNotificationTypeName($type) . '">';
@@ -59,6 +56,21 @@ class FormNotifications extends Zend_Form_Decorator_Abstract
             }
         }
 
+        if (isset($notifications[Form::NOTIFICATION_ERROR])) {
+            $icon = 'cancel';
+            $class = 'error';
+        } elseif (isset($notifications[Form::NOTIFICATION_WARNING])) {
+            $icon = 'warning-empty';
+            $class = 'warning';
+        } else {
+            $icon = 'info';
+            $class = 'info';
+        }
+
+        $html = "<div class=\"form-notifications $class\">"
+        . Icinga::app()->getViewRenderer()->view->icon($icon, '', ['class' => 'form-notification-icon'])
+        . $html;
+
         switch ($this->getPlacement()) {
             case self::APPEND:
                 return $content . $html . '</ul></div>';
diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less
index 4452adf19..15d117ddf 100644
--- a/public/css/icinga/forms.less
+++ b/public/css/icinga/forms.less
@@ -386,7 +386,17 @@ form.icinga-forms {
   }
 
   .form-notifications {
-    background-color: fade(@color-ok, 20%);
+    &.info {
+      background-color: fade(@color-ok, 20%);
+    }
+
+    &.error {
+      background-color: fade(@color-critical, 30%);
+    }
+
+    &.warning {
+      background-color: fade(@color-warning, 40%);
+    }
   }
 
   .form-description {