Add ability for super users to take ownership of namespaces
Fixes #1395
This commit is contained in:
parent
f75949d533
commit
20816804e5
14 changed files with 280 additions and 94 deletions
|
@ -49,3 +49,11 @@
|
|||
.super-user .input-util {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.super-user .take-ownership-dialog .avatar {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.super-user .take-ownership-dialog .co-alert {
|
||||
margin-top: 20px;
|
||||
}
|
|
@ -223,6 +223,14 @@ angular.module('quay').directive('logsView', function () {
|
|||
'service_key_extend': 'Change of expiration of service key {kid} from {old_expiration_date} to {expiration_date}',
|
||||
'service_key_rotate': 'Automatic rotation of service key {kid} by {user_agent}',
|
||||
|
||||
'take_ownership': function(metadata) {
|
||||
if (metadata.was_user) {
|
||||
return 'Superuser {superuser} took ownership of user namespace {namespace}';
|
||||
} else {
|
||||
return 'Superuser {superuser} took ownership of organization {namespace}';
|
||||
}
|
||||
},
|
||||
|
||||
// Note: These are deprecated.
|
||||
'add_repo_webhook': 'Add webhook in repository {repo}',
|
||||
'delete_repo_webhook': 'Delete webhook in repository {repo}'
|
||||
|
@ -279,6 +287,7 @@ angular.module('quay').directive('logsView', function () {
|
|||
'service_key_delete': 'Delete Service Key',
|
||||
'service_key_extend': 'Extend Service Key Expiration',
|
||||
'service_key_rotate': 'Automatic rotation of Service Key',
|
||||
'take_ownership': 'Take Namespace Ownership',
|
||||
|
||||
// Note: these are deprecated.
|
||||
'add_repo_webhook': 'Add webhook',
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
})
|
||||
}]);
|
||||
|
||||
function SuperuserCtrl($scope, $timeout, ApiService, Features, UserService, ContainerService, AngularPollChannel, CoreDialog) {
|
||||
function SuperuserCtrl($scope, $timeout, $location, ApiService, Features, UserService, ContainerService, AngularPollChannel, CoreDialog) {
|
||||
if (!Features.SUPER_USERS) {
|
||||
return;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
|||
$scope.dashboardActive = false;
|
||||
$scope.currentConfig = null;
|
||||
$scope.serviceKeysActive = false;
|
||||
$scope.takeOwnershipInfo = null;
|
||||
|
||||
$scope.setDashboardActive = function(active) {
|
||||
$scope.dashboardActive = active;
|
||||
|
@ -261,6 +262,25 @@
|
|||
});
|
||||
};
|
||||
|
||||
$scope.askTakeOwnership = function(entity, is_org) {
|
||||
$scope.takeOwnershipInfo = {
|
||||
'entity': entity,
|
||||
'is_org': is_org
|
||||
};
|
||||
};
|
||||
|
||||
$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.askDisableUser = function(user) {
|
||||
var message = 'Are you sure you want to disable this user? ' +
|
||||
'They will be unable to login, pull or push.'
|
||||
|
|
|
@ -138,6 +138,9 @@
|
|||
<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)">
|
||||
<i class="fa fa-bolt"></i> Take Ownership
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -223,6 +226,10 @@
|
|||
<span class="cor-option" option-click="askDisableUser(current_user)">
|
||||
<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)"
|
||||
ng-if="user.username != current_user.username && !current_user.super_user">
|
||||
<i class="fa fa-bolt"></i> Take Ownership
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -233,6 +240,21 @@
|
|||
</div> <!-- /cor-tab-content -->
|
||||
</div> <!-- /cor-tab-panel -->
|
||||
|
||||
<!-- Take ownership dialog -->
|
||||
<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
|
||||
<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" size="16"></span> {{ takeOwnershipInfo .entity.username }}?</span>
|
||||
|
||||
<div class="co-alert co-alert-warning" ng-if="!takeOwnershipInfo.is_org">
|
||||
Note: This will convert the user namespace into an organization. <strong>The user will no longer be able to login to this account.</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal message dialog -->
|
||||
<div class="co-dialog modal fade" id="confirmDeleteUserModal">
|
||||
<div class="modal-dialog">
|
||||
|
|
Reference in a new issue