From d1fdc31549804336d58c022c9f205b8a83b2eff2 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 24 Feb 2014 20:36:54 -0500 Subject: [PATCH] - Add a dropdown-select directive and use it in the git trigger setup dialog both times - Add a dropdown-select for the docker file folder - Add an API method for listing the build source sub directories --- endpoints/api.py | 35 ++- static/css/quay.css | 37 ++- static/directives/dropdown-select-icon.html | 1 + static/directives/dropdown-select-menu.html | 1 + static/directives/dropdown-select.html | 13 ++ static/directives/trigger-setup-github.html | 61 +++-- static/js/app.js | 241 ++++++++++++++++---- templates/base.html | 1 + 8 files changed, 331 insertions(+), 59 deletions(-) create mode 100644 static/directives/dropdown-select-icon.html create mode 100644 static/directives/dropdown-select-menu.html create mode 100644 static/directives/dropdown-select.html diff --git a/endpoints/api.py b/endpoints/api.py index 877a14384..01eab914d 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -29,7 +29,7 @@ from auth.permissions import (ReadRepositoryPermission, ViewTeamPermission, UserPermission) from endpoints.common import common_login, get_route_data, truthy_param -from endpoints.trigger import BuildTrigger, TriggerActivationException +from endpoints.trigger import BuildTrigger, TriggerActivationException, EmptyRepositoryException from util.cache import cache_control from datetime import datetime, timedelta @@ -1369,6 +1369,39 @@ def _prepare_webhook_url(scheme, username, password, hostname, path): return urlparse.urlunparse((scheme, auth_hostname, path, '', '', '')) +@api.route('/repository//trigger//subdir', + methods=['POST']) +@api_login_required +@parse_repository_name +def list_build_trigger_subdirs(namespace, repository, trigger_uuid): + permission = AdministerRepositoryPermission(namespace, repository) + if permission.can(): + try: + trigger = model.get_build_trigger(namespace, repository, trigger_uuid) + except model.InvalidBuildTriggerException: + abort(404) + return + + handler = BuildTrigger.get_trigger_for_service(trigger.service.name) + user_permission = UserPermission(trigger.connected_user.username) + if user_permission.can(): + new_config_dict = request.get_json() + + try: + subdirs = handler.list_build_subdirs(trigger.auth_token, new_config_dict) + return jsonify({ + 'subdir': subdirs, + 'status': 'success' + }) + except EmptyRepositoryException as e: + return jsonify({ + 'status': 'error', + 'message': e.msg + }) + + abort(403) # Permission denied + + @api.route('/repository//trigger//activate', methods=['POST']) @api_login_required diff --git a/static/css/quay.css b/static/css/quay.css index c1d8aa8c6..d2861cc0e 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -3254,18 +3254,31 @@ pre.command:before { position: relative; } -.dropdown-select .dropdown-icon { +.dropdown-select .dropdown-select-icon { position: absolute; top: 6px; left: 6px; z-index: 2; + display: none; } -.dropdown-select .dropdown-icon.none-icon { +.dropdown-select .dropdown-select-icon.fa { top: 10px; left: 8px; font-size: 20px; +} + +.dropdown-select .dropdown-select-icon.none-icon { color: #ccc; + display: inline; +} + +.dropdown-select.has-item .dropdown-select-icon { + display: inline; +} + +.dropdown-select.has-item .dropdown-select-icon.none-icon { + display: none; } .dropdown-select .lookahead-input { @@ -3304,4 +3317,24 @@ pre.command:before { .trigger-setup-github-element li.github-org-header { padding-left: 6px; +} + +.slideinout { + -webkit-transition:0.5s all; + transition:0.5s linear all; + opacity: 1; + + position: relative; + + height: 100px; + opacity: 1; +} + +.slideinout.ng-hide { + opacity: 0; + height: 0px; +} + +.slideinout.ng-hide-add, .slideinout.ng-hide-remove { + display: block !important; } \ No newline at end of file diff --git a/static/directives/dropdown-select-icon.html b/static/directives/dropdown-select-icon.html new file mode 100644 index 000000000..8fc5d79b6 --- /dev/null +++ b/static/directives/dropdown-select-icon.html @@ -0,0 +1 @@ + diff --git a/static/directives/dropdown-select-menu.html b/static/directives/dropdown-select-menu.html new file mode 100644 index 000000000..4d6c453f0 --- /dev/null +++ b/static/directives/dropdown-select-menu.html @@ -0,0 +1 @@ + diff --git a/static/directives/dropdown-select.html b/static/directives/dropdown-select.html new file mode 100644 index 000000000..d24cd531e --- /dev/null +++ b/static/directives/dropdown-select.html @@ -0,0 +1,13 @@ +
Please choose the GitHub repository that will trigger the build:
+ + + -