Have entity reference link to the new user and org pages for showing robots

This commit is contained in:
Joseph Schorr 2015-04-22 15:26:01 -04:00
parent d6a1493d52
commit ee9d6ae66a

View file

@ -15,12 +15,40 @@ angular.module('quay').directive('entityReference', function () {
'showAvatar': '@showAvatar',
'avatarSize': '@avatarSize'
},
controller: function($scope, $element, UserService, UtilService) {
controller: function($scope, $element, UserService, UtilService, Config) {
$scope.getIsAdmin = function(namespace) {
return UserService.isNamespaceAdmin(namespace);
};
$scope.getRobotUrl = function(name) {
if (Config.isNewLayout()) {
return $scope.getNewRobotUrl(name);
} else {
return $scope.getOldRobotUrl(name);
}
};
$scope.getNewRobotUrl = function(name) {
var namespace = $scope.getPrefix(name);
if (!namespace) {
return '';
}
if (!$scope.getIsAdmin(namespace)) {
return '';
}
var org = UserService.getOrganization(namespace);
if (!org) {
// This robot is owned by the user.
return '/user/' + namespace + '?tab=robots&showRobot=' + UtilService.textToSafeHtml(name);
}
return '/organization/' + org['name'] + '?tab=robots&showRobot=' + UtilService.textToSafeHtml(name);
};
// TODO(jschorr): Remove when new layout is in prod.
$scope.getOldRobotUrl = function(name) {
var namespace = $scope.getPrefix(name);
if (!namespace) {
return '';