diff --git a/endpoints/api.py b/endpoints/api.py index aee4947d9..b245d131f 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -1516,10 +1516,10 @@ def get_org_subscription(orgname): abort(403) -def robot_view(name, password): +def robot_view(name, token): return { 'name': name, - 'password': password, + 'token': token, } diff --git a/static/css/quay.css b/static/css/quay.css index bf3f1124a..8ff8c4880 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -6,6 +6,26 @@ visibility: hidden; } +.robots-manager-element { + max-width: 800px; +} + +.robots-manager-element .alert { + margin-bottom: 20px; +} + +.robots-manager-element .robot { + font-size: 16px; +} + +.robots-manager-element .robot .prefix { + color: #aaa; +} + +.robots-manager-element .robot i { + margin-right: 10px; +} + .billing-options-element .current-card { font-size: 16px; margin-bottom: 20px; @@ -1671,16 +1691,16 @@ p.editable:hover i { margin-right: 4px; } -.org-admin #members .side-controls { +.side-controls { float: right; } -.org-admin #members .result-count { +.side-controls .result-count { display: inline-block; margin-right: 10px; } -.org-admin #members .filter-input { +.side-controls .filter-input { display: inline-block; } diff --git a/static/directives/robots-manager.html b/static/directives/robots-manager.html new file mode 100644 index 000000000..21e916296 --- /dev/null +++ b/static/directives/robots-manager.html @@ -0,0 +1,31 @@ +
+ +
Robot accounts allow for delegating access in multiple repositories to tokens
+ +
+
+ +
+ + + + + + + + + + + +
Robot Account Name
+ + {{ getPrefix(robotInfo.name) }}+{{ getShortenedName(robotInfo.name) }} + + + + + +
+ +
+
diff --git a/static/js/app.js b/static/js/app.js index 376c0feb3..be084ac50 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -529,6 +529,72 @@ quayApp.directive('plansTable', function () { }); + +quayApp.directive('robotsManager', function () { + var directiveDefinitionObject = { + priority: 0, + templateUrl: '/static/directives/robots-manager.html', + replace: false, + transclude: true, + restrict: 'C', + scope: { + 'organization': '=organization', + 'user': '=user' + }, + controller: function($scope, $element, Restangular) { + $scope.robots = null; + $scope.loading = false; + + $scope.getShortenedName = function(name) { + var plus = name.indexOf('+'); + return name.substr(plus + 1); + }; + + $scope.getPrefix = function(name) { + var plus = name.indexOf('+'); + return name.substr(0, plus); + }; + + $scope.deleteRobot = function(info) { + var shortName = $scope.getShortenedName(info.name); + var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'robots', shortName) : + getRestUrl('user/robots', shortName); + + var deleteRobot = Restangular.one(url); + deleteRobot.customDELETE().then(function(resp) { + for (var i = 0; i < $scope.robots.length; ++i) { + if ($scope.robots[i].name == info.name) { + $scope.robots.slice(i, 1); + return; + } + } + }, function() { + + }); + }; + + var update = function() { + if (!$scope.user && !$scope.organization) { return; } + if ($scope.loading) { return; } + + $scope.loading = true; + var url = $scope.organization ? getRestUrl('organization', $scope.organization.name, 'robots') : 'user/robots'; + var getRobots = Restangular.one(url); + getRobots.customGET($scope.obj).then(function(resp) { + $scope.robots = resp.robots; + $scope.loading = false; + }); + }; + + $scope.$watch('organization', update); + $scope.$watch('user', update); + } + }; + return directiveDefinitionObject; +}); + + + quayApp.directive('organizationHeader', function () { var directiveDefinitionObject = { priority: 0, diff --git a/static/partials/org-admin.html b/static/partials/org-admin.html index 46e3af4ea..3fead806a 100644 --- a/static/partials/org-admin.html +++ b/static/partials/org-admin.html @@ -15,6 +15,7 @@ @@ -28,6 +29,11 @@
+ +
+
+
+
diff --git a/static/partials/user-admin.html b/static/partials/user-admin.html index e6c7123e6..bdf222523 100644 --- a/static/partials/user-admin.html +++ b/static/partials/user-admin.html @@ -28,6 +28,7 @@ @@ -59,6 +60,11 @@
+ +
+
+
+