From 9729ac3cbb34c372946b2cc3e87ecd659bc203a3 Mon Sep 17 00:00:00 2001 From: Charlton Austin Date: Mon, 8 May 2017 15:57:27 -0400 Subject: [PATCH] fix(entity-search.js): fix reload namespace before if you reloaded the say the team owners tab you would get an error this now watches the namespace and updates it [TESTING -> tested against prod like data with local docker build] Issue: https://www.pivotaltracker.com/story/show/145041479 - [ ] It works! - [ ] Comments provide sufficient explanations for the next contributor - [ ] Tests cover changes and corner cases - [ ] Follows Quay syntax patterns and format --- static/js/directives/ui/entity-search.js | 14 +++++++++++--- static/js/services/user-service.js | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/static/js/directives/ui/entity-search.js b/static/js/directives/ui/entity-search.js index 8bcefe249..a6cad6f31 100644 --- a/static/js/directives/ui/entity-search.js +++ b/static/js/directives/ui/entity-search.js @@ -68,7 +68,10 @@ angular.module('quay').directive('entitySearch', function () { }; $scope.lazyLoad = function() { - if (!$scope.namespace || !$scope.lazyLoading) { return; } + if (!$scope.namespace || !$scope.thisUser || !$scope.lazyLoading) { return; } + $scope.isAdmin = UserService.isNamespaceAdmin($scope.namespace); + $scope.isOrganization = !!UserService.getOrganization($scope.namespace); + // Reset the cached teams and robots. $scope.teams = null; @@ -359,8 +362,13 @@ angular.module('quay').directive('entitySearch', function () { $scope.$watch('namespace', function(namespace) { if (!namespace) { return; } - $scope.isAdmin = UserService.isNamespaceAdmin(namespace); - $scope.isOrganization = !!UserService.getOrganization(namespace); + $scope.lazyLoad(); + }); + + UserService.updateUserIn($scope, function(currentUser){ + if (currentUser.anonymous) { return; } + $scope.thisUser = currentUser; + $scope.lazyLoad(); }); $scope.$watch('currentEntity', function(entity) { diff --git a/static/js/services/user-service.js b/static/js/services/user-service.js index 256605c14..7cc8388c9 100644 --- a/static/js/services/user-service.js +++ b/static/js/services/user-service.js @@ -14,9 +14,9 @@ function(ApiService, CookieService, $rootScope, Config, $location) { organizations: [], logins: [], beforeload: true - } + }; - var userService = {} + var userService = {}; var _EXTERNAL_SERVICES = ['ldap', 'jwtauthn', 'keystone', 'dex']; userService.hasEverLoggedIn = function() {