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.

This commit is contained in:
Michael Jumper
2015-03-12 14:21:18 -07:00
parent fea085fd7b
commit 0aff801642
3 changed files with 69 additions and 6 deletions

View File

@@ -80,6 +80,23 @@ angular.module('userMenu').directive('guacUserMenu', [function guacUserMenu() {
*/ */
var document = $document[0]; 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 * Whether the current user has sufficient permissions to use the
* management interface. If permissions have not yet been loaded, * 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 * Logs out the current user, redirecting them to back to the login
* screen after logout completes. * screen after logout completes.
*/ */
$scope.logout = function logout() { $scope.logout = function logout() {
authenticationService.logout()['finally'](function logoutComplete() { authenticationService.logout()['finally'](function logoutComplete() {
$location.path('/login'); $location.path('/login/');
}); });
}; };

View File

@@ -169,7 +169,14 @@
} }
.user-menu .options li a:hover { .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, .user-menu .options li a.home,

View File

@@ -27,10 +27,35 @@
<!-- Menu options --> <!-- Menu options -->
<ul class="options"> <ul class="options">
<li><a class="home" href="#/">{{'USER_MENU.ACTION_NAVIGATE_HOME' | translate}}</a></li>
<li><a class="manage" ng-show="canManageGuacamole" href="#/manage/">{{'USER_MENU.ACTION_MANAGE' | translate}}</a></li> <!-- Home -->
<li><a class="change-password" ng-click="showPasswordUpdate()" ng-show="canChangePassword">{{'USER_MENU.ACTION_CHANGE_PASSWORD' | translate}}</a></li> <li>
<li><a class="logout" ng-click="logout()">{{'USER_MENU.ACTION_LOGOUT' | translate}}</a></li> <a class="home" ng-click="navigateHome()" ng-class="{disabled: homeDisabled}" href="#/">
{{'USER_MENU.ACTION_NAVIGATE_HOME' | translate}}
</a>
</li>
<!-- Manage -->
<li>
<a class="manage" ng-click="manage()" ng-class="{disabled: manageDisabled}" ng-show="canManageGuacamole" href="#/manage/">
{{'USER_MENU.ACTION_MANAGE' | translate}}
</a>
</li>
<!-- Change password -->
<li>
<a class="change-password" ng-click="showPasswordUpdate()" ng-show="canChangePassword">
{{'USER_MENU.ACTION_CHANGE_PASSWORD' | translate}}
</a>
</li>
<!-- Logout -->
<li>
<a class="logout" ng-click="logout()">
{{'USER_MENU.ACTION_LOGOUT' | translate}}
</a>
</li>
</ul> </ul>
</div> </div>