diff --git a/static/js/directives/ui/header-bar.js b/static/js/directives/ui/header-bar.js index e54cc476f..956cae711 100644 --- a/static/js/directives/ui/header-bar.js +++ b/static/js/directives/ui/header-bar.js @@ -211,11 +211,11 @@ angular.module('quay').directive('headerBar', function () { $scope.createRobot = function(context) { var namespace = $scope.getNamespace(context); - CreateService.askCreateRobot(function(created) { - if (isorg) { - $location.url('/organization/' + namespace + '?tab=robots'); + CreateService.askCreateRobot(namespace, function(created) { + if (UserService.isOrganization(namespace)) { + $location.url('/organization/' + namespace + '?tab=robots&showRobot=' + created.name); } else { - $location.url('/user/' + namespace + '?tab=robots'); + $location.url('/user/' + namespace + '?tab=robots&showRobot=' + created.name); } }); }; @@ -224,8 +224,8 @@ angular.module('quay').directive('headerBar', function () { var namespace = $scope.getNamespace(context); if (!namespace || !UserService.isNamespaceAdmin(namespace)) { return; } - CreateService.askCreateTeam(function(created) { - $location.url('/organization/' + namespace + '/teams/' + teamname); + CreateService.askCreateTeam(namespace, function(created) { + $location.url('/organization/' + namespace + '/teams/' + created.name); }); }; } diff --git a/static/js/directives/ui/robots-manager.js b/static/js/directives/ui/robots-manager.js index 6a567c885..8cacfa687 100644 --- a/static/js/directives/ui/robots-manager.js +++ b/static/js/directives/ui/robots-manager.js @@ -13,7 +13,8 @@ angular.module('quay').directive('robotsManager', function () { 'user': '=user', 'isEnabled': '=isEnabled' }, - controller: function($scope, $element, ApiService, $routeParams, CreateService, Config) { + controller: function($scope, $element, ApiService, $routeParams, $location, CreateService, + Config, $rootScope) { $scope.ROBOT_PATTERN = ROBOT_PATTERN; $scope.robots = null; @@ -22,6 +23,17 @@ angular.module('quay').directive('robotsManager', function () { $scope.showRobotCounter = 0; $scope.Config = Config; + // Listen for route changes and update the tabs accordingly. + var locationListener = $rootScope.$on('$routeUpdate', function(){ + if ($location.search()['showRobot']) { + $scope.filterToRobot($location.search()['showRobot']); + } + }); + + $scope.$on('$destroy', function() { + locationListener && locationListener(); + }); + var loadRobotPermissions = function(info) { var shortName = $scope.getShortenedName(info.name); info.loading_permissions = true; @@ -31,6 +43,20 @@ angular.module('quay').directive('robotsManager', function () { }, ApiService.errorDisplay('Could not load robot permissions')); }; + $scope.filterToRobot = function(robotName) { + if ($scope.robotFilter == robotName) { + return; + } + + var index = $scope.findRobotIndexByName(robotName); + if (index < 0) { + // Robot doesn't exist. Reload the list to see if we can find it. + update(); + } + + $scope.robotFilter = robotName; + }; + $scope.showPermissions = function(robotInfo) { robotInfo.showing_permissions = !robotInfo.showing_permissions; @@ -112,10 +138,7 @@ angular.module('quay').directive('robotsManager', function () { $scope.loading = false; if ($routeParams.showRobot) { - var index = $scope.findRobotIndexByName($routeParams.showRobot); - if (index >= 0) { - $scope.robotFilter = $routeParams.showRobot; - } + $scope.filterToRobot($routeParams.showRobot); } }); }; diff --git a/static/js/services/ui-service.js b/static/js/services/ui-service.js index 465f2c977..86a326390 100644 --- a/static/js/services/ui-service.js +++ b/static/js/services/ui-service.js @@ -216,7 +216,7 @@ angular.module('quay').factory('UIService', ['$timeout', '$rootScope', '$locatio var registerListeners = function(tabs) { // Listen for scope destruction. scope.$on('$destroy', function() { - dispoed = true; + disposed = true; locationListener && locationListener(); });