Add notification actions support

This commit is contained in:
Joseph Schorr 2014-08-15 21:56:29 -04:00
parent c026782abb
commit eefb7e1ec9
3 changed files with 40 additions and 1 deletions

View file

@ -145,6 +145,15 @@ nav.navbar-default .navbar-nav>li>a.active {
max-width: 320px; max-width: 320px;
} }
.notification-view-element .right-controls button {
margin-left: 10px;
}
.notification-view-element .message i.fa {
margin-right: 6px;
}
.notification-view-element .orginfo { .notification-view-element .orginfo {
margin-top: 8px; margin-top: 8px;
float: left; float: left;

View file

@ -7,10 +7,13 @@
<span class="orgname">{{ notification.organization }}</span> <span class="orgname">{{ notification.organization }}</span>
</div> </div>
</div> </div>
<div class="datetime">{{ parseDate(notification.created) | date:'medium'}}</div>
<div class="right-controls"> <div class="right-controls">
<a href="javascript:void(0)" ng-if="canDismiss(notification)" ng-click="dismissNotification(notification)"> <a href="javascript:void(0)" ng-if="canDismiss(notification)" ng-click="dismissNotification(notification)">
Dismiss Notification Dismiss Notification
</a> </a>
<button class="btn" ng-class="'btn-' + action.kind" ng-repeat="action in getActions(notification)" ng-click="action.handler(notification)">
{{ action.title }}
</button>
</div> </div>
<div class="datetime">{{ parseDate(notification.created) | date:'medium'}}</div>
</div> </div>

View file

@ -535,6 +535,7 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
stringBuilderService.buildString = function(value_or_func, metadata) { stringBuilderService.buildString = function(value_or_func, metadata) {
var fieldIcons = { var fieldIcons = {
'adder': 'user',
'username': 'user', 'username': 'user',
'activating_username': 'user', 'activating_username': 'user',
'delegate_user': 'user', 'delegate_user': 'user',
@ -1132,6 +1133,19 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
'page': '/about/', 'page': '/about/',
'dismissable': true 'dismissable': true
}, },
'org_team_invite': {
'level': 'primary',
'message': '{adder} is inviting you to join team {team} under organization {org}',
'actions': [
{
'title': 'Join team',
'kind': 'primary',
'handler': function(notification) {
}
},
{'title': 'Decline', 'kind': 'default'}
]
},
'password_required': { 'password_required': {
'level': 'error', 'level': 'error',
'message': 'In order to begin pushing and pulling repositories, a password must be set for your account', 'message': 'In order to begin pushing and pulling repositories, a password must be set for your account',
@ -1224,6 +1238,15 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
} }
}; };
notificationService.getActions = function(notification) {
var kindInfo = notificationKinds[notification['kind']];
if (!kindInfo) {
return [];
}
return kindInfo['actions'] || [];
};
notificationService.canDismiss = function(notification) { notificationService.canDismiss = function(notification) {
var kindInfo = notificationKinds[notification['kind']]; var kindInfo = notificationKinds[notification['kind']];
if (!kindInfo) { if (!kindInfo) {
@ -5104,6 +5127,10 @@ quayApp.directive('notificationView', function () {
$scope.getClass = function(notification) { $scope.getClass = function(notification) {
return NotificationService.getClass(notification); return NotificationService.getClass(notification);
}; };
$scope.getActions = function(notification) {
return NotificationService.getActions(notification);
};
} }
}; };
return directiveDefinitionObject; return directiveDefinitionObject;