GUAC-1126: Only display NAVIGATE_HOME_ACTION if the home page is not the current page.

This commit is contained in:
Michael Jumper
2015-04-06 22:02:14 -07:00
parent 6fd6d64981
commit 9a0ac52ee1

View File

@@ -34,6 +34,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
var $location = $injector.get('$location'); var $location = $injector.get('$location');
var guacClientManager = $injector.get('guacClientManager'); var guacClientManager = $injector.get('guacClientManager');
var guacNotification = $injector.get('guacNotification'); var guacNotification = $injector.get('guacNotification');
var userPageService = $injector.get('userPageService');
/** /**
* The minimum number of pixels a drag gesture must move to result in the * The minimum number of pixels a drag gesture must move to result in the
@@ -126,15 +127,27 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
}; };
/** /**
* Action which returns the user to the home screen. * Action which returns the user to the home screen. If the home page has
* not yet been determined, this will be null.
*/ */
var NAVIGATE_HOME_ACTION = { var NAVIGATE_HOME_ACTION = null;
// Assign home page action once user's home page has been determined
userPageService.getHomePage()
.then(function homePageRetrieved(homePage) {
// Define home action only if different from current location
if ($location.path() !== homePage.url) {
NAVIGATE_HOME_ACTION = {
name : "CLIENT.ACTION_NAVIGATE_HOME", name : "CLIENT.ACTION_NAVIGATE_HOME",
className : "home button", className : "home button",
callback : function navigateHomeCallback() { callback : function navigateHomeCallback() {
$location.path('/'); $location.url(homePage.url);
} }
}; };
}
});
/** /**
* Action which replaces the current client with a newly-connected client. * Action which replaces the current client with a newly-connected client.
@@ -414,6 +427,13 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
if (!connectionState) if (!connectionState)
return; return;
// Build array of available actions
var actions;
if (NAVIGATE_HOME_ACTION)
actions = [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ];
else
actions = [ RECONNECT_ACTION ];
// Get any associated status code // Get any associated status code
var status = $scope.client.clientState.statusCode; var status = $scope.client.clientState.statusCode;
@@ -441,7 +461,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
title : "CLIENT.DIALOG_HEADER_CONNECTION_ERROR", title : "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
text : "CLIENT.ERROR_CLIENT_" + errorName, text : "CLIENT.ERROR_CLIENT_" + errorName,
countdown : countdown, countdown : countdown,
actions: [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ] actions : actions
}); });
} }
@@ -461,7 +481,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
title : "CLIENT.DIALOG_HEADER_CONNECTION_ERROR", title : "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
text : "CLIENT.ERROR_TUNNEL_" + errorName, text : "CLIENT.ERROR_TUNNEL_" + errorName,
countdown : countdown, countdown : countdown,
actions: [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ] actions : actions
}); });
} }
@@ -471,7 +491,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
guacNotification.showStatus({ guacNotification.showStatus({
title : "CLIENT.DIALOG_HEADER_DISCONNECTED", title : "CLIENT.DIALOG_HEADER_DISCONNECTED",
text : "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase(), text : "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase(),
actions: [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ] actions : actions
}); });
} }