Be more resistant to invalid notification kinds

This commit is contained in:
Joseph Schorr 2014-08-05 18:20:04 -04:00
parent eee6a38c5f
commit b8979c0499

View file

@ -1194,7 +1194,11 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
};
notificationService.canDismiss = function(notification) {
return !!notificationKinds[notification['kind']]['dismissable'];
var kindInfo = notificationKinds[notification['kind']];
if (!kindInfo) {
return false;
}
return !!kindInfo['dismissable'];
};
notificationService.getPage = function(notification) {
@ -1207,11 +1211,18 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
notificationService.getMessage = function(notification) {
var kindInfo = notificationKinds[notification['kind']];
if (!kindInfo) {
return '(Unknown notification kind: ' + notification['kind'] + ')';
}
return StringBuilderService.buildString(kindInfo['message'], notification['metadata']);
};
notificationService.getClass = function(notification) {
return 'notification-' + notificationKinds[notification['kind']]['level'];
var kindInfo = notificationKinds[notification['kind']];
if (!kindInfo) {
return 'notification-info';
}
return 'notification-' + kindInfo['level'];
};
notificationService.getClasses = function(notifications) {