keycloak-uncached

Changes

Details

diff --git a/services/src/main/java/org/keycloak/authorization/admin/PolicyResourceService.java b/services/src/main/java/org/keycloak/authorization/admin/PolicyResourceService.java
index dd9acb3..f4df4c4 100644
--- a/services/src/main/java/org/keycloak/authorization/admin/PolicyResourceService.java
+++ b/services/src/main/java/org/keycloak/authorization/admin/PolicyResourceService.java
@@ -215,6 +215,7 @@ public class PolicyResourceService {
             representation1.setId(policy.getId());
             representation1.setName(policy.getName());
             representation1.setType(policy.getType());
+            representation1.setDescription(policy.getDescription());
 
             return representation1;
         }).collect(Collectors.toList())).build();
diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/authorization/policy/AggregatePolicyForm.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/authorization/policy/AggregatePolicyForm.java
index cf01f24..8ed8c39 100644
--- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/authorization/policy/AggregatePolicyForm.java
+++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/authorization/policy/AggregatePolicyForm.java
@@ -179,7 +179,7 @@ public class AggregatePolicyForm extends Form {
 
                 if (!tds.get(0).getText().isEmpty()) {
                     if (tds.get(0).getText().equals(name)) {
-                        tds.get(2).click();
+                        tds.get(3).click();
                         return true;
                     }
                 }
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 88a9573..e6f7d5c 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
@@ -871,7 +871,7 @@ module.controller('ResourceServerPolicyDroolsDetailCtrl', function($scope, $http
     }, realm, client, $scope);
 });
 
-module.controller('ResourceServerPolicyResourceDetailCtrl', function($scope, $route, $location, realm, client, PolicyController, ResourceServerPermission, ResourceServerResource) {
+module.controller('ResourceServerPolicyResourceDetailCtrl', function($scope, $route, $location, realm, client, PolicyController, ResourceServerPermission, ResourceServerResource, policyState) {
     PolicyController.onInit({
         getPolicyType : function() {
             return "resource";
@@ -1009,7 +1009,7 @@ module.controller('ResourceServerPolicyResourceDetailCtrl', function($scope, $ro
         },
 
         onInitCreate : function(newPolicy) {
-            newPolicy.decisionStrategy = 'UNANIMOUS';
+            policyState.state.previousPage.name = 'authz-add-resource-permission';
             $scope.selectedResource = null;
             var copy = angular.copy($scope.selectedResource);
             $scope.$watch('selectedResource', function() {
@@ -1058,11 +1058,22 @@ module.controller('ResourceServerPolicyResourceDetailCtrl', function($scope, $ro
 
             $scope.policy.policies = policies;
             delete $scope.policy.config;
+        },
+
+        onSaveState : function(policy) {
+            policyState.state.selectedResource = $scope.selectedResource;
+            policyState.state.applyToResourceTypeFlag = $scope.applyToResourceTypeFlag;
+        },
+
+        onRestoreState : function(policy) {
+            $scope.selectedResource = policyState.state.selectedResource;
+            $scope.applyToResourceTypeFlag = policyState.state.applyToResourceTypeFlag;
+            policy.resourceType = policyState.state.policy.resourceType;
         }
     }, realm, client, $scope);
 });
 
-module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route, $location, realm, client, PolicyController, ResourceServerPolicy, ResourceServerResource, ResourceServerScope) {
+module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route, $location, realm, client, PolicyController, ResourceServerPolicy, ResourceServerResource, ResourceServerScope, policyState) {
     PolicyController.onInit({
         getPolicyType : function() {
             return "scope";
@@ -1307,8 +1318,7 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
         },
 
         onInitCreate : function(newPolicy) {
-            newPolicy.decisionStrategy = 'UNANIMOUS';
-
+            policyState.state.previousPage.name = 'authz-add-scope-permission';
             var scopeId = $location.search()['scpid'];
 
             if (scopeId) {
@@ -1351,6 +1361,18 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
 
             $scope.policy.policies = policies;
             delete $scope.policy.config;
+        },
+
+        onSaveState : function(policy) {
+            policyState.state.selectedScopes = $scope.selectedScopes;
+            policyState.state.selectedResource = $scope.selectedResource;
+            policyState.state.resourceScopes = $scope.resourceScopes;
+        },
+
+        onRestoreState : function(policy) {
+            $scope.selectedScopes = policyState.state.selectedScopes;
+            $scope.selectedResource = policyState.state.selectedResource;
+            $scope.resourceScopes = policyState.state.resourceScopes;
         }
     }, realm, client, $scope);
 });
@@ -1890,6 +1912,7 @@ module.controller('ResourceServerPolicyTimeDetailCtrl', function($scope, $route,
         },
 
         onInit : function() {
+
         },
 
         onInitUpdate : function(policy) {
@@ -1991,68 +2014,26 @@ module.controller('ResourceServerPolicyAggregateDetailCtrl', function($scope, $r
                     return object.name;
                 }
             };
-
-            $scope.policyProviders = [];
-
-            PolicyProvider.query({
-                realm : $route.current.params.realm,
-                client : client.id
-            }, function (data) {
-                for (i = 0; i < data.length; i++) {
-                    if (data[i].type != 'resource' && data[i].type != 'scope') {
-                        $scope.policyProviders.push(data[i]);
-                    }
-                }
-            });
         },
 
         onInitUpdate : function(policy) {
-            if (PolicyController.isBackNewAssociatedPolicy()) {
-                policy.name = policyState.state.name;
-                policy.description = policyState.state.description;
-                policy.decisionStrategy = policyState.state.decisionStrategy;
-                policy.logic = policyState.state.logic;
-                $scope.selectedPolicies = policyState.state.selectedPolicies;
-
-                if (!$scope.selectedPolicies) {
-                    $scope.selectedPolicies = [];
+            ResourceServerPolicy.associatedPolicies({
+                realm : $route.current.params.realm,
+                client : client.id,
+                id : policy.id
+            }, function(policies) {
+                $scope.selectedPolicies = [];
+                for (i = 0; i < policies.length; i++) {
+                    policies[i].text = policies[i].name;
+                    $scope.selectedPolicies.push(policies[i]);
                 }
-
-                $scope.changed = true;
-                ResourceServerPolicy.query({
-                   realm: realm.realm,
-                   client : client.id,
-                   permission: false,
-                   name: policyState.state.newPolicyName,
-                   max : 20,
-                   first : 0
-               }, function(response) {
-                    for (i = 0; i < response.length; i++) {
-                        if (response[i].name == policyState.state.newPolicyName) {
-                            response[i].text = response[i].name;
-                            $scope.selectedPolicies.push(response[i]);
-                        }
-                    }
-                });
-            } else {
-                ResourceServerPolicy.associatedPolicies({
-                    realm : $route.current.params.realm,
-                    client : client.id,
-                    id : policy.id
-                }, function(policies) {
-                    $scope.selectedPolicies = [];
-                    for (i = 0; i < policies.length; i++) {
-                        policies[i].text = policies[i].name;
-                        $scope.selectedPolicies.push(policies[i]);
+                var copy = angular.copy($scope.selectedPolicies);
+                $scope.$watch('selectedPolicies', function() {
+                    if (!angular.equals($scope.selectedPolicies, copy)) {
+                        $scope.changed = true;
                     }
-                    var copy = angular.copy($scope.selectedPolicies);
-                    $scope.$watch('selectedPolicies', function() {
-                        if (!angular.equals($scope.selectedPolicies, copy)) {
-                            $scope.changed = true;
-                        }
-                    }, true);
-                });
-            }
+                }, true);
+            });
         },
 
         onUpdate : function() {
@@ -2067,37 +2048,7 @@ module.controller('ResourceServerPolicyAggregateDetailCtrl', function($scope, $r
         },
 
         onInitCreate : function(newPolicy) {
-            policyState.previousPage.name = 'authz-add-aggregated-policy';
-            if (PolicyController.isBackNewAssociatedPolicy()) {
-                newPolicy.name = policyState.state.name;
-                newPolicy.description = policyState.state.description;
-                newPolicy.decisionStrategy = policyState.state.decisionStrategy;
-                newPolicy.logic = policyState.state.logic;
-                $scope.selectedPolicies = policyState.state.selectedPolicies;
-
-                if (!$scope.selectedPolicies) {
-                    $scope.selectedPolicies = [];
-                }
-
-                $scope.changed = true;
-                ResourceServerPolicy.query({
-                   realm: realm.realm,
-                   client : client.id,
-                   permission: false,
-                   name: policyState.state.newPolicyName,
-                   max : 20,
-                   first : 0
-               }, function(response) {
-                    for (i = 0; i < response.length; i++) {
-                        if (response[i].name == policyState.state.newPolicyName) {
-                            response[i].text = response[i].name;
-                            $scope.selectedPolicies.push(response[i]);
-                        }
-                    }
-                });
-            } else {
-                newPolicy.decisionStrategy = 'UNANIMOUS';
-            }
+            policyState.state.previousPage.name = 'authz-add-aggregated-policy';
         },
 
         onCreate : function() {
@@ -2113,7 +2064,7 @@ module.controller('ResourceServerPolicyAggregateDetailCtrl', function($scope, $r
     }, realm, client, $scope);
 });
 
-module.service("PolicyController", function($http, $route, $location, ResourceServer, ResourceServerPolicy, ResourceServerPermission, AuthzDialog, Notifications, policyState) {
+module.service("PolicyController", function($http, $route, $location, ResourceServer, ResourceServerPolicy, ResourceServerPermission, AuthzDialog, Notifications, policyState, PolicyProvider) {
 
     var PolicyController = {};
 
@@ -2126,14 +2077,36 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
     }
 
     PolicyController.onInit = function(delegate, realm, client, $scope) {
-        if (!policyState.previousPage) {
-            policyState.previousPage = {};
+        $scope.policyProviders = [];
+
+        PolicyProvider.query({
+            realm : $route.current.params.realm,
+            client : client.id
+        }, function (data) {
+            for (i = 0; i < data.length; i++) {
+                if (data[i].type != 'resource' && data[i].type != 'scope') {
+                    $scope.policyProviders.push(data[i]);
+                }
+            }
+        });
+
+        if ((!policyState.state || !PolicyController.isBackNewAssociatedPolicy()) && !PolicyController.isNewAssociatedPolicy()) {
+            policyState.state = {};
+        }
+
+        if (!policyState.state.previousPage) {
+            policyState.state.previousPage = {};
         }
 
         $scope.policyState = policyState;
 
         $scope.addPolicy = function(policyType) {
-            policyState.state = $scope.policy;
+            policyState.state.policy = $scope.policy;
+
+            if (delegate.onSaveState) {
+               delegate.onSaveState($scope.policy);
+            }
+
             if ($scope.selectedPolicies) {
                 policyState.state.selectedPolicies = $scope.selectedPolicies;
             }
@@ -2147,7 +2120,10 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
         }
 
         $scope.detailPolicy = function(policy) {
-            policyState.state = $scope.policy;
+            policyState.state.policy = $scope.policy;
+            if (delegate.onSaveState) {
+               delegate.onSaveState($scope.policy);
+            }
             if ($scope.selectedPolicies) {
                 policyState.state.selectedPolicies = $scope.selectedPolicies;
             }
@@ -2236,10 +2212,7 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
                 policy.type = delegate.getPolicyType();
                 policy.config = {};
                 policy.logic = 'POSITIVE';
-
-                if (delegate.onInitCreate) {
-                    delegate.onInitCreate(policy);
-                }
+                policy.decisionStrategy = 'UNANIMOUS';
 
                 $scope.changed = $scope.historyBackOnSaveOrCancel || PolicyController.isBackNewAssociatedPolicy();
 
@@ -2251,6 +2224,15 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
                     }
                 }, true);
 
+                if (PolicyController.isBackNewAssociatedPolicy()) {
+                    if (delegate.onRestoreState) {
+                        delegate.onRestoreState($scope.policy);
+                    }
+                    $instance.restoreState($scope);
+                } else if (delegate.onInitCreate) {
+                   delegate.onInitCreate(policy);
+                }
+
                 $scope.save = function() {
                     $instance.checkNameAvailability(function () {
                         if (delegate.onCreate) {
@@ -2303,12 +2285,18 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
                     $scope.originalPolicy = data;
                     var policy = angular.copy(data);
 
-                    if (delegate.onInitUpdate) {
+                    $scope.changed = $scope.historyBackOnSaveOrCancel || PolicyController.isBackNewAssociatedPolicy();
+
+                    if (PolicyController.isBackNewAssociatedPolicy()) {
+                        if (delegate.onRestoreState) {
+                            delegate.onRestoreState($scope.policy);
+                        }
+                        $instance.restoreState($scope);
+                    } else if (delegate.onInitUpdate) {
                         delegate.onInitUpdate(policy);
                     }
 
                     $scope.policy = angular.copy(policy);
-                    $scope.changed = $scope.historyBackOnSaveOrCancel || PolicyController.isBackNewAssociatedPolicy();
 
                     $scope.$watch('policy', function() {
                         if (!angular.equals($scope.policy, policy)) {
@@ -2316,16 +2304,28 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
                         }
                     }, true);
 
+
                     $scope.save = function() {
                         $instance.checkNameAvailability(function () {
                             if (delegate.onUpdate) {
                                 delegate.onUpdate();
                             }
                             service.update({realm : realm.realm, client : client.id, type: $scope.policy.type, id : $scope.policy.id}, $scope.policy, function() {
-                                $route.reload();
                                 if (delegate.isPermission()) {
+                                    if ($scope.historyBackOnSaveOrCancel) {
+                                        $location.url(policyState.state.previousUrl);
+                                    } else {
+                                        $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/permission/" + $scope.policy.type + "/" + $scope.policy.id);
+                                    }
+                                    $route.reload();
                                     Notifications.success("The permission has been updated.");
                                 } else {
+                                    if ($scope.historyBackOnSaveOrCancel) {
+                                        $location.url(policyState.state.previousUrl);
+                                    } else {
+                                        $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/policy/" + $scope.policy.type + "/" + $scope.policy.id);
+                                    }
+                                    $route.reload();
                                     Notifications.success("The policy has been updated.");
                                 }
                             });
@@ -2374,6 +2374,44 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
                 }
             });
         }
+
+        this.restoreState = function($scope) {
+            $scope.policy.name = policyState.state.policy.name;
+            $scope.policy.description = policyState.state.policy.description;
+            $scope.policy.decisionStrategy = policyState.state.policy.decisionStrategy;
+            $scope.policy.logic = policyState.state.policy.logic;
+            $scope.selectedPolicies = policyState.state.selectedPolicies;
+
+            if (!$scope.selectedPolicies) {
+                $scope.selectedPolicies = [];
+            }
+
+            $scope.changed = true;
+            var previousPage = policyState.state.previousPage;
+
+            if (policyState.state.newPolicyName) {
+                ResourceServerPolicy.query({
+                   realm: realm.realm,
+                   client : client.id,
+                   permission: false,
+                   name: policyState.state.newPolicyName,
+                   max : 20,
+                   first : 0
+               }, function(response) {
+                    for (i = 0; i < response.length; i++) {
+                        if (response[i].name == policyState.state.newPolicyName) {
+                            response[i].text = response[i].name;
+                            $scope.selectedPolicies.push(response[i]);
+                        }
+                    }
+                    policyState.state = {};
+                    policyState.state.previousPage = previousPage;
+                });
+            } else {
+                policyState.state = {};
+                policyState.state.previousPage = previousPage;
+            }
+        }
     }
 
     return PolicyController;
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-resource-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-resource-detail.html
index 89f8b36..cbd06fd 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-resource-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-resource-detail.html
@@ -54,11 +54,46 @@
             </div>
             <div class="form-group clearfix">
                 <label class="col-md-2 control-label" for="policies">{{:: 'authz-policy-apply-policy' | translate}} <span class="required">*</span></label>
-
-                <div class="col-md-6">
-                    <input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-model="selectedPolicies" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..." multiple />
+                <div class="col-sm-6">
+                     <input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-change="selectPolicy(selectedPolicy);" data-ng-model="selectedPolicy" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..." />
+                    <p/>
+                    <table class="table table-striped table-bordered" id="selected-policies">
+                        <thead>
+                        <tr>
+                            <th class="kc-table-actions" colspan="3">
+                                <div class="form-inline">
+                                    <div class="form-group">
+                                    </div>
+                                    <div class="pull-right">
+                                        <select id="create-policy" class="form-control" ng-model="policyType"
+                                                ng-options="p.name for p in policyProviders track by p.type"
+                                                data-ng-change="addPolicy(policyType);">
+                                            <option value="" disabled selected>{{:: 'authz-create-policy' | translate}}...</option>
+                                        </select>
+                                    </div>
+                                </div>
+                            </th>
+                        </tr>
+                        <tr data-ng-hide="!selectedPolicies || selectedPolicies.length == 0">
+                            <th>{{:: 'name' | translate}}</th>
+                            <th>{{:: 'description' | translate}}</th>
+                            <th>{{:: 'actions' | translate}}</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr ng-repeat="policy in selectedPolicies">
+                            <td><a href="" data-ng-click="detailPolicy(policy)">{{policy.name}}</a></td>
+                            <td>{{policy.description}}</td>
+                            <td class="kc-action-cell" ng-click="removePolicy(selectedPolicies, policy);">
+                                {{:: 'remove' | translate}}
+                            </td>
+                        </tr>
+                        <tr data-ng-show="!selectedPolicies || selectedPolicies.length == 0">
+                            <td class="text-muted" colspan="3">{{:: 'authz-no-policies-assigned' | translate}}</td>
+                        </tr>
+                        </tbody>
+                    </table>
                 </div>
-
                 <kc-tooltip>{{:: 'authz-policy-apply-policy.tooltip' | translate}}</kc-tooltip>
             </div>
             <div class="form-group clearfix">
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-scope-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-scope-detail.html
index 49e533f..4f469a2 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-scope-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-scope-detail.html
@@ -58,11 +58,46 @@
             </div>
             <div class="form-group clearfix">
                 <label class="col-md-2 control-label" for="policies">{{:: 'authz-policy-apply-policy' | translate}} <span class="required">*</span></label>
-
-                <div class="col-md-6">
-                    <input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-model="selectedPolicies" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..." multiple />
+                <div class="col-sm-6">
+                    <input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-change="selectPolicy(selectedPolicy);" data-ng-model="selectedPolicy" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..." />
+                    <p/>
+                    <table class="table table-striped table-bordered" id="selected-policies">
+                        <thead>
+                        <tr>
+                            <th class="kc-table-actions" colspan="3">
+                                <div class="form-inline">
+                                    <div class="form-group">
+                                    </div>
+                                    <div class="pull-right">
+                                        <select id="create-policy" class="form-control" ng-model="policyType"
+                                                ng-options="p.name for p in policyProviders track by p.type"
+                                                data-ng-change="addPolicy(policyType);">
+                                            <option value="" disabled selected>{{:: 'authz-create-policy' | translate}}...</option>
+                                        </select>
+                                    </div>
+                                </div>
+                            </th>
+                        </tr>
+                        <tr data-ng-hide="!selectedPolicies || selectedPolicies.length == 0">
+                            <th>{{:: 'name' | translate}}</th>
+                            <th>{{:: 'description' | translate}}</th>
+                            <th>{{:: 'actions' | translate}}</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr ng-repeat="policy in selectedPolicies">
+                            <td><a href="" data-ng-click="detailPolicy(policy)">{{policy.name}}</a></td>
+                            <td>{{policy.description}}</td>
+                            <td class="kc-action-cell" ng-click="removePolicy(selectedPolicies, policy);">
+                                {{:: 'remove' | translate}}
+                            </td>
+                        </tr>
+                        <tr data-ng-show="!selectedPolicies || selectedPolicies.length == 0">
+                            <td class="text-muted" colspan="3">{{:: 'authz-no-policies-assigned' | translate}}</td>
+                        </tr>
+                        </tbody>
+                    </table>
                 </div>
-
                 <kc-tooltip>{{:: 'authz-policy-apply-policy.tooltip' | translate}}</kc-tooltip>
             </div>
             <div class="form-group clearfix">
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html
index 6911daa..acaa7a2 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html
@@ -5,8 +5,8 @@
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
-        <li data-ng-show="create && policyState.state.name != null && historyBackOnSaveOrCancel">{{policyState.state.name}}</li>
-        <li data-ng-show="create && policyState.state.name == null && historyBackOnSaveOrCancel">{{policyState.previousPage.name}}</li>
+        <li data-ng-show="policyState.state.policy.name != null && historyBackOnSaveOrCancel">{{policyState.state.policy.name}}</li>
+        <li data-ng-show="policyState.state.policy.name == null && historyBackOnSaveOrCancel">{{:: policyState.state.previousPage.name | translate}}</li>
         <li data-ng-show="create">{{:: 'authz-add-aggregated-policy' | translate}}</li>
         <li data-ng-hide="create">{{:: 'authz-aggregated' | translate}}</li>
         <li data-ng-hide="create">{{originalPolicy.name}}</li>
@@ -47,7 +47,8 @@
                                         <div class="pull-right">
                                             <select id="create-policy" class="form-control" ng-model="policyType"
                                                     ng-options="p.name for p in policyProviders track by p.type"
-                                                    data-ng-change="addPolicy(policyType);">
+                                                    data-ng-change="addPolicy(policyType);"
+                                                    data-ng-hide="historyBackOnSaveOrCancel">
                                                 <option value="" disabled selected>{{:: 'authz-create-policy' | translate}}...</option>
                                             </select>
                                         </div>
@@ -62,7 +63,8 @@
                         </thead>
                         <tbody>
                             <tr ng-repeat="policy in selectedPolicies">
-                                <td><a href="" data-ng-click="detailPolicy(policy)">{{policy.name}}</a></td>
+                                <td data-ng-hide="historyBackOnSaveOrCancel"><a href="" data-ng-click="detailPolicy(policy)">{{policy.name}}</a></td>
+                                <td data-ng-show="historyBackOnSaveOrCancel">{{policy.name}}</td>
                                 <td>{{policy.description}}</td>
                                 <td class="kc-action-cell" ng-click="removePolicy(selectedPolicies, policy);">
                                     {{:: 'remove' | translate}}
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-client-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-client-detail.html
index 85c0769..9c5630a 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-client-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-client-detail.html
@@ -5,8 +5,8 @@
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
-        <li data-ng-show="create && policyState.state.name != null && historyBackOnSaveOrCancel">{{policyState.state.name}}</li>
-        <li data-ng-show="create && policyState.state.name == null && historyBackOnSaveOrCancel">{{policyState.previousPage.name}}</li>
+        <li data-ng-show="policyState.state.policy.name != null && historyBackOnSaveOrCancel">{{policyState.state.policy.name}}</li>
+        <li data-ng-show="policyState.state.policy.name == null && historyBackOnSaveOrCancel">{{:: policyState.state.previousPage.name | translate}}</li>
         <li data-ng-show="create">{{:: 'authz-add-client-policy' | translate}}</li>
         <li data-ng-hide="create">{{:: 'client' | translate}}</li>
         <li data-ng-hide="create">{{originalPolicy.name}}</li>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-drools-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-drools-detail.html
index 1ab6662..583548f 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-drools-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-drools-detail.html
@@ -5,8 +5,8 @@
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
-        <li data-ng-show="create && policyState.state.name != null && historyBackOnSaveOrCancel">{{policyState.state.name}}</li>
-        <li data-ng-show="create && policyState.state.name == null && historyBackOnSaveOrCancel">{{policyState.previousPage.name}}</li>
+        <li data-ng-show="policyState.state.policy.name != null && historyBackOnSaveOrCancel">{{policyState.state.policy.name}}</li>
+        <li data-ng-show="policyState.state.policy.name == null && historyBackOnSaveOrCancel">{{:: policyState.state.previousPage.name | translate}}</li>
         <li data-ng-show="create">{{:: 'authz-add-drools-policy' | translate}}</li>
         <li data-ng-hide="create">Rules</li>
         <li data-ng-hide="create">{{originalPolicy.name}}</li>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-group-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-group-detail.html
index 21d6908..71cec33 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-group-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-group-detail.html
@@ -22,8 +22,8 @@
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
-        <li data-ng-show="create && policyState.state.name != null && historyBackOnSaveOrCancel">{{policyState.state.name}}</li>
-        <li data-ng-show="create && policyState.state.name == null && historyBackOnSaveOrCancel">{{policyState.previousPage.name}}</li>
+        <li data-ng-show="policyState.state.policy.name != null && historyBackOnSaveOrCancel">{{policyState.state.policy.name}}</li>
+        <li data-ng-show="policyState.state.policy.name == null && historyBackOnSaveOrCancel">{{:: policyState.state.previousPage.name | translate}}</li>
         <li data-ng-show="create">{{:: 'authz-add-group-policy' | translate}}</li>
         <li data-ng-hide="create">{{:: 'groups' | translate}}</li>
         <li data-ng-hide="create">{{originalPolicy.name}}</li>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-js-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-js-detail.html
index dc3173c..80f70e1 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-js-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-js-detail.html
@@ -8,8 +8,8 @@
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
-        <li data-ng-show="create && policyState.state.name != null && historyBackOnSaveOrCancel">{{policyState.state.name}}</li>
-        <li data-ng-show="create && policyState.state.name == null && historyBackOnSaveOrCancel">{{policyState.previousPage.name}}</li>
+        <li data-ng-show="policyState.state.policy.name != null && historyBackOnSaveOrCancel">{{policyState.state.policy.name}}</li>
+        <li data-ng-show="policyState.state.policy.name == null && historyBackOnSaveOrCancel">{{:: policyState.state.previousPage.name | translate}}</li>
         <li data-ng-show="create">{{:: 'authz-add-js-policy' | translate}}</li>
         <li data-ng-hide="create">JavaScript</li>
         <li data-ng-hide="create">{{originalPolicy.name}}</li>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-role-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-role-detail.html
index 2536b5d..9448682 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-role-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-role-detail.html
@@ -23,8 +23,8 @@
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
-        <li data-ng-show="create && policyState.state.name != null && historyBackOnSaveOrCancel">{{policyState.state.name}}</li>
-        <li data-ng-show="create && policyState.state.name == null && historyBackOnSaveOrCancel">{{:: policyState.previousPage.name | translate}}</li>
+        <li data-ng-show="policyState.state.policy.name != null && historyBackOnSaveOrCancel">{{policyState.state.policy.name}}</li>
+        <li data-ng-show="policyState.state.policy.name == null && historyBackOnSaveOrCancel">{{:: policyState.state.previousPage.name | translate}}</li>
         <li data-ng-show="create">{{:: 'authz-add-role-policy' | translate}}</li>
         <li data-ng-hide="create">{{:: 'roles' | translate}}</li>
         <li data-ng-hide="create">{{originalPolicy.name}}</li>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-time-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-time-detail.html
index 393a10c..4af9014 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-time-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-time-detail.html
@@ -8,8 +8,8 @@
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
-        <li data-ng-show="create && policyState.state.name != null && historyBackOnSaveOrCancel">{{policyState.state.name}}</li>
-        <li data-ng-show="create && policyState.state.name == null && historyBackOnSaveOrCancel">{{policyState.previousPage.name}}</li>
+        <li data-ng-show="policyState.state.policy.name != null && historyBackOnSaveOrCancel">{{policyState.state.policy.name}}</li>
+        <li data-ng-show="policyState.state.policy.name == null && historyBackOnSaveOrCancel">{{:: policyState.state.previousPage.name | translate}}</li>
         <li data-ng-show="create">{{:: 'authz-add-time-policy' | translate}}</li>
         <li data-ng-hide="create">{{:: 'time' | translate}}</li>
         <li data-ng-hide="create">{{originalPolicy.name}}</li>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-user-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-user-detail.html
index 41221fe..80d81ac 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-user-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-user-detail.html
@@ -5,8 +5,8 @@
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
         <li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
-        <li data-ng-show="create && policyState.state.name != null && historyBackOnSaveOrCancel">{{policyState.state.name}}</li>
-        <li data-ng-show="create && policyState.state.name == null && historyBackOnSaveOrCancel">{{policyState.previousPage.name}}</li>
+        <li data-ng-show="policyState.state.policy.name != null && historyBackOnSaveOrCancel">{{policyState.state.policy.name}}</li>
+        <li data-ng-show="policyState.state.policy.name == null && historyBackOnSaveOrCancel">{{:: policyState.state.previousPage.name | translate}}</li>
         <li data-ng-show="create">{{:: 'authz-add-user-policy' | translate}}</li>
         <li data-ng-hide="create">{{:: 'user' | translate}}</li>
         <li data-ng-hide="create">{{originalPolicy.name}}</li>