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