From ee9d6ae66ab78bbeb048e9a8021a0c35fb31c749 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 22 Apr 2015 15:26:01 -0400 Subject: [PATCH] Have entity reference link to the new user and org pages for showing robots --- static/js/directives/ui/entity-reference.js | 30 ++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/static/js/directives/ui/entity-reference.js b/static/js/directives/ui/entity-reference.js index 403ddcd9a..929cfb03c 100644 --- a/static/js/directives/ui/entity-reference.js +++ b/static/js/directives/ui/entity-reference.js @@ -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 '';