When this occurs: |
diff --git a/static/directives/repository-events-table.html b/static/directives/repository-events-table.html
index a2331e7fe..3a463f54c 100644
--- a/static/directives/repository-events-table.html
+++ b/static/directives/repository-events-table.html
@@ -26,6 +26,7 @@
+ Title |
Event |
Notification |
|
@@ -34,6 +35,10 @@
+
+ {{ notification.title || '(Untitled)' }}
+ |
+
@@ -53,6 +58,16 @@
Test Notification
+
+
+ View Webhook URL
+
+
+
+ View E-mail Address
+
diff --git a/static/js/directives/ui/create-external-notification-dialog.js b/static/js/directives/ui/create-external-notification-dialog.js
index 1e8613e8a..a0a1a65e1 100644
--- a/static/js/directives/ui/create-external-notification-dialog.js
+++ b/static/js/directives/ui/create-external-notification-dialog.js
@@ -88,7 +88,8 @@ angular.module('quay').directive('createExternalNotificationDialog', function ()
var data = {
'event': $scope.currentEvent.id,
'method': $scope.currentMethod.id,
- 'config': $scope.currentConfig
+ 'config': $scope.currentConfig,
+ 'title': $scope.currentTitle
};
ApiService.createRepoNotification(data, params).then(function(resp) {
diff --git a/static/js/directives/ui/repository-events-table.js b/static/js/directives/ui/repository-events-table.js
index 897694d9c..05b3e3226 100644
--- a/static/js/directives/ui/repository-events-table.js
+++ b/static/js/directives/ui/repository-events-table.js
@@ -64,6 +64,25 @@ angular.module('quay').directive('repositoryEventsTable', function () {
}, ApiService.errorDisplay('Cannot delete notification'));
};
+ $scope.showNotifyInfo = function(notification, field) {
+ var dom = document.createElement('input');
+ dom.setAttribute('type', 'text');
+ dom.setAttribute('class', 'form-control');
+ dom.setAttribute('value', notification.config[field]);
+ dom.setAttribute('readonly', 'readonly');
+
+ bootbox.dialog({
+ 'title': (notification.title || 'Notification') + ' ' + field,
+ 'message': dom.outerHTML,
+ 'buttons': {
+ "Done": {
+ className: "btn-primary",
+ callback: function() {}
+ },
+ }
+ });
+ };
+
$scope.showWebhookInfo = function(notification) {
var eventId = notification.event;
document.location = 'http://docs.quay.io/guides/notifications.html#webhook_' + eventId;
diff --git a/test/data/test.db b/test/data/test.db
index cd69ffaa0..45095cb99 100644
Binary files a/test/data/test.db and b/test/data/test.db differ
diff --git a/test/test_api_usage.py b/test/test_api_usage.py
index a982ec847..f80082c79 100644
--- a/test/test_api_usage.py
+++ b/test/test_api_usage.py
@@ -1935,6 +1935,8 @@ class TestRepositoryNotifications(ApiTestCase):
self.assertEquals('repo_push', json['event'])
self.assertEquals('webhook', json['method'])
self.assertEquals('http://example.com', json['config']['url'])
+ self.assertIsNone(json['title'])
+
wid = json['uuid']
# Get the notification.
@@ -1944,6 +1946,7 @@ class TestRepositoryNotifications(ApiTestCase):
self.assertEquals(wid, json['uuid'])
self.assertEquals('repo_push', json['event'])
self.assertEquals('webhook', json['method'])
+ self.assertIsNone(json['title'])
# Verify the notification is listed.
json = self.getJsonResponse(RepositoryNotificationList,
@@ -1962,6 +1965,29 @@ class TestRepositoryNotifications(ApiTestCase):
params=dict(repository=ADMIN_ACCESS_USER + '/simple', uuid=wid),
expected_code=404)
+ # Add another notification.
+ json = self.postJsonResponse(RepositoryNotificationList,
+ params=dict(repository=ADMIN_ACCESS_USER + '/simple'),
+ data=dict(config={'url': 'http://example.com'}, event='repo_push',
+ method='webhook', title='Some Notification'),
+ expected_code=201)
+
+ self.assertEquals('repo_push', json['event'])
+ self.assertEquals('webhook', json['method'])
+ self.assertEquals('http://example.com', json['config']['url'])
+ self.assertEquals('Some Notification', json['title'])
+
+ wid = json['uuid']
+
+ # Get the notification.
+ json = self.getJsonResponse(RepositoryNotification,
+ params=dict(repository=ADMIN_ACCESS_USER + '/simple', uuid=wid))
+
+ self.assertEquals(wid, json['uuid'])
+ self.assertEquals('repo_push', json['event'])
+ self.assertEquals('webhook', json['method'])
+ self.assertEquals('Some Notification', json['title'])
+
class TestListAndGetImage(ApiTestCase):
def test_listandgetimages(self):
diff --git a/util/migrate/migrateslackwebhook.py b/util/migrate/migrateslackwebhook.py
index 9d4c3ba61..e480f6180 100644
--- a/util/migrate/migrateslackwebhook.py
+++ b/util/migrate/migrateslackwebhook.py
@@ -13,10 +13,11 @@ def run_slackwebhook_migration():
encountered = set()
while True:
- found = list(RepositoryNotification.select().where(
- RepositoryNotification.method == slack_method,
- RepositoryNotification.config_json ** "%subdomain%",
- ~(RepositoryNotification.config_json ** "%url%")))
+ found = list(RepositoryNotification.select(RepositoryNotification.uuid,
+ RepositoryNotification.config_json)
+ .where(RepositoryNotification.method == slack_method,
+ RepositoryNotification.config_json ** "%subdomain%",
+ ~(RepositoryNotification.config_json ** "%url%")))
found = [f for f in found if not f.uuid in encountered]
| |