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
This commit is contained in:
Joseph Schorr 2017-03-22 12:25:20 -04:00
parent 789e35668c
commit 1d3af2b0bd
4 changed files with 32 additions and 12 deletions

View file

@ -86,7 +86,7 @@
<i class="fa" ng-class="current_user.enabled ? 'fa-circle-o' : 'fa-check-circle-o'"></i> <span
ng-if="current_user.enabled">Disable</span> <span ng-if="!current_user.enabled">Enable</span> User
</span>
<span class="cor-option" option-click="askTakeOwnership(current_user, false)"
<span class="cor-option" option-click="askTakeOwnership(current_user)"
ng-if="user.username != current_user.username && !current_user.super_user">
<i class="fa fa-bolt"></i> Take Ownership
</span>
@ -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
<span ng-if="takeOwnershipInfo.is_org">organization <span class="avatar" data="takeOwnershipInfo.entity.avatar"
size="16"></span> {{ takeOwnershipInfo.entity.name }}?</span>
<span ng-if="!takeOwnershipInfo.is_org">user namespace <span class="avatar" data="takeOwnershipInfo.entity.avatar"
Are you sure you want to take ownership of user namespace <span class="avatar" data="takeOwnershipInfo.entity.avatar"
size="16"></span> {{ takeOwnershipInfo .entity.username }}?</span>
<div class="co-alert co-alert-warning" ng-if="!takeOwnershipInfo.is_org">
<div class="co-alert co-alert-warning">
Note: This will convert the user namespace into an organization. <strong>The user will no longer be able to login
to
this account.</strong>

View file

@ -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
};
};

View file

@ -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');

View file

@ -172,7 +172,7 @@
<span class="cor-option" option-click="askDeleteOrganization(current_org)">
<i class="fa fa-times"></i> Delete Organization
</span>
<span class="cor-option" option-click="askTakeOwnership(current_org, true)">
<span class="cor-option" option-click="askTakeOwnership(current_org)">
<i class="fa fa-bolt"></i> Take Ownership
</span>
</span>
@ -211,6 +211,13 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="cor-confirm-dialog take-ownership-dialog"
dialog-context="takeOwnershipInfo"
dialog-action="takeOwnership(info, callback)"
dialog-title="Take Ownership"
dialog-action-title="Take Ownership">
Are you sure you want to take ownership of organization <span class="avatar" data="takeOwnershipInfo.entity.avatar" size="16"></span> {{ takeOwnershipInfo.entity.name }}?</span>
</div>
</div> <!-- /page-content -->
</div>