From 0aff80164251aff4faca5fee81a9863b3e9b66f9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 12 Mar 2015 14:21:18 -0700 Subject: [PATCH] GUAC-1120: Display menu options as disabled if they are not relevant. Navigate explicitly via click event, in case browser depends on click propagation to handle href, but keep href for sake of "open in new tab", etc. --- .../app/userMenu/directives/guacUserMenu.js | 33 ++++++++++++++++++- .../webapp/app/userMenu/styles/user-menu.css | 9 ++++- .../app/userMenu/templates/guacUserMenu.html | 33 ++++++++++++++++--- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/guacamole/src/main/webapp/app/userMenu/directives/guacUserMenu.js b/guacamole/src/main/webapp/app/userMenu/directives/guacUserMenu.js index 77c1f5895..042254422 100644 --- a/guacamole/src/main/webapp/app/userMenu/directives/guacUserMenu.js +++ b/guacamole/src/main/webapp/app/userMenu/directives/guacUserMenu.js @@ -80,6 +80,23 @@ angular.module('userMenu').directive('guacUserMenu', [function guacUserMenu() { */ var document = $document[0]; + /** + * Whether the option to go to the home screen is disabled. + * + * @type Boolean + */ + $scope.homeDisabled = ($location.path() === '/'); + + /** + * Whether the option to go to the management interface is + * disabled. Note that shis is different from canManageGuacamole, + * which deals with whether permission to manage is granted. A user + * may have permission, yet see this option as currently disabled. + * + * @type Boolean + */ + $scope.manageDisabled = ($location.path() === '/manage/'); + /** * Whether the current user has sufficient permissions to use the * management interface. If permissions have not yet been loaded, @@ -263,13 +280,27 @@ angular.module('userMenu').directive('guacUserMenu', [function guacUserMenu() { }; + /** + * Navigates to the home screen. + */ + $scope.navigateHome = function navigateHome() { + $location.path('/'); + }; + + /** + * Navigates to the management interface. + */ + $scope.manage = function manage() { + $location.path('/manage/'); + }; + /** * Logs out the current user, redirecting them to back to the login * screen after logout completes. */ $scope.logout = function logout() { authenticationService.logout()['finally'](function logoutComplete() { - $location.path('/login'); + $location.path('/login/'); }); }; diff --git a/guacamole/src/main/webapp/app/userMenu/styles/user-menu.css b/guacamole/src/main/webapp/app/userMenu/styles/user-menu.css index aa1f1f70f..8405abc96 100644 --- a/guacamole/src/main/webapp/app/userMenu/styles/user-menu.css +++ b/guacamole/src/main/webapp/app/userMenu/styles/user-menu.css @@ -169,7 +169,14 @@ } .user-menu .options li a:hover { - background: #CDA; + background-color: #CDA; +} + +.user-menu .options li a.disabled, +.user-menu .options li a.disabled:hover { + background-color: transparent; + cursor: default; + opacity: 0.25; } .user-menu .options li a.home, diff --git a/guacamole/src/main/webapp/app/userMenu/templates/guacUserMenu.html b/guacamole/src/main/webapp/app/userMenu/templates/guacUserMenu.html index 2943b8b84..b49c956f9 100644 --- a/guacamole/src/main/webapp/app/userMenu/templates/guacUserMenu.html +++ b/guacamole/src/main/webapp/app/userMenu/templates/guacUserMenu.html @@ -27,10 +27,35 @@