From dc05134e41d15e90630388e7ddc2931c60b72633 Mon Sep 17 00:00:00 2001 From: Stan Silvert Date: Wed, 15 Nov 2017 14:12:03 -0500 Subject: [PATCH] KEYCLOAK-5850: Del realm role broken on permissions & Users tabs. --- .../admin/resources/js/authz/authz-controller.js | 7 ++++++- .../base/admin/resources/js/controllers/realm.js | 14 +++----------- .../base/admin/resources/js/controllers/roles.js | 7 +++++-- .../theme/base/admin/resources/js/services.js | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js index 9233a04389..e164f59a03 100644 --- a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js @@ -2536,10 +2536,15 @@ getManageClientId = function(realm) { } } -module.controller('RealmRolePermissionsCtrl', function($scope, $http, $route, $location, realm, role, RoleManagementPermissions, Client, Notifications) { +module.controller('RealmRolePermissionsCtrl', function($scope, $http, $route, $location, realm, role, RoleManagementPermissions, Client, Notifications, Dialog, RealmRoleRemover) { console.log('RealmRolePermissionsCtrl'); $scope.role = role; $scope.realm = realm; + + $scope.remove = function() { + RealmRoleRemover.remove($scope.role, realm, Dialog, $location, Notifications); + }; + RoleManagementPermissions.get({realm: realm.realm, role: role.id}, function(data) { $scope.permissions = data; $scope.$watch('permissions.enabled', function(newVal, oldVal) { diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js index 715effa292..bf8120382a 100644 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js @@ -1433,7 +1433,7 @@ module.controller('RoleListCtrl', function($scope, $route, Dialog, Notifications module.controller('RoleDetailCtrl', function($scope, realm, role, roles, clients, Role, ClientRole, RoleById, RoleRealmComposites, RoleClientComposites, - $http, $location, Dialog, Notifications) { + $http, $location, Dialog, Notifications, RealmRoleRemover) { $scope.realm = realm; $scope.role = angular.copy(role); $scope.create = !role.name; @@ -1460,16 +1460,8 @@ module.controller('RoleDetailCtrl', function($scope, realm, role, roles, clients } }; - $scope.remove = function () { - Dialog.confirmDelete($scope.role.name, 'role', function () { - $scope.role.$remove({ - realm: realm.realm, - role: $scope.role.id - }, function () { - $location.url("/realms/" + realm.realm + "/roles"); - Notifications.success("The role has been deleted."); - }); - }); + $scope.remove = function() { + RealmRoleRemover.remove($scope.role, realm, Dialog, $location, Notifications); }; $scope.cancel = function () { diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/roles.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/roles.js index 185913abb7..bc24c578eb 100644 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/roles.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/roles.js @@ -1,4 +1,4 @@ -module.controller('RoleMembersCtrl', function($scope, realm, role, RoleMembership) { +module.controller('RoleMembersCtrl', function($scope, realm, role, RoleMembership, Dialog, Notifications, $location, RealmRoleRemover) { $scope.realm = realm; $scope.page = 0; $scope.role = role; @@ -10,7 +10,10 @@ module.controller('RoleMembersCtrl', function($scope, realm, role, RoleMembershi first : 0 } - + $scope.remove = function() { + RealmRoleRemover.remove($scope.role, realm, Dialog, $location, Notifications); + }; + $scope.firstPage = function() { $scope.query.first = 0; $scope.searchQuery(); diff --git a/themes/src/main/resources/theme/base/admin/resources/js/services.js b/themes/src/main/resources/theme/base/admin/resources/js/services.js index 9297965e4d..ac0430c778 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/services.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/services.js @@ -461,6 +461,20 @@ module.service('LastFlowSelected', function() { this.alias = null; }); +module.service('RealmRoleRemover', function() { + this.remove = function (role, realm, Dialog, $location, Notifications) { + Dialog.confirmDelete(role.name, 'role', function () { + role.$remove({ + realm: realm.realm, + role: role.id + }, function () { + $location.url("/realms/" + realm.realm + "/roles"); + Notifications.success("The role has been deleted."); + }); + }); + }; +}); + module.factory('UserSessionStats', function($resource) { return $resource(authUrl + '/admin/realms/:realm/users/:user/session-stats', { realm : '@realm',