From 84276ee9456315dbf0f681d344da88d8d1e37a97 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 17 Aug 2015 16:30:15 -0400 Subject: [PATCH] Better notifications UI Fixes #369 --- data/database.py | 1 + data/model/notification.py | 4 +-- endpoints/api/repositorynotification.py | 12 ++++++-- .../create-external-notification-dialog.html | 12 ++++++-- .../directives/repository-events-table.html | 15 ++++++++++ .../ui/create-external-notification-dialog.js | 3 +- .../directives/ui/repository-events-table.js | 19 +++++++++++++ test/data/test.db | Bin 790528 -> 802816 bytes test/test_api_usage.py | 26 ++++++++++++++++++ util/migrate/migrateslackwebhook.py | 9 +++--- 10 files changed, 89 insertions(+), 12 deletions(-) diff --git a/data/database.py b/data/database.py index 225b0c11c..6309c4eb4 100644 --- a/data/database.py +++ b/data/database.py @@ -722,6 +722,7 @@ class RepositoryNotification(BaseModel): repository = ForeignKeyField(Repository, index=True) event = ForeignKeyField(ExternalNotificationEvent) method = ForeignKeyField(ExternalNotificationMethod) + title = CharField(null=True) config_json = TextField() diff --git a/data/model/notification.py b/data/model/notification.py index b894a1cf7..87ae7f7ca 100644 --- a/data/model/notification.py +++ b/data/model/notification.py @@ -113,12 +113,12 @@ def delete_matching_notifications(target, kind_name, **kwargs): notification.delete_instance() -def create_repo_notification(repo, event_name, method_name, config): +def create_repo_notification(repo, event_name, method_name, config, title=None): event = ExternalNotificationEvent.get(ExternalNotificationEvent.name == event_name) method = ExternalNotificationMethod.get(ExternalNotificationMethod.name == method_name) return RepositoryNotification.create(repository=repo, event=event, method=method, - config_json=json.dumps(config)) + config_json=json.dumps(config), title=title) def get_repo_notification(uuid): diff --git a/endpoints/api/repositorynotification.py b/endpoints/api/repositorynotification.py index 54643ccc3..832328cbe 100644 --- a/endpoints/api/repositorynotification.py +++ b/endpoints/api/repositorynotification.py @@ -26,7 +26,8 @@ def notification_view(note): 'uuid': note.uuid, 'event': note.event.name, 'method': note.method.name, - 'config': config + 'config': config, + 'title': note.title, } @@ -55,7 +56,11 @@ class RepositoryNotificationList(RepositoryParamResource): 'config': { 'type': 'object', 'description': 'JSON config information for the specific method of notification' - } + }, + 'title': { + 'type': 'string', + 'description': 'The human-readable title of the notification', + }, } }, } @@ -78,7 +83,8 @@ class RepositoryNotificationList(RepositoryParamResource): raise request_error(message=ex.message) new_notification = model.notification.create_repo_notification(repo, parsed['event'], - parsed['method'], parsed['config']) + parsed['method'], parsed['config'], + parsed.get('title', None)) resp = notification_view(new_notification) log_action('add_repo_notification', namespace, diff --git a/static/directives/create-external-notification-dialog.html b/static/directives/create-external-notification-dialog.html index 0b7401c30..592efc322 100644 --- a/static/directives/create-external-notification-dialog.html +++ b/static/directives/create-external-notification-dialog.html @@ -11,14 +11,14 @@