U4-7756 - EventMessageType.Info is same color as EventMessageType.Success

Created by Rasmus Eeg Møller 16 Jan 2016, 12:28:32 Updated by Rasmus Eeg Møller 16 Jan 2016, 12:28:32

What did you do? created the following IApplicationEventHandler

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Services;

namespace Commodities.Web.Events {
    /*
     * This file contains the logic to prevent vacancy background for being moved and deleted.
    */
    public class PreventActionsOnBackgroundsEventHandler : IApplicationEventHandler {
        private Dictionary<string, int> backgrounds = new Dictionary<string, int> {
            { "Business Development", 2098},
            { "Business Operation & Risk Management", 2097},
            { "CEO Office", 2099},
            { "Finance", 2092},
            { "IT", 2094 },
            { "Legal And Compliance", 2100 },
            { "Management", 2090 },
            { "Sales", 2095},
            { "Student Employee", 2089 },
            { "Trading", 2088 }
        };

        public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) {
            MediaService.Deleting += MediaService_Deleting;
            MediaService.Moving += MediaService_Moving;
            MediaService.Saving += MediaService_Saving;
            MediaService.Trashing += MediaService_Trashing;
        }

        /// <summary>
        /// Prevent users from changing the names
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MediaService_Saving(IMediaService sender, SaveEventArgs<Umbraco.Core.Models.IMedia> e) {
            foreach(var media in e.SavedEntities) {
                if (backgrounds.ContainsValue(media.Id)) {
                    var key = backgrounds.FirstOrDefault(p => p.Value == media.Id).Key;
                    if(media.Name != key) {
                        media.Name = key;
                        e.Messages.Add(new EventMessage("Woops!", "You should not rename this media item. So we reverted the name for you.", EventMessageType.Info));
                    }
                }
            }
        }

        /// <summary>
        /// Prevent users from moving backgrounds
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MediaService_Moving(IMediaService sender, MoveEventArgs<Umbraco.Core.Models.IMedia> e) {
            foreach( var moveInfo in e.MoveInfoCollection) {
                if (backgrounds.ContainsValue(moveInfo.Entity.Id) && moveInfo.Entity.Trashed == false) {
                    e.CancelOperation(new EventMessage("Woops!", "You cannot move this media item. But you can change the uploaded file.", EventMessageType.Warning));
                }
            }
        }

        /// <summary>
        /// Prevent trashing of the backgrounds
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MediaService_Trashing(IMediaService sender, MoveEventArgs<Umbraco.Core.Models.IMedia> e) {
            foreach (var moveInfo in e.MoveInfoCollection) {
                if (backgrounds.ContainsValue(moveInfo.Entity.Id)) {
                    e.CancelOperation(new EventMessage("Woops!", "You cannot move this media item. But you can change the uploaded file.", EventMessageType.Warning));
                }
            }
        }

        /// <summary>
        /// Prevent users from deleting the backgrounds. Should really get this far, since we are preventing trashing. Delete is the last step.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MediaService_Deleting(IMediaService sender, Umbraco.Core.Events.DeleteEventArgs<Umbraco.Core.Models.IMedia> e) {
            foreach (var media in e.DeletedEntities) {
                if (backgrounds.ContainsValue(media.Id)) {
                    e.CancelOperation(new EventMessage("Woops!", "You cannot delete this media item. But you can change the uploaded file.", EventMessageType.Warning));
                }
            }
        }

        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) {
        }

        public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) {
        }
    }
}

What did you expect to happen? That the messages with have different colors. EventMessageType.Info = Blue, or grayish. EventMessageType.Warning = yellowish?

What actually happened? They all just display as green speech bobbles.

Comments

Priority: Normal

Type: Usability Problem

State: Submitted

Assignee:

Difficulty:

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.3.1

Due in version:

Sprint:

Story Points:

Cycle: