From 1d3af2b0bdef933f0804fd292f03dd260e5e6339 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 22 Mar 2017 12:25:20 -0400 Subject: [PATCH] Fix take ownership of organizations Take ownership code got moved into its own directive in Oct, but we forgot we have a call in superuser panel for orgs as well. Fix this, and simplify the call sites --- static/directives/manage-users-tab.html | 10 +++------- static/js/directives/ui/manage-user-tab.js | 5 ++--- static/js/pages/superuser.js | 20 +++++++++++++++++++- static/partials/super-user.html | 9 ++++++++- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/static/directives/manage-users-tab.html b/static/directives/manage-users-tab.html index 730ebf15a..58be3248f 100644 --- a/static/directives/manage-users-tab.html +++ b/static/directives/manage-users-tab.html @@ -86,7 +86,7 @@ Disable Enable User - Take Ownership @@ -102,13 +102,9 @@ dialog-action="takeOwnership(info, callback)" dialog-title="Take Ownership" dialog-action-title="Take Ownership"> - Are you sure you want to take ownership of - organization {{ takeOwnershipInfo.entity.name }}? - user namespace {{ takeOwnershipInfo .entity.username }}? - -
+
Note: This will convert the user namespace into an organization. The user will no longer be able to login to this account. diff --git a/static/js/directives/ui/manage-user-tab.js b/static/js/directives/ui/manage-user-tab.js index 7695936b4..8e86cb0a7 100644 --- a/static/js/directives/ui/manage-user-tab.js +++ b/static/js/directives/ui/manage-user-tab.js @@ -228,10 +228,9 @@ angular.module('quay').directive('manageUserTab', function () { }); }; - $scope.askTakeOwnership = function (entity, is_org) { + $scope.askTakeOwnership = function (entity) { $scope.takeOwnershipInfo = { - 'entity': entity, - 'is_org': is_org + 'entity': entity }; }; diff --git a/static/js/pages/superuser.js b/static/js/pages/superuser.js index b94db2314..d8b02051b 100644 --- a/static/js/pages/superuser.js +++ b/static/js/pages/superuser.js @@ -10,7 +10,7 @@ }) }]); - function SuperuserCtrl($scope, ApiService, Features, UserService, ContainerService, AngularPollChannel, CoreDialog, TableService) { + function SuperuserCtrl($scope, $location, ApiService, Features, UserService, ContainerService, AngularPollChannel, CoreDialog, TableService) { if (!Features.SUPER_USERS) { return; } @@ -198,6 +198,24 @@ }); }; + $scope.askTakeOwnership = function (entity) { + $scope.takeOwnershipInfo = { + 'entity': entity + }; + }; + + $scope.takeOwnership = function (info, callback) { + var errorDisplay = ApiService.errorDisplay('Could not take ownership of namespace', callback); + var params = { + 'namespace': info.entity.username || info.entity.name + }; + + ApiService.takeOwnership(null, params).then(function () { + callback(true); + $location.path('/organization/' + params.namespace); + }, errorDisplay) + }; + $scope.checkStatus = function() { ContainerService.checkStatus(function(resp) { $('#restartingContainerModal').modal('hide'); diff --git a/static/partials/super-user.html b/static/partials/super-user.html index ec6c6b519..827a49e59 100644 --- a/static/partials/super-user.html +++ b/static/partials/super-user.html @@ -172,7 +172,7 @@ Delete Organization - + Take Ownership @@ -211,6 +211,13 @@
+
+ Are you sure you want to take ownership of organization {{ takeOwnershipInfo.entity.name }}? +