Finish permissions table support
This commit is contained in:
parent
dc5d40ddc3
commit
32956b6713
3 changed files with 31 additions and 15 deletions
|
@ -804,6 +804,11 @@
|
|||
width: 30px;
|
||||
}
|
||||
|
||||
.co-table .add-row td {
|
||||
border-top: 2px solid #eee;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.cor-checkable-menu {
|
||||
display: inline-block;
|
||||
}
|
||||
|
|
|
@ -43,23 +43,23 @@
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="3"><a href="asdasdasd">Add New Permission</a></td>
|
||||
</tr>
|
||||
|
||||
<tr style="background: #eee; ">
|
||||
<tr class="add-row">
|
||||
<td id="add-entity-permission" class="admin-search">
|
||||
<span class="entity-search" namespace="repository.namespace"
|
||||
placeholder="'Add a ' + (repository.is_organization ? 'team or ' : '') + 'user...'"
|
||||
entity-selected="addNewPermission(entity)"
|
||||
current-entity="selectedEntity"
|
||||
auto-clear="true"></span>
|
||||
placeholder="'Select a ' + (repository.is_organization ? 'team or ' : '') + 'user...'"
|
||||
current-entity="addPermissionInfo.entity"></span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="role-group" current-role="permission.role" role-changed="setRole(role, name, 'team')" roles="roles"></span>
|
||||
|
||||
<span class="role-group" current-role="addPermissionInfo.role" roles="roles"
|
||||
role-changed="addPermissionInfo.role = role"></span>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-success"
|
||||
ng-disabled="!addPermissionInfo.role || !addPermissionInfo.entity"
|
||||
ng-click="addPermission()">
|
||||
Add Permission
|
||||
</button>
|
||||
</td>
|
||||
<td><button class="btn btn-success">Add Permission</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -22,6 +22,7 @@ angular.module('quay').directive('repositoryPermissionsTable', function () {
|
|||
$scope.permissionResources = {'team': {}, 'user': {}};
|
||||
$scope.permissionCache = {};
|
||||
$scope.permissions = {};
|
||||
$scope.addPermissionInfo = {};
|
||||
|
||||
var loadAllPermissions = function() {
|
||||
if (!$scope.repository) { return; }
|
||||
|
@ -71,13 +72,21 @@ angular.module('quay').directive('repositoryPermissionsTable', function () {
|
|||
};
|
||||
};
|
||||
|
||||
$scope.addPermission = function() {
|
||||
$scope.addPermissionInfo['working'] = true;
|
||||
$scope.addNewPermission($scope.addPermissionInfo.entity, $scope.addPermissionInfo.role)
|
||||
};
|
||||
|
||||
$scope.grantPermission = function(entity, callback) {
|
||||
$scope.addRole(entity.name, 'read', entity.kind, callback);
|
||||
};
|
||||
|
||||
$scope.addNewPermission = function(entity) {
|
||||
$scope.addNewPermission = function(entity, opt_role) {
|
||||
// Don't allow duplicates.
|
||||
if (!entity || !entity.kind || $scope.permissions[entity.kind][entity.name]) { return; }
|
||||
if (!entity || !entity.kind || $scope.permissions[entity.kind][entity.name]) {
|
||||
$scope.addPermissionInfo = {};
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity.is_org_member === false) {
|
||||
$scope.grantPermissionInfo = {
|
||||
|
@ -86,7 +95,7 @@ angular.module('quay').directive('repositoryPermissionsTable', function () {
|
|||
return;
|
||||
}
|
||||
|
||||
$scope.addRole(entity.name, 'read', entity.kind);
|
||||
$scope.addRole(entity.name, opt_role || 'read', entity.kind);
|
||||
};
|
||||
|
||||
$scope.deleteRole = function(entityName, kind) {
|
||||
|
@ -109,11 +118,13 @@ angular.module('quay').directive('repositoryPermissionsTable', function () {
|
|||
|
||||
var errorHandler = ApiService.errorDisplay('Cannot change permission', function() {
|
||||
opt_callback && opt_callback(false);
|
||||
$scope.addPermissionInfo = {};
|
||||
});
|
||||
|
||||
var endpoint = getPermissionEndpoint(entityName, kind);
|
||||
endpoint.customPUT(permission).then(function(result) {
|
||||
$scope.permissions[kind][entityName] = result;
|
||||
$scope.addPermissionInfo = {};
|
||||
opt_callback && opt_callback(true)
|
||||
}, errorHandler);
|
||||
};
|
||||
|
|
Reference in a new issue