Add ability to dismiss notifications
This commit is contained in:
parent
34fc279092
commit
32b2ecdfa6
9 changed files with 162 additions and 11 deletions
|
@ -1084,7 +1084,8 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
|||
'test_notification': {
|
||||
'level': 'primary',
|
||||
'message': 'This notification is a long message for testing',
|
||||
'page': '/about/'
|
||||
'page': '/about/',
|
||||
'dismissable': true
|
||||
},
|
||||
'password_required': {
|
||||
'level': 'error',
|
||||
|
@ -1121,31 +1122,53 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
|||
'message': 'Repository {repository} has been pushed with the following tags updated: {updated_tags}',
|
||||
'page': function(metadata) {
|
||||
return '/repository/' + metadata.repository;
|
||||
}
|
||||
},
|
||||
'dismissable': true
|
||||
},
|
||||
'build_queued': {
|
||||
'level': 'info',
|
||||
'message': 'A build has been queued for repository {repository}',
|
||||
'page': function(metadata) {
|
||||
return '/repository/' + metadata.repository + '/build?current=' + metadata.build_id;
|
||||
}
|
||||
},
|
||||
'dismissable': true
|
||||
},
|
||||
'build_start': {
|
||||
'level': 'info',
|
||||
'message': 'A build has been started for repository {repository}',
|
||||
'page': function(metadata) {
|
||||
return '/repository/' + metadata.repository + '/build?current=' + metadata.build_id;
|
||||
}
|
||||
},
|
||||
'dismissable': true
|
||||
},
|
||||
'build_failure': {
|
||||
'level': 'error',
|
||||
'message': 'A build has failed for repository {repository}',
|
||||
'page': function(metadata) {
|
||||
return '/repository/' + metadata.repository + '/build?current=' + metadata.build_id;
|
||||
}
|
||||
},
|
||||
'dismissable': true
|
||||
}
|
||||
};
|
||||
|
||||
notificationService.dismissNotification = function(notification) {
|
||||
notification.dismissed = true;
|
||||
var params = {
|
||||
'uuid': notification.id
|
||||
};
|
||||
|
||||
ApiService.updateUserNotification(notification, params);
|
||||
|
||||
var index = $.inArray(notification, notificationService.notifications);
|
||||
if (index >= 0) {
|
||||
notificationService.notifications.splice(index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
notificationService.canDismiss = function(notification) {
|
||||
return !!notificationKinds[notification['kind']]['dismissable'];
|
||||
};
|
||||
|
||||
notificationService.getPage = function(notification) {
|
||||
var page = notificationKinds[notification['kind']]['page'];
|
||||
if (typeof page != 'string') {
|
||||
|
@ -4907,7 +4930,7 @@ quayApp.directive('notificationView', function () {
|
|||
'notification': '=notification',
|
||||
'parent': '=parent'
|
||||
},
|
||||
controller: function($scope, $element, $window, $location, UserService, NotificationService) {
|
||||
controller: function($scope, $element, $window, $location, UserService, NotificationService, ApiService) {
|
||||
var stringStartsWith = function (str, prefix) {
|
||||
return str.slice(0, prefix.length) == prefix;
|
||||
};
|
||||
|
@ -4943,6 +4966,14 @@ quayApp.directive('notificationView', function () {
|
|||
}
|
||||
};
|
||||
|
||||
$scope.dismissNotification = function(notification) {
|
||||
NotificationService.dismissNotification(notification);
|
||||
};
|
||||
|
||||
$scope.canDismiss = function(notification) {
|
||||
return NotificationService.canDismiss(notification);
|
||||
};
|
||||
|
||||
$scope.getClass = function(notification) {
|
||||
return NotificationService.getClass(notification);
|
||||
};
|
||||
|
|
Reference in a new issue