diff --git a/static/css/core-ui.css b/static/css/core-ui.css index 165a25dc6..3ba6e89d6 100644 --- a/static/css/core-ui.css +++ b/static/css/core-ui.css @@ -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; } diff --git a/static/directives/repository-permissions-table.html b/static/directives/repository-permissions-table.html index 3ce95c1d5..d5a9d1352 100644 --- a/static/directives/repository-permissions-table.html +++ b/static/directives/repository-permissions-table.html @@ -43,23 +43,23 @@ - - Add New Permission - - - + + placeholder="'Select a ' + (repository.is_organization ? 'team or ' : '') + 'user...'" + current-entity="addPermissionInfo.entity"> - - + + + + - diff --git a/static/js/directives/ui/repository-permissions-table.js b/static/js/directives/ui/repository-permissions-table.js index fb3601d68..a0dfaddb2 100644 --- a/static/js/directives/ui/repository-permissions-table.js +++ b/static/js/directives/ui/repository-permissions-table.js @@ -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); };