Be more resistant to invalid notification kinds
This commit is contained in:
parent
eee6a38c5f
commit
b8979c0499
1 changed files with 13 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Reference in a new issue